[med-svn] [camp] 04/11: New upstream version 0.7.1.5
Flavien Bridault
fbridault-guest at moszumanska.debian.org
Wed Nov 23 16:44:42 UTC 2016
This is an automated email from the git hooks/post-receive script.
fbridault-guest pushed a commit to branch master
in repository camp.
commit ac17d3f07a4e2c6b2aab823b1b8a22a981299e3f
Author: Flavien Bridault <fbridault at ircad.fr>
Date: Wed Nov 16 11:33:38 2016 +0100
New upstream version 0.7.1.5
---
include/camp/class.hpp | 744 +++++++++++++++++------------------
include/camp/detail/classmanager.hpp | 378 +++++++++---------
include/camp/detail/enummanager.hpp | 372 +++++++++---------
include/camp/enum.hpp | 460 +++++++++++-----------
test/function.hpp | 354 ++++++++---------
test/functionaccess.hpp | 130 +++---
test/inheritance.hpp | 230 +++++------
test/mapper.hpp | 296 +++++++-------
test/propertyaccess.hpp | 148 +++----
9 files changed, 1556 insertions(+), 1556 deletions(-)
diff --git a/include/camp/class.hpp b/include/camp/class.hpp
index 1cf20ad..5d7c416 100644
--- a/include/camp/class.hpp
+++ b/include/camp/class.hpp
@@ -1,372 +1,372 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-
-#ifndef CAMP_CLASS_HPP
-#define CAMP_CLASS_HPP
-
-
-#include <camp/config.hpp>
-#include <camp/args.hpp>
-#include <camp/classget.hpp>
-#include <camp/classcast.hpp>
-#include <camp/property.hpp>
-#include <camp/function.hpp>
-#include <camp/tagholder.hpp>
-#include <camp/errors.hpp>
-#include <camp/userobject.hpp>
-#include <camp/detail/classmanager.hpp>
-#include <camp/detail/typeid.hpp>
-#include <boost/noncopyable.hpp>
-//#include <boost/shared_ptr.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <string>
-
-
-namespace bm = boost::multi_index;
-
-namespace camp
-{
-template <typename T> class ClassBuilder;
-class Constructor;
-class Value;
-class ClassVisitor;
-
-/**
- * \brief camp::Class represents a metaclass composed of properties and functions
- *
- * camp::Class is the main class of the CAMP API. It defines a metaclass, which
- * is an abstract representation of a C++ class with its own properties,
- * functions, constructors, base classes, etc.
- *
- * Classes are declared, bound to a C++ type and filled with the \c declare
- * template function.
- *
- * \code
- * class MyClass
- * {
- * public:
- *
- * MyClass();
- * int getProp() const;
- * void setProp(int);
- * std::string func();
- * };
- *
- * camp::Class::declare<MyClass>("MyClass")
- * .tag("help", "this is my class")
- * .constructor0()
- * .property("prop", &MyClass::getProp, &MyClass::setProp)
- * .function("func", &MyClass::func);
- * \endcode
- *
- * It then provides a set of accessors to retrieve its member functions and properties.
- *
- * \code
- * const camp::Class& metaclass = camp::classByType<MyClass>();
- *
- * const camp::Property& prop = metaclass.property("prop");
- * const camp::Function& func = metaclass.function("func");
- * \endcode
- *
- * Another way to inspect a class, which is more type-safe, is to use a ClassVisitor.
- *
- * \code
- * MyVisitor visitor;
- * metaclass.visit(visitor);
- * \endcode
- *
- * It also allows to create and destroy instances of the bound C++ class.
- *
- * \code
- * MyClass* obj = metaclass.construct<MyClass>();
- * metaclass.destroy(obj);
- * \endcode
- *
- * \remark All function and property names are unique within the metaclass.
- *
- * \sa Enum, TagHolder, ClassBuilder, Function, Property
- */
-class CAMP_API Class : public TagHolder, boost::noncopyable
-{
-public:
-
- /**
- * \brief Declare a new metaclass
- *
- * This is the function to call to create a new metaclass. The template
- * parameter T is the C++ class that will be bound to the metaclass.
- *
- * \param name Name of the metaclass in CAMP. This name identifies
- * the metaclass and thus has to be unique
- *
- * \return A ClassBuilder<T> object that will provide functions
- * to fill the new metaclass with properties, functions, etc.
- */
- template <typename T>
- static ClassBuilder<T> declare(const std::string& name);
-
-public:
-
- /**
- * \brief Return the name of the metaclass
- *
- * \return String containing the name of the metaclass
- */
- const std::string& name() const;
-
- /**
- * \brief Return the total number of base metaclasses of this metaclass
- *
- * \return Number of base metaclasses
- */
- std::size_t baseCount() const;
-
- /**
- * \brief Return a base metaclass from its index
- *
- * \param index Index of the base to get
- *
- * \return Reference to the index-th base metaclass of this metaclass
- *
- * \throw OutOfRange index is out of range
- */
- const Class& base(std::size_t index) const;
-
- /**
- * \brief Return the total number of functions of this metaclass
- *
- * \return Number of functions
- */
- std::size_t functionCount() const;
-
- /**
- * \brief Check if this metaclass contains the given function
- *
- * \param name Name of the function to check
- *
- * \return True if the function is in the metaclass, false otherwise
- */
- bool hasFunction(const std::string& name) const;
-
- /**
- * \brief Get a function from its index in this metaclass
- *
- * \param index Index of the function to get
- *
- * \return Reference to the function
- *
- * \throw OutOfRange index is out of range
- */
- const Function& function(std::size_t index) const;
-
- /**
- * \brief Get a function from its name
- *
- * \param name Name of the function to get (case sensitive)
- *
- * \return Reference to the function
- *
- * \throw FunctionNotFound \a name is not a function of the metaclass
- */
- const Function& function(const std::string& name) const;
-
- /**
- * \brief Return the total number of properties of this metaclass
- *
- * \return Number of properties
- */
- std::size_t propertyCount() const;
-
- /**
- * \brief Check if this metaclass contains the given property
- *
- * \param name Name of the property to check
- *
- * \return True if the property is in the metaclass, false otherwise
- */
- bool hasProperty(const std::string& name) const;
-
- /**
- * \brief Get a property from its index in this metaclass
- *
- * \param index Index of the property to get
- *
- * \return Reference to the property
- *
- * \throw OutOfRange index is out of range
- */
- const Property& property(std::size_t index) const;
-
- /**
- * \brief Get a property from its name
- *
- * \param name Name of the property to get (case sensitive)
- *
- * \return Reference to the property
- *
- * \throw PropertyNotFound \a name is not a property of the metaclass
- */
- const Property& property(const std::string& name) const;
-
- /**
- * \brief Construct a new instance of the C++ class bound to the metaclass
- *
- * If no constructor can match the provided arguments, UserObject::nothing
- * is returned.
- * The new instance is wrapped into a UserObject. It must be destroyed
- * with the Class::destroy function.
- *
- * \param args Arguments to pass to the constructor (empty by default)
- *
- * \return New instance wrapped into a UserObject, or UserObject::nothing if it failed
- */
- UserObject construct(const Args& args = Args::empty) const;
-
- /**
- * \brief Destroy an instance of the C++ class bound to the metaclass
- *
- * This function must be called to destroy every instance created with
- * Class::construct.
- *
- * \param object Object to be destroyed
- */
- void destroy(const UserObject& object) const;
-
- /**
- * \brief Start visitation of a class
- *
- * \param visitor Visitor to use for visitation
- */
- void visit(ClassVisitor& visitor) const;
-
- /**
- * \brief Convert a pointer to an object to be compatible with a base or derived metaclass
- *
- * The target metaclass may be a base or a derived of this, both cases are properly handled.
- *
- * \param pointer Pointer to convert
- * \param target Target metaclass to convert to
- *
- * \return Converted pointer
- *
- * \throw ClassUnrelated \a target is not a base nor a derived class of this
- */
- void* applyOffset(void* pointer, const Class& target) const;
-
- /**
- * \brief Operator == to check equality between two metaclasses
- *
- * Two metaclasses are equal if their name is the same.
- *
- * \param other Metaclass to compare with this
- *
- * \return True if both metaclasses are the same, false otherwise
- */
- bool operator==(const Class& other) const;
-
- /**
- * \brief Operator != to check inequality between two metaclasses
- *
- * \param other Metaclass to compare with this
- *
- * \return True if metaclasses are different, false if they are equal
- */
- bool operator!=(const Class& other) const;
-
-private:
-
- template <typename T> friend class ClassBuilder;
- friend class detail::ClassManager;
-
- /**
- * \brief Construct the metaclass from its name
- *
- * \param name Name of the metaclass
- */
- Class(const std::string& name);
-
- /**
- * \brief Get the offset of a base metaclass
- *
- * \param base Base metaclass to check
- *
- * \return offset between this and base, or -1 if both classes are unrelated
- */
- int baseOffset(const Class& base) const;
-
-private:
-
- /**
- * \brief Structure holding informations about a base metaclass
- */
- struct BaseInfo
- {
- const Class* base;
- int offset;
- };
-
- typedef std::shared_ptr<Property> PropertyPtr;
- typedef std::shared_ptr<Function> FunctionPtr;
- typedef std::shared_ptr<Constructor> ConstructorPtr;
- typedef std::vector<ConstructorPtr> ConstructorList;
- typedef std::vector<BaseInfo> BaseList;
-
- struct Id;
- struct Name;
-
- typedef boost::multi_index_container<PropertyPtr,
- bm::indexed_by<bm::random_access<bm::tag<Id> >,
- bm::ordered_unique<bm::tag<Name>, bm::const_mem_fun<Property, const std::string&, &Property::name> >
- >
- > PropertyTable;
-
- typedef boost::multi_index_container<FunctionPtr,
- bm::indexed_by<bm::random_access<bm::tag<Id> >,
- bm::ordered_unique<bm::tag<Name>, bm::const_mem_fun<Function, const std::string&, &Function::name> >
- >
- > FunctionTable;
-
- typedef PropertyTable::index<Name>::type PropertyNameIndex;
- typedef FunctionTable::index<Name>::type FunctionNameIndex;
- typedef void (*Destructor)(const UserObject&);
-
- std::string m_name; ///< Name of the metaclass
- FunctionTable m_functions; ///< Table of metafunctions indexed by name
- PropertyTable m_properties; ///< Table of metaproperties indexed by name
- BaseList m_bases; ///< List of base metaclasses
- ConstructorList m_constructors; ///< List of metaconstructors
- Destructor m_destructor; ///< Destructor (function that is able to delete an abstract object)
-};
-
-} // namespace camp
-
-// Must be included here because of mutual dependance between Class and ClassBuilder
-#include <camp/classbuilder.hpp>
-
-#include <camp/class.inl>
-
-
-#endif // CAMP_CLASS_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+
+#ifndef CAMP_CLASS_HPP
+#define CAMP_CLASS_HPP
+
+
+#include <camp/config.hpp>
+#include <camp/args.hpp>
+#include <camp/classget.hpp>
+#include <camp/classcast.hpp>
+#include <camp/property.hpp>
+#include <camp/function.hpp>
+#include <camp/tagholder.hpp>
+#include <camp/errors.hpp>
+#include <camp/userobject.hpp>
+#include <camp/detail/classmanager.hpp>
+#include <camp/detail/typeid.hpp>
+#include <boost/noncopyable.hpp>
+//#include <boost/shared_ptr.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+#include <string>
+
+
+namespace bm = boost::multi_index;
+
+namespace camp
+{
+template <typename T> class ClassBuilder;
+class Constructor;
+class Value;
+class ClassVisitor;
+
+/**
+ * \brief camp::Class represents a metaclass composed of properties and functions
+ *
+ * camp::Class is the main class of the CAMP API. It defines a metaclass, which
+ * is an abstract representation of a C++ class with its own properties,
+ * functions, constructors, base classes, etc.
+ *
+ * Classes are declared, bound to a C++ type and filled with the \c declare
+ * template function.
+ *
+ * \code
+ * class MyClass
+ * {
+ * public:
+ *
+ * MyClass();
+ * int getProp() const;
+ * void setProp(int);
+ * std::string func();
+ * };
+ *
+ * camp::Class::declare<MyClass>("MyClass")
+ * .tag("help", "this is my class")
+ * .constructor0()
+ * .property("prop", &MyClass::getProp, &MyClass::setProp)
+ * .function("func", &MyClass::func);
+ * \endcode
+ *
+ * It then provides a set of accessors to retrieve its member functions and properties.
+ *
+ * \code
+ * const camp::Class& metaclass = camp::classByType<MyClass>();
+ *
+ * const camp::Property& prop = metaclass.property("prop");
+ * const camp::Function& func = metaclass.function("func");
+ * \endcode
+ *
+ * Another way to inspect a class, which is more type-safe, is to use a ClassVisitor.
+ *
+ * \code
+ * MyVisitor visitor;
+ * metaclass.visit(visitor);
+ * \endcode
+ *
+ * It also allows to create and destroy instances of the bound C++ class.
+ *
+ * \code
+ * MyClass* obj = metaclass.construct<MyClass>();
+ * metaclass.destroy(obj);
+ * \endcode
+ *
+ * \remark All function and property names are unique within the metaclass.
+ *
+ * \sa Enum, TagHolder, ClassBuilder, Function, Property
+ */
+class CAMP_API Class : public TagHolder, boost::noncopyable
+{
+public:
+
+ /**
+ * \brief Declare a new metaclass
+ *
+ * This is the function to call to create a new metaclass. The template
+ * parameter T is the C++ class that will be bound to the metaclass.
+ *
+ * \param name Name of the metaclass in CAMP. This name identifies
+ * the metaclass and thus has to be unique
+ *
+ * \return A ClassBuilder<T> object that will provide functions
+ * to fill the new metaclass with properties, functions, etc.
+ */
+ template <typename T>
+ static ClassBuilder<T> declare(const std::string& name);
+
+public:
+
+ /**
+ * \brief Return the name of the metaclass
+ *
+ * \return String containing the name of the metaclass
+ */
+ const std::string& name() const;
+
+ /**
+ * \brief Return the total number of base metaclasses of this metaclass
+ *
+ * \return Number of base metaclasses
+ */
+ std::size_t baseCount() const;
+
+ /**
+ * \brief Return a base metaclass from its index
+ *
+ * \param index Index of the base to get
+ *
+ * \return Reference to the index-th base metaclass of this metaclass
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Class& base(std::size_t index) const;
+
+ /**
+ * \brief Return the total number of functions of this metaclass
+ *
+ * \return Number of functions
+ */
+ std::size_t functionCount() const;
+
+ /**
+ * \brief Check if this metaclass contains the given function
+ *
+ * \param name Name of the function to check
+ *
+ * \return True if the function is in the metaclass, false otherwise
+ */
+ bool hasFunction(const std::string& name) const;
+
+ /**
+ * \brief Get a function from its index in this metaclass
+ *
+ * \param index Index of the function to get
+ *
+ * \return Reference to the function
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Function& function(std::size_t index) const;
+
+ /**
+ * \brief Get a function from its name
+ *
+ * \param name Name of the function to get (case sensitive)
+ *
+ * \return Reference to the function
+ *
+ * \throw FunctionNotFound \a name is not a function of the metaclass
+ */
+ const Function& function(const std::string& name) const;
+
+ /**
+ * \brief Return the total number of properties of this metaclass
+ *
+ * \return Number of properties
+ */
+ std::size_t propertyCount() const;
+
+ /**
+ * \brief Check if this metaclass contains the given property
+ *
+ * \param name Name of the property to check
+ *
+ * \return True if the property is in the metaclass, false otherwise
+ */
+ bool hasProperty(const std::string& name) const;
+
+ /**
+ * \brief Get a property from its index in this metaclass
+ *
+ * \param index Index of the property to get
+ *
+ * \return Reference to the property
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Property& property(std::size_t index) const;
+
+ /**
+ * \brief Get a property from its name
+ *
+ * \param name Name of the property to get (case sensitive)
+ *
+ * \return Reference to the property
+ *
+ * \throw PropertyNotFound \a name is not a property of the metaclass
+ */
+ const Property& property(const std::string& name) const;
+
+ /**
+ * \brief Construct a new instance of the C++ class bound to the metaclass
+ *
+ * If no constructor can match the provided arguments, UserObject::nothing
+ * is returned.
+ * The new instance is wrapped into a UserObject. It must be destroyed
+ * with the Class::destroy function.
+ *
+ * \param args Arguments to pass to the constructor (empty by default)
+ *
+ * \return New instance wrapped into a UserObject, or UserObject::nothing if it failed
+ */
+ UserObject construct(const Args& args = Args::empty) const;
+
+ /**
+ * \brief Destroy an instance of the C++ class bound to the metaclass
+ *
+ * This function must be called to destroy every instance created with
+ * Class::construct.
+ *
+ * \param object Object to be destroyed
+ */
+ void destroy(const UserObject& object) const;
+
+ /**
+ * \brief Start visitation of a class
+ *
+ * \param visitor Visitor to use for visitation
+ */
+ void visit(ClassVisitor& visitor) const;
+
+ /**
+ * \brief Convert a pointer to an object to be compatible with a base or derived metaclass
+ *
+ * The target metaclass may be a base or a derived of this, both cases are properly handled.
+ *
+ * \param pointer Pointer to convert
+ * \param target Target metaclass to convert to
+ *
+ * \return Converted pointer
+ *
+ * \throw ClassUnrelated \a target is not a base nor a derived class of this
+ */
+ void* applyOffset(void* pointer, const Class& target) const;
+
+ /**
+ * \brief Operator == to check equality between two metaclasses
+ *
+ * Two metaclasses are equal if their name is the same.
+ *
+ * \param other Metaclass to compare with this
+ *
+ * \return True if both metaclasses are the same, false otherwise
+ */
+ bool operator==(const Class& other) const;
+
+ /**
+ * \brief Operator != to check inequality between two metaclasses
+ *
+ * \param other Metaclass to compare with this
+ *
+ * \return True if metaclasses are different, false if they are equal
+ */
+ bool operator!=(const Class& other) const;
+
+private:
+
+ template <typename T> friend class ClassBuilder;
+ friend class detail::ClassManager;
+
+ /**
+ * \brief Construct the metaclass from its name
+ *
+ * \param name Name of the metaclass
+ */
+ Class(const std::string& name);
+
+ /**
+ * \brief Get the offset of a base metaclass
+ *
+ * \param base Base metaclass to check
+ *
+ * \return offset between this and base, or -1 if both classes are unrelated
+ */
+ int baseOffset(const Class& base) const;
+
+private:
+
+ /**
+ * \brief Structure holding informations about a base metaclass
+ */
+ struct BaseInfo
+ {
+ const Class* base;
+ int offset;
+ };
+
+ typedef std::shared_ptr<Property> PropertyPtr;
+ typedef std::shared_ptr<Function> FunctionPtr;
+ typedef std::shared_ptr<Constructor> ConstructorPtr;
+ typedef std::vector<ConstructorPtr> ConstructorList;
+ typedef std::vector<BaseInfo> BaseList;
+
+ struct Id;
+ struct Name;
+
+ typedef boost::multi_index_container<PropertyPtr,
+ bm::indexed_by<bm::random_access<bm::tag<Id> >,
+ bm::ordered_unique<bm::tag<Name>, bm::const_mem_fun<Property, const std::string&, &Property::name> >
+ >
+ > PropertyTable;
+
+ typedef boost::multi_index_container<FunctionPtr,
+ bm::indexed_by<bm::random_access<bm::tag<Id> >,
+ bm::ordered_unique<bm::tag<Name>, bm::const_mem_fun<Function, const std::string&, &Function::name> >
+ >
+ > FunctionTable;
+
+ typedef PropertyTable::index<Name>::type PropertyNameIndex;
+ typedef FunctionTable::index<Name>::type FunctionNameIndex;
+ typedef void (*Destructor)(const UserObject&);
+
+ std::string m_name; ///< Name of the metaclass
+ FunctionTable m_functions; ///< Table of metafunctions indexed by name
+ PropertyTable m_properties; ///< Table of metaproperties indexed by name
+ BaseList m_bases; ///< List of base metaclasses
+ ConstructorList m_constructors; ///< List of metaconstructors
+ Destructor m_destructor; ///< Destructor (function that is able to delete an abstract object)
+};
+
+} // namespace camp
+
+// Must be included here because of mutual dependance between Class and ClassBuilder
+#include <camp/classbuilder.hpp>
+
+#include <camp/class.inl>
+
+
+#endif // CAMP_CLASS_HPP
diff --git a/include/camp/detail/classmanager.hpp b/include/camp/detail/classmanager.hpp
index 5263f4b..5ac7b8b 100644
--- a/include/camp/detail/classmanager.hpp
+++ b/include/camp/detail/classmanager.hpp
@@ -1,189 +1,189 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-
-#ifndef CAMP_DETAIL_CLASSMANAGER_HPP
-#define CAMP_DETAIL_CLASSMANAGER_HPP
-
-
-#include <camp/config.hpp>
-#include <camp/detail/observernotifier.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <string>
-
-
-namespace bm = boost::multi_index;
-
-namespace camp
-{
-class Class;
-
-namespace detail
-{
-/**
- * \brief Manages creation, storage, retrieval and destruction of metaclasses
- *
- * camp::ClassManager is the place where all metaclasses are stored and accessed.
- * It consists of a singleton which is created on first use and destroyed at global exit.
- *
- * \sa Class
- */
-class CAMP_API ClassManager : public ObserverNotifier, boost::noncopyable
-{
-public:
-
- /**
- * \brief Get the unique instance of the class
- *
- * \return Reference to the unique instance of ClassManager
- */
- static ClassManager& instance();
-
- /**
- * \brief Create and register a new metaclass
- *
- * This is the entry point for every metaclass creation. This
- * function also notifies registered observers after successful creations.
- *
- * \param name Name of the metaclass to create (must be unique)
- * \param id Identifier of the C++ class bound to the metaclass
- *
- * \return Reference to the new metaclass
- *
- * \throw ClassAlreadyCreated \a name or \a id already exists
- */
- Class& addClass(const std::string& name, const std::string& id);
-
- /**
- * \brief Get the total number of metaclasses
- *
- * \return Number of metaclasses that have been registered
- */
- std::size_t count() const;
-
- /**
- * \brief Get a metaclass from its global index
- *
- * This function, together with ClassManager::count, provides a way to iterate through
- * all the metaclasses that have been declared.
- *
- * \param index Global index of the metaclass to get
- *
- * \return Reference to the index-th metaclass
- *
- * \throw OutOfRange index is out of range
- */
- const Class& getByIndex(std::size_t index) const;
-
- /**
- * \brief Get a metaclass from its name
- *
- * \param name Name of the metaclass to retrieve
- *
- * \return Reference to the requested metaclass
- *
- * \throw ClassNotFound name is not the name of an existing metaclass
- */
- const Class& getByName(const std::string& name) const;
-
- /**
- * \brief Get a metaclass from a C++ type
- *
- * \param id Identifier of the C++ type
- *
- * \return Reference to the requested metaclass
- *
- * \throw ClassNotFound id is not the name of an existing metaclass
- */
- const Class& getById(const std::string& id) const;
-
- /**
- * \brief Get a metaclass from a C++ type
- *
- * This version returns a null pointer if no metaclass is found, instead
- * of throwing an exception.
- *
- * \param id Identifier of the C++ type
- *
- * \return Pointer to the requested metaclass, or 0 if not found
- */
- const Class* getByIdSafe(const std::string& id) const;
-
- /**
- * \brief Check if a given type has a metaclass
- *
- * \param id Identifier of the C++ type
- *
- * \return True if the class exists, false otherwise
- */
- bool classExists(const std::string& id) const;
-
-private:
-
- /**
- * \brief Default constructor
- */
- ClassManager();
-
- /**
- * \brief Destructor
- *
- * The destructor destroys all the registered metaclasses and notifies the observers.
- */
- ~ClassManager();
-
- /**
- * \brief Structure gathering a class, its type identifier and its name
- */
- struct ClassInfo
- {
- std::string id;
- std::string name;
- std::shared_ptr<Class> classPtr;
- };
-
- struct Id;
- struct Name;
-
- typedef boost::multi_index_container<ClassInfo,
- bm::indexed_by<bm::ordered_unique<bm::tag<Id>, bm::member<ClassInfo, std::string, &ClassInfo::id> >,
- bm::ordered_unique<bm::tag<Name>, bm::member<ClassInfo, std::string, &ClassInfo::name> >
- >
- > ClassTable;
-
- typedef ClassTable::index<Id>::type IdIndex;
- typedef ClassTable::index<Name>::type NameIndex;
-
- ClassTable m_classes; ///< Table storing classes indexed by their id and name
-};
-
-} // namespace detail
-
-} // namespace camp
-
-
-#endif // CAMP_DETAIL_CLASSMANAGER_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+
+#ifndef CAMP_DETAIL_CLASSMANAGER_HPP
+#define CAMP_DETAIL_CLASSMANAGER_HPP
+
+
+#include <camp/config.hpp>
+#include <camp/detail/observernotifier.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <string>
+
+
+namespace bm = boost::multi_index;
+
+namespace camp
+{
+class Class;
+
+namespace detail
+{
+/**
+ * \brief Manages creation, storage, retrieval and destruction of metaclasses
+ *
+ * camp::ClassManager is the place where all metaclasses are stored and accessed.
+ * It consists of a singleton which is created on first use and destroyed at global exit.
+ *
+ * \sa Class
+ */
+class CAMP_API ClassManager : public ObserverNotifier, boost::noncopyable
+{
+public:
+
+ /**
+ * \brief Get the unique instance of the class
+ *
+ * \return Reference to the unique instance of ClassManager
+ */
+ static ClassManager& instance();
+
+ /**
+ * \brief Create and register a new metaclass
+ *
+ * This is the entry point for every metaclass creation. This
+ * function also notifies registered observers after successful creations.
+ *
+ * \param name Name of the metaclass to create (must be unique)
+ * \param id Identifier of the C++ class bound to the metaclass
+ *
+ * \return Reference to the new metaclass
+ *
+ * \throw ClassAlreadyCreated \a name or \a id already exists
+ */
+ Class& addClass(const std::string& name, const std::string& id);
+
+ /**
+ * \brief Get the total number of metaclasses
+ *
+ * \return Number of metaclasses that have been registered
+ */
+ std::size_t count() const;
+
+ /**
+ * \brief Get a metaclass from its global index
+ *
+ * This function, together with ClassManager::count, provides a way to iterate through
+ * all the metaclasses that have been declared.
+ *
+ * \param index Global index of the metaclass to get
+ *
+ * \return Reference to the index-th metaclass
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Class& getByIndex(std::size_t index) const;
+
+ /**
+ * \brief Get a metaclass from its name
+ *
+ * \param name Name of the metaclass to retrieve
+ *
+ * \return Reference to the requested metaclass
+ *
+ * \throw ClassNotFound name is not the name of an existing metaclass
+ */
+ const Class& getByName(const std::string& name) const;
+
+ /**
+ * \brief Get a metaclass from a C++ type
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return Reference to the requested metaclass
+ *
+ * \throw ClassNotFound id is not the name of an existing metaclass
+ */
+ const Class& getById(const std::string& id) const;
+
+ /**
+ * \brief Get a metaclass from a C++ type
+ *
+ * This version returns a null pointer if no metaclass is found, instead
+ * of throwing an exception.
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return Pointer to the requested metaclass, or 0 if not found
+ */
+ const Class* getByIdSafe(const std::string& id) const;
+
+ /**
+ * \brief Check if a given type has a metaclass
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return True if the class exists, false otherwise
+ */
+ bool classExists(const std::string& id) const;
+
+private:
+
+ /**
+ * \brief Default constructor
+ */
+ ClassManager();
+
+ /**
+ * \brief Destructor
+ *
+ * The destructor destroys all the registered metaclasses and notifies the observers.
+ */
+ ~ClassManager();
+
+ /**
+ * \brief Structure gathering a class, its type identifier and its name
+ */
+ struct ClassInfo
+ {
+ std::string id;
+ std::string name;
+ std::shared_ptr<Class> classPtr;
+ };
+
+ struct Id;
+ struct Name;
+
+ typedef boost::multi_index_container<ClassInfo,
+ bm::indexed_by<bm::ordered_unique<bm::tag<Id>, bm::member<ClassInfo, std::string, &ClassInfo::id> >,
+ bm::ordered_unique<bm::tag<Name>, bm::member<ClassInfo, std::string, &ClassInfo::name> >
+ >
+ > ClassTable;
+
+ typedef ClassTable::index<Id>::type IdIndex;
+ typedef ClassTable::index<Name>::type NameIndex;
+
+ ClassTable m_classes; ///< Table storing classes indexed by their id and name
+};
+
+} // namespace detail
+
+} // namespace camp
+
+
+#endif // CAMP_DETAIL_CLASSMANAGER_HPP
diff --git a/include/camp/detail/enummanager.hpp b/include/camp/detail/enummanager.hpp
index af8310c..78d0732 100644
--- a/include/camp/detail/enummanager.hpp
+++ b/include/camp/detail/enummanager.hpp
@@ -1,186 +1,186 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-
-#ifndef CAMP_DETAIL_ENUMMANAGER_HPP
-#define CAMP_DETAIL_ENUMMANAGER_HPP
-
-
-#include <camp/config.hpp>
-#include <camp/detail/observernotifier.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <string>
-
-
-namespace bm = boost::multi_index;
-
-namespace camp
-{
-class Enum;
-
-namespace detail
-{
-/**
- * \brief Manages creation, storage, retrieval and destruction of metaenums
- *
- * camp::EnumManager is the place where all metaenums are stored and accessed.
- * It consists of a singleton which is created on first use and destroyed at global exit.
- *
- * \sa Enum
- */
-class CAMP_API EnumManager : public ObserverNotifier, boost::noncopyable
-{
-public:
-
- /**
- * \brief Get the unique instance of the class
- *
- * \return Reference to the unique instance of EnumManager
- */
- static EnumManager& instance();
-
- /**
- * \brief Create and register a new metaenum
- *
- * This is the entry point for every metaenum creation. This
- * function also notifies registered observers after successful creations.
- *
- * \param name Name of the metaenum to create (must be unique)
- * \param id Identifier of the C++ enum bound to the metaenum
- *
- * \return Reference to the new metaenum
- */
- Enum& addClass(const std::string& name, const std::string& id);
-
- /**
- * \brief Get the total number of metaenums
- *
- * \return Number of metaenums that have been registered
- */
- std::size_t count() const;
-
- /**
- * \brief Get a metaenum from its global index
- *
- * This function, together with EnumManager::count, provides a way to iterate through
- * all the metaenums that have been declared.
- *
- * \param index Global index of the metaenum to get
- *
- * \return Reference to the index-th metaenum
- *
- * \throw OutOfRange index is out of range
- */
- const Enum& getByIndex(std::size_t index) const;
-
- /**
- * \brief Get a metaenum from its name
- *
- * \param name Name of the metaenum to retrieve
- *
- * \return Reference to the requested metaenum
- *
- * \throw EnumNotFound name is not the name of an existing metaenum
- */
- const Enum& getByName(const std::string& name) const;
-
- /**
- * \brief Get a metaenum from a C++ type
- *
- * \param id Identifier of the C++ type
- *
- * \return Reference to the requested metaenum
- *
- * \throw EnumNotFound id is not the name of an existing metaenum
- */
- const Enum& getById(const std::string& id) const;
-
- /**
- * \brief Get a metaenum from a C++ type
- *
- * This version returns a null pointer if no metaenum is found, instead
- * of throwing an exception.
- *
- * \param id Identifier of the C++ type
- *
- * \return Pointer to the requested metaenum, or 0 if not found
- */
- const Enum* getByIdSafe(const std::string& id) const;
-
- /**
- * \brief Check if a given type has a metaenum
- *
- * \param id Identifier of the C++ type
- *
- * \return True if the enum exists, false otherwise
- */
- bool enumExists(const std::string& id) const;
-
-private:
-
- /**
- * \brief Default constructor
- */
- EnumManager();
-
- /**
- * \brief Destructor
- *
- * The destructor destroys all the registered metaenums and notifies the observers.
- */
- ~EnumManager();
-
- /**
- * \brief Structure gathering an enum, its type identifier and its name
- */
- struct EnumInfo
- {
- std::string id;
- std::string name;
- std::shared_ptr<Enum> enumPtr;
- };
-
- struct Id;
- struct Name;
-
- typedef boost::multi_index_container<EnumInfo,
- bm::indexed_by<bm::ordered_unique<bm::tag<Id>, bm::member<EnumInfo, std::string, &EnumInfo::id> >,
- bm::ordered_unique<bm::tag<Name>, bm::member<EnumInfo, std::string, &EnumInfo::name> >
- >
- > EnumTable;
-
- typedef EnumTable::index<Id>::type IdIndex;
- typedef EnumTable::index<Name>::type NameIndex;
-
- EnumTable m_enums; ///< Table storing enums indexed by their id and name
-};
-
-} // namespace detail
-
-} // namespace camp
-
-
-#endif // CAMP_DETAIL_ENUMMANAGER_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+
+#ifndef CAMP_DETAIL_ENUMMANAGER_HPP
+#define CAMP_DETAIL_ENUMMANAGER_HPP
+
+
+#include <camp/config.hpp>
+#include <camp/detail/observernotifier.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <string>
+
+
+namespace bm = boost::multi_index;
+
+namespace camp
+{
+class Enum;
+
+namespace detail
+{
+/**
+ * \brief Manages creation, storage, retrieval and destruction of metaenums
+ *
+ * camp::EnumManager is the place where all metaenums are stored and accessed.
+ * It consists of a singleton which is created on first use and destroyed at global exit.
+ *
+ * \sa Enum
+ */
+class CAMP_API EnumManager : public ObserverNotifier, boost::noncopyable
+{
+public:
+
+ /**
+ * \brief Get the unique instance of the class
+ *
+ * \return Reference to the unique instance of EnumManager
+ */
+ static EnumManager& instance();
+
+ /**
+ * \brief Create and register a new metaenum
+ *
+ * This is the entry point for every metaenum creation. This
+ * function also notifies registered observers after successful creations.
+ *
+ * \param name Name of the metaenum to create (must be unique)
+ * \param id Identifier of the C++ enum bound to the metaenum
+ *
+ * \return Reference to the new metaenum
+ */
+ Enum& addClass(const std::string& name, const std::string& id);
+
+ /**
+ * \brief Get the total number of metaenums
+ *
+ * \return Number of metaenums that have been registered
+ */
+ std::size_t count() const;
+
+ /**
+ * \brief Get a metaenum from its global index
+ *
+ * This function, together with EnumManager::count, provides a way to iterate through
+ * all the metaenums that have been declared.
+ *
+ * \param index Global index of the metaenum to get
+ *
+ * \return Reference to the index-th metaenum
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Enum& getByIndex(std::size_t index) const;
+
+ /**
+ * \brief Get a metaenum from its name
+ *
+ * \param name Name of the metaenum to retrieve
+ *
+ * \return Reference to the requested metaenum
+ *
+ * \throw EnumNotFound name is not the name of an existing metaenum
+ */
+ const Enum& getByName(const std::string& name) const;
+
+ /**
+ * \brief Get a metaenum from a C++ type
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return Reference to the requested metaenum
+ *
+ * \throw EnumNotFound id is not the name of an existing metaenum
+ */
+ const Enum& getById(const std::string& id) const;
+
+ /**
+ * \brief Get a metaenum from a C++ type
+ *
+ * This version returns a null pointer if no metaenum is found, instead
+ * of throwing an exception.
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return Pointer to the requested metaenum, or 0 if not found
+ */
+ const Enum* getByIdSafe(const std::string& id) const;
+
+ /**
+ * \brief Check if a given type has a metaenum
+ *
+ * \param id Identifier of the C++ type
+ *
+ * \return True if the enum exists, false otherwise
+ */
+ bool enumExists(const std::string& id) const;
+
+private:
+
+ /**
+ * \brief Default constructor
+ */
+ EnumManager();
+
+ /**
+ * \brief Destructor
+ *
+ * The destructor destroys all the registered metaenums and notifies the observers.
+ */
+ ~EnumManager();
+
+ /**
+ * \brief Structure gathering an enum, its type identifier and its name
+ */
+ struct EnumInfo
+ {
+ std::string id;
+ std::string name;
+ std::shared_ptr<Enum> enumPtr;
+ };
+
+ struct Id;
+ struct Name;
+
+ typedef boost::multi_index_container<EnumInfo,
+ bm::indexed_by<bm::ordered_unique<bm::tag<Id>, bm::member<EnumInfo, std::string, &EnumInfo::id> >,
+ bm::ordered_unique<bm::tag<Name>, bm::member<EnumInfo, std::string, &EnumInfo::name> >
+ >
+ > EnumTable;
+
+ typedef EnumTable::index<Id>::type IdIndex;
+ typedef EnumTable::index<Name>::type NameIndex;
+
+ EnumTable m_enums; ///< Table storing enums indexed by their id and name
+};
+
+} // namespace detail
+
+} // namespace camp
+
+
+#endif // CAMP_DETAIL_ENUMMANAGER_HPP
diff --git a/include/camp/enum.hpp b/include/camp/enum.hpp
index f5d1c22..c820ac9 100644
--- a/include/camp/enum.hpp
+++ b/include/camp/enum.hpp
@@ -1,230 +1,230 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-
-#ifndef CAMP_ENUM_HPP
-#define CAMP_ENUM_HPP
-
-
-#include <camp/config.hpp>
-#include <camp/enumbuilder.hpp>
-#include <camp/enumget.hpp>
-#include <camp/detail/enummanager.hpp>
-#include <camp/detail/typeid.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <string>
-
-
-namespace bm = boost::multi_index;
-
-namespace camp
-{
-/**
- * \brief camp::Enum represents a metaenum composed of <name, value> pairs
- *
- * Enums are declared, bound to a C++ type and filled with the \c declare
- * template function.
- *
- * \code
- * enum MyEnum {one = 1, two = 2, ten = 10};
- *
- * camp::Enum::declare<MyEnum>("MyEnum")
- * .value("one", one)
- * .value("two", two)
- * .value("ten", ten);
- * \endcode
- *
- * It then provides a set of accessors to retrieve names, values and pairs contained in it.
- *
- * \code
- * const camp::Enum& metaenum = camp::enumByType<MyEnum>();
- *
- * bool b1 = metaenum.hasName("one"); // b1 == true
- * bool b2 = metaenum.hasValue(5); // b2 == false
- *
- * std::string s = metaenum.name(10); // s == "ten"
- * long l = metaenum.value("two"); // l == 2
- *
- * camp::Enum::Pair p = metaenum.pair(0); // p == {"one", one}
- * \endcode
- *
- * \remark All values and names are unique within the metaenum.
- *
- * \sa Class, EnumBuilder
- */
-class CAMP_API Enum : boost::noncopyable
-{
-public:
-
- /**
- * \brief Structure defining the <name, value> pairs stored in metaenums
- */
- struct Pair
- {
- std::string name; ///< Name of the pair
- long value; ///< Value of the pair
- };
-
-public:
-
- /**
- * \brief Declare a new metaenum
- *
- * This is the function to call to create a new metaenum. The template
- * parameter T is the C++ enum type that will be bound to the metaclass.
- *
- * \param name Name of the metaenum in CAMP. This name identifies
- * the metaenum and thus has to be unique
- *
- * \return A EnumBuilder object that will provide functions
- * to fill the new metaenum with values.
- */
- template <typename T>
- static EnumBuilder declare(const std::string& name);
-
-public:
-
- /**
- * \brief Return the name of the metaenum
- *
- * \return String containing the name of the metaenum
- */
- const std::string& name() const;
-
- /**
- * \brief Return the size of the metaenum
- *
- * \return Total number of values contained in the metaenum
- */
- std::size_t size() const;
-
- /**
- * \brief Get a pair by its index
- *
- * \param index Index of the pair to get
- *
- * \return index-th pair
- *
- * \throw OutOfRange index is out of range
- */
- const Pair& pair(std::size_t index) const;
-
- /**
- * \brief Check if the enum contains a name
- *
- * \param name Name to check
- *
- * \return True if the metaenum contains a pair whose name is \a name
- */
- bool hasName(const std::string& name) const;
-
- /**
- * \brief Check if the enum contains a value
- *
- * \param value Value to check
- *
- * \return True if the metaenum contains a pair whose value is \a value
- */
- bool hasValue(long value) const;
-
- /**
- * \brief Return the name corresponding to given a value
- *
- * \param value Value to get
- *
- * \return Name of the requested value
- *
- * \throw InvalidEnumValue value doesn't exist in the metaenum
- */
- const std::string& name(long value) const;
-
- /**
- * \brief Return the value corresponding to given a name
- *
- * \param name Name to get
- *
- * \return Value of the requested name
- *
- * \throw InvalidEnumName name doesn't exist in the metaenum
- */
- long value(const std::string& name) const;
-
- /**
- * \brief Operator == to check equality between two metaenums
- *
- * Two metaenums are equal if their name is the same.
- *
- * \param other Metaenum to compare with this
- *
- * \return True if both metaenums are the same, false otherwise
- */
- bool operator==(const Enum& other) const;
-
- /**
- * \brief Operator != to check inequality between two metaenums
- *
- * \param other Metaenum to compare with this
- *
- * \return True if metaenums are different, false if they are equal
- */
- bool operator!=(const Enum& other) const;
-
-private:
-
- friend class EnumBuilder;
- friend class detail::EnumManager;
-
- /**
- * \brief Construct the metaenum from its name
- *
- * \param name Name of the metaenum
- */
- Enum(const std::string& name);
-
- struct Id;
- struct Val;
- struct Name;
-
- typedef boost::multi_index_container<Pair,
- bm::indexed_by<bm::random_access<bm::tag<Id> >,
- bm::ordered_unique<bm::tag<Val>, bm::member<Pair, long, &Pair::value> >,
- bm::ordered_unique<bm::tag<Name>, bm::member<Pair, std::string, &Pair::name> >
- >
- > PairTable;
-
- typedef PairTable::index<Val>::type ValueIndex;
- typedef PairTable::index<Name>::type NameIndex;
-
- std::string m_name; ///< Name of the metaenum
- PairTable m_pairs; ///< Table of pairs, indexed by their value and name
-};
-
-} // namespace camp
-
-#include <camp/enum.inl>
-
-
-#endif // CAMP_ENUM_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+
+#ifndef CAMP_ENUM_HPP
+#define CAMP_ENUM_HPP
+
+
+#include <camp/config.hpp>
+#include <camp/enumbuilder.hpp>
+#include <camp/enumget.hpp>
+#include <camp/detail/enummanager.hpp>
+#include <camp/detail/typeid.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+#include <string>
+
+
+namespace bm = boost::multi_index;
+
+namespace camp
+{
+/**
+ * \brief camp::Enum represents a metaenum composed of <name, value> pairs
+ *
+ * Enums are declared, bound to a C++ type and filled with the \c declare
+ * template function.
+ *
+ * \code
+ * enum MyEnum {one = 1, two = 2, ten = 10};
+ *
+ * camp::Enum::declare<MyEnum>("MyEnum")
+ * .value("one", one)
+ * .value("two", two)
+ * .value("ten", ten);
+ * \endcode
+ *
+ * It then provides a set of accessors to retrieve names, values and pairs contained in it.
+ *
+ * \code
+ * const camp::Enum& metaenum = camp::enumByType<MyEnum>();
+ *
+ * bool b1 = metaenum.hasName("one"); // b1 == true
+ * bool b2 = metaenum.hasValue(5); // b2 == false
+ *
+ * std::string s = metaenum.name(10); // s == "ten"
+ * long l = metaenum.value("two"); // l == 2
+ *
+ * camp::Enum::Pair p = metaenum.pair(0); // p == {"one", one}
+ * \endcode
+ *
+ * \remark All values and names are unique within the metaenum.
+ *
+ * \sa Class, EnumBuilder
+ */
+class CAMP_API Enum : boost::noncopyable
+{
+public:
+
+ /**
+ * \brief Structure defining the <name, value> pairs stored in metaenums
+ */
+ struct Pair
+ {
+ std::string name; ///< Name of the pair
+ long value; ///< Value of the pair
+ };
+
+public:
+
+ /**
+ * \brief Declare a new metaenum
+ *
+ * This is the function to call to create a new metaenum. The template
+ * parameter T is the C++ enum type that will be bound to the metaclass.
+ *
+ * \param name Name of the metaenum in CAMP. This name identifies
+ * the metaenum and thus has to be unique
+ *
+ * \return A EnumBuilder object that will provide functions
+ * to fill the new metaenum with values.
+ */
+ template <typename T>
+ static EnumBuilder declare(const std::string& name);
+
+public:
+
+ /**
+ * \brief Return the name of the metaenum
+ *
+ * \return String containing the name of the metaenum
+ */
+ const std::string& name() const;
+
+ /**
+ * \brief Return the size of the metaenum
+ *
+ * \return Total number of values contained in the metaenum
+ */
+ std::size_t size() const;
+
+ /**
+ * \brief Get a pair by its index
+ *
+ * \param index Index of the pair to get
+ *
+ * \return index-th pair
+ *
+ * \throw OutOfRange index is out of range
+ */
+ const Pair& pair(std::size_t index) const;
+
+ /**
+ * \brief Check if the enum contains a name
+ *
+ * \param name Name to check
+ *
+ * \return True if the metaenum contains a pair whose name is \a name
+ */
+ bool hasName(const std::string& name) const;
+
+ /**
+ * \brief Check if the enum contains a value
+ *
+ * \param value Value to check
+ *
+ * \return True if the metaenum contains a pair whose value is \a value
+ */
+ bool hasValue(long value) const;
+
+ /**
+ * \brief Return the name corresponding to given a value
+ *
+ * \param value Value to get
+ *
+ * \return Name of the requested value
+ *
+ * \throw InvalidEnumValue value doesn't exist in the metaenum
+ */
+ const std::string& name(long value) const;
+
+ /**
+ * \brief Return the value corresponding to given a name
+ *
+ * \param name Name to get
+ *
+ * \return Value of the requested name
+ *
+ * \throw InvalidEnumName name doesn't exist in the metaenum
+ */
+ long value(const std::string& name) const;
+
+ /**
+ * \brief Operator == to check equality between two metaenums
+ *
+ * Two metaenums are equal if their name is the same.
+ *
+ * \param other Metaenum to compare with this
+ *
+ * \return True if both metaenums are the same, false otherwise
+ */
+ bool operator==(const Enum& other) const;
+
+ /**
+ * \brief Operator != to check inequality between two metaenums
+ *
+ * \param other Metaenum to compare with this
+ *
+ * \return True if metaenums are different, false if they are equal
+ */
+ bool operator!=(const Enum& other) const;
+
+private:
+
+ friend class EnumBuilder;
+ friend class detail::EnumManager;
+
+ /**
+ * \brief Construct the metaenum from its name
+ *
+ * \param name Name of the metaenum
+ */
+ Enum(const std::string& name);
+
+ struct Id;
+ struct Val;
+ struct Name;
+
+ typedef boost::multi_index_container<Pair,
+ bm::indexed_by<bm::random_access<bm::tag<Id> >,
+ bm::ordered_unique<bm::tag<Val>, bm::member<Pair, long, &Pair::value> >,
+ bm::ordered_unique<bm::tag<Name>, bm::member<Pair, std::string, &Pair::name> >
+ >
+ > PairTable;
+
+ typedef PairTable::index<Val>::type ValueIndex;
+ typedef PairTable::index<Name>::type NameIndex;
+
+ std::string m_name; ///< Name of the metaenum
+ PairTable m_pairs; ///< Table of pairs, indexed by their value and name
+};
+
+} // namespace camp
+
+#include <camp/enum.inl>
+
+
+#endif // CAMP_ENUM_HPP
diff --git a/test/function.hpp b/test/function.hpp
index 037b66d..160d4d1 100644
--- a/test/function.hpp
+++ b/test/function.hpp
@@ -1,177 +1,177 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef CAMPTEST_FUNCTION_HPP
-#define CAMPTEST_FUNCTION_HPP
-
-#include <camp/camptype.hpp>
-#include <camp/enum.hpp>
-#include <camp/class.hpp>
-#include <camp/value.hpp>
-#include <boost/shared_ptr.hpp>
-#include <string>
-
-namespace FunctionTest
-{
- enum MyEnum
- {
- Zero = 0,
- One = 1,
- Two = 2
- };
-
- struct MyType
- {
- MyType(int x_) : x(x_) {}
- int x;
- };
-
- bool operator==(const MyType& left, const MyType& right) {return left.x == right.x;}
- bool operator<(const MyType& left, const MyType& right) {return left.x < right.x;}
- std::ostream& operator<<(std::ostream& stream, const MyType& object) {return stream << object.x;}
-
- struct MyBase
- {
- void f6() {}
- char padding[10];
- };
-
- struct MyClass : MyBase
- {
- MyClass()
- : p1(true)
- , p2(2)
- , p3("3")
- , p4(MyType(4))
- , p5(MyType(5))
- , innerPtr(&inner)
- , innerSmartPtr(new Inner)
- {
- }
-
- bool p1;
- int p2;
- std::string p3;
-
- MyType p4; const MyType& f4() {return p4;}
- MyType p5; const MyType& f5() const {return p5;}
- // f6 is inherited
- camp::Value f7(camp::Value v) {return v;}
-
- void f8() {}
- void f9(bool) {}
- void f10(float, double) {}
- void f11(short, int, long) {}
- void f12(const std::string&, std::string, const std::string&, std::string) {}
- void f13(MyEnum, MyEnum, MyEnum, MyEnum, MyEnum) {}
-
- struct Inner
- {
- void f14() {}
- void f15() const {}
- int f16() {return 16;}
- void f17(int) {}
- void f18() {}
- void f19() {}
- };
- Inner inner;
- const Inner& getInner() const {return inner;}
- Inner* innerPtr;
- const Inner* getInnerPtr() const {return innerPtr;}
- boost::shared_ptr<Inner> innerSmartPtr;
- const boost::shared_ptr<Inner> getInnerSmartPtr() {return innerSmartPtr;}
-
- int f20(int x) {return x;}
- int f21(int x, int y) {return x + y;}
- int f22(int x, int y, int z) {return x + y + z;}
- };
-
- void f1(MyClass& object)
- {
- object.p1 = true;
- }
-
- int f2(MyClass object, int x)
- {
- return object.p2 + x;
- }
-
- const std::string& f3(const MyClass* object)
- {
- return object->p3;
- }
-
- void declare()
- {
- camp::Enum::declare<MyEnum>("FunctionTest::MyEnum")
- .value("Zero", Zero)
- .value("One", One)
- .value("Two", Two);
-
- camp::Class::declare<MyType>("FunctionTest::MyType");
-
- camp::Class::declare<MyBase>("FunctionTest::MyBase");
-
- camp::Class::declare<MyClass>("FunctionTest::MyClass")
- .base<MyBase>()
-
- // ***** non-member functions *****
- .function("f1", &f1) // object by reference
- .function("f2", &f2) // object by value + parameter
- .function("f3", &f3) // object by pointer
-
- // ***** member functions *****
- .function("f4", &MyClass::f4) // non-const
- .function("f5", &MyClass::f5) // const
- .function("f6", &MyClass::f6) // inherited
- .function("f7", &MyClass::f7) // camp::Value as return and argument types
-
- // ***** arguments count ******
- .function("f8", &MyClass::f8) // 0 argument
- .function("f9", &MyClass::f9) // 1 argument
- .function("f10", &MyClass::f10) // 2 arguments
- .function("f11", &MyClass::f11) // 3 arguments
- .function("f12", &MyClass::f12) // 4 arguments
- .function("f13", &MyClass::f13) // 5 arguments
-
- // ***** nested functions *****
- // TOFIX .function("f14", &MyClass::Inner::f14, &MyClass::inner) // object
- .function("f15", &MyClass::Inner::f15, &MyClass::getInner) // getter returning an object
- .function("f16", &MyClass::Inner::f16, &MyClass::innerPtr) // raw pointer
- // TOFIX .function("f17", &MyClass::Inner::f17, &MyClass::getInnerPtr) // getter returning a raw pointer
- .function("f18", &MyClass::Inner::f18, &MyClass::innerSmartPtr) // smart pointer
- .function("f19", &MyClass::Inner::f19, &MyClass::getInnerSmartPtr) // getter returning a smart pointer
-
- // ***** boost::function *****
- .function("f20", boost::function<int (MyClass&, int)>(boost::bind(&MyClass::f20, _1, _2)))
- .function("f21", boost::function<int (MyClass&, int)>(boost::bind(&MyClass::f21, _1, _2, 20)))
- .function("f22", boost::function<int (MyClass&, int)>(boost::bind(boost::bind(&MyClass::f22, _1, _2, _3, 30), _1, _2, 20)))
- ;
- }
-}
-
-CAMP_AUTO_TYPE(FunctionTest::MyEnum, &FunctionTest::declare)
-CAMP_AUTO_TYPE(FunctionTest::MyType, &FunctionTest::declare)
-CAMP_AUTO_TYPE(FunctionTest::MyClass, &FunctionTest::declare)
-CAMP_AUTO_TYPE(FunctionTest::MyBase, &FunctionTest::declare)
-
-#endif // CAMPTEST_FUNCTION_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CAMPTEST_FUNCTION_HPP
+#define CAMPTEST_FUNCTION_HPP
+
+#include <camp/camptype.hpp>
+#include <camp/enum.hpp>
+#include <camp/class.hpp>
+#include <camp/value.hpp>
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+namespace FunctionTest
+{
+ enum MyEnum
+ {
+ Zero = 0,
+ One = 1,
+ Two = 2
+ };
+
+ struct MyType
+ {
+ MyType(int x_) : x(x_) {}
+ int x;
+ };
+
+ bool operator==(const MyType& left, const MyType& right) {return left.x == right.x;}
+ bool operator<(const MyType& left, const MyType& right) {return left.x < right.x;}
+ std::ostream& operator<<(std::ostream& stream, const MyType& object) {return stream << object.x;}
+
+ struct MyBase
+ {
+ void f6() {}
+ char padding[10];
+ };
+
+ struct MyClass : MyBase
+ {
+ MyClass()
+ : p1(true)
+ , p2(2)
+ , p3("3")
+ , p4(MyType(4))
+ , p5(MyType(5))
+ , innerPtr(&inner)
+ , innerSmartPtr(new Inner)
+ {
+ }
+
+ bool p1;
+ int p2;
+ std::string p3;
+
+ MyType p4; const MyType& f4() {return p4;}
+ MyType p5; const MyType& f5() const {return p5;}
+ // f6 is inherited
+ camp::Value f7(camp::Value v) {return v;}
+
+ void f8() {}
+ void f9(bool) {}
+ void f10(float, double) {}
+ void f11(short, int, long) {}
+ void f12(const std::string&, std::string, const std::string&, std::string) {}
+ void f13(MyEnum, MyEnum, MyEnum, MyEnum, MyEnum) {}
+
+ struct Inner
+ {
+ void f14() {}
+ void f15() const {}
+ int f16() {return 16;}
+ void f17(int) {}
+ void f18() {}
+ void f19() {}
+ };
+ Inner inner;
+ const Inner& getInner() const {return inner;}
+ Inner* innerPtr;
+ const Inner* getInnerPtr() const {return innerPtr;}
+ boost::shared_ptr<Inner> innerSmartPtr;
+ const boost::shared_ptr<Inner> getInnerSmartPtr() {return innerSmartPtr;}
+
+ int f20(int x) {return x;}
+ int f21(int x, int y) {return x + y;}
+ int f22(int x, int y, int z) {return x + y + z;}
+ };
+
+ void f1(MyClass& object)
+ {
+ object.p1 = true;
+ }
+
+ int f2(MyClass object, int x)
+ {
+ return object.p2 + x;
+ }
+
+ const std::string& f3(const MyClass* object)
+ {
+ return object->p3;
+ }
+
+ void declare()
+ {
+ camp::Enum::declare<MyEnum>("FunctionTest::MyEnum")
+ .value("Zero", Zero)
+ .value("One", One)
+ .value("Two", Two);
+
+ camp::Class::declare<MyType>("FunctionTest::MyType");
+
+ camp::Class::declare<MyBase>("FunctionTest::MyBase");
+
+ camp::Class::declare<MyClass>("FunctionTest::MyClass")
+ .base<MyBase>()
+
+ // ***** non-member functions *****
+ .function("f1", &f1) // object by reference
+ .function("f2", &f2) // object by value + parameter
+ .function("f3", &f3) // object by pointer
+
+ // ***** member functions *****
+ .function("f4", &MyClass::f4) // non-const
+ .function("f5", &MyClass::f5) // const
+ .function("f6", &MyClass::f6) // inherited
+ .function("f7", &MyClass::f7) // camp::Value as return and argument types
+
+ // ***** arguments count ******
+ .function("f8", &MyClass::f8) // 0 argument
+ .function("f9", &MyClass::f9) // 1 argument
+ .function("f10", &MyClass::f10) // 2 arguments
+ .function("f11", &MyClass::f11) // 3 arguments
+ .function("f12", &MyClass::f12) // 4 arguments
+ .function("f13", &MyClass::f13) // 5 arguments
+
+ // ***** nested functions *****
+ // TOFIX .function("f14", &MyClass::Inner::f14, &MyClass::inner) // object
+ .function("f15", &MyClass::Inner::f15, &MyClass::getInner) // getter returning an object
+ .function("f16", &MyClass::Inner::f16, &MyClass::innerPtr) // raw pointer
+ // TOFIX .function("f17", &MyClass::Inner::f17, &MyClass::getInnerPtr) // getter returning a raw pointer
+ .function("f18", &MyClass::Inner::f18, &MyClass::innerSmartPtr) // smart pointer
+ .function("f19", &MyClass::Inner::f19, &MyClass::getInnerSmartPtr) // getter returning a smart pointer
+
+ // ***** boost::function *****
+ .function("f20", boost::function<int (MyClass&, int)>(boost::bind(&MyClass::f20, _1, _2)))
+ .function("f21", boost::function<int (MyClass&, int)>(boost::bind(&MyClass::f21, _1, _2, 20)))
+ .function("f22", boost::function<int (MyClass&, int)>(boost::bind(boost::bind(&MyClass::f22, _1, _2, _3, 30), _1, _2, 20)))
+ ;
+ }
+}
+
+CAMP_AUTO_TYPE(FunctionTest::MyEnum, &FunctionTest::declare)
+CAMP_AUTO_TYPE(FunctionTest::MyType, &FunctionTest::declare)
+CAMP_AUTO_TYPE(FunctionTest::MyClass, &FunctionTest::declare)
+CAMP_AUTO_TYPE(FunctionTest::MyBase, &FunctionTest::declare)
+
+#endif // CAMPTEST_FUNCTION_HPP
diff --git a/test/functionaccess.hpp b/test/functionaccess.hpp
index 3b573e7..4dc1022 100644
--- a/test/functionaccess.hpp
+++ b/test/functionaccess.hpp
@@ -1,65 +1,65 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef CAMPTEST_FUNCTIONACCESS_HPP
-#define CAMPTEST_FUNCTIONACCESS_HPP
-
-#include <camp/camptype.hpp>
-#include <camp/class.hpp>
-
-namespace FunctionAccessTest
-{
- struct MyClass
- {
- MyClass(bool b = true)
- : m_b(b)
- {
- }
-
- void f() {}
-
- bool m_b;
- bool b1() {return true;}
- bool b2() const {return false;}
- };
-
- void declare()
- {
- camp::Class::declare<MyClass>("FunctionAccessTest::MyClass")
-
- // ***** constant value *****
- .function("f0", &MyClass::f).callable(false)
- .function("f1", &MyClass::f).callable(true)
-
- // ***** function *****
- .function("f2", &MyClass::f).callable(&MyClass::b1)
- .function("f3", &MyClass::f).callable(&MyClass::b2)
- .function("f4", &MyClass::f).callable(boost::bind(&MyClass::b1, _1))
- .function("f5", &MyClass::f).callable(&MyClass::m_b)
- .function("f6", &MyClass::f).callable(boost::function<bool (MyClass&)>(&MyClass::m_b))
- ;
- }
-}
-
-CAMP_AUTO_TYPE(FunctionAccessTest::MyClass, &FunctionAccessTest::declare);
-
-#endif // CAMPTEST_FUNCTIONACCESS_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CAMPTEST_FUNCTIONACCESS_HPP
+#define CAMPTEST_FUNCTIONACCESS_HPP
+
+#include <camp/camptype.hpp>
+#include <camp/class.hpp>
+
+namespace FunctionAccessTest
+{
+ struct MyClass
+ {
+ MyClass(bool b = true)
+ : m_b(b)
+ {
+ }
+
+ void f() {}
+
+ bool m_b;
+ bool b1() {return true;}
+ bool b2() const {return false;}
+ };
+
+ void declare()
+ {
+ camp::Class::declare<MyClass>("FunctionAccessTest::MyClass")
+
+ // ***** constant value *****
+ .function("f0", &MyClass::f).callable(false)
+ .function("f1", &MyClass::f).callable(true)
+
+ // ***** function *****
+ .function("f2", &MyClass::f).callable(&MyClass::b1)
+ .function("f3", &MyClass::f).callable(&MyClass::b2)
+ .function("f4", &MyClass::f).callable(boost::bind(&MyClass::b1, _1))
+ .function("f5", &MyClass::f).callable(&MyClass::m_b)
+ .function("f6", &MyClass::f).callable(boost::function<bool (MyClass&)>(&MyClass::m_b))
+ ;
+ }
+}
+
+CAMP_AUTO_TYPE(FunctionAccessTest::MyClass, &FunctionAccessTest::declare);
+
+#endif // CAMPTEST_FUNCTIONACCESS_HPP
diff --git a/test/inheritance.hpp b/test/inheritance.hpp
index b8b6048..fb1e4f6 100644
--- a/test/inheritance.hpp
+++ b/test/inheritance.hpp
@@ -1,115 +1,115 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef CAMPTEST_INHERITANCE_HPP
-#define CAMPTEST_INHERITANCE_HPP
-
-#include <camp/camptype.hpp>
-#include <camp/class.hpp>
-
-namespace InheritanceTest
-{
- struct MyClass1
- {
- MyClass1() : p1(10), po1(10) {}
- virtual ~MyClass1() {}
- int p1;
- int f1() const {return 1;}
- int po1;
- int fo1() {return 1;}
- CAMP_RTTI();
- };
-
- struct MyClass2
- {
- MyClass2() : p2(20), po2(20) {}
- virtual ~MyClass2() {}
- int p2;
- int f2() const {return 2;}
- virtual int fv() const {return p2;}
- int po2;
- int fo2() {return 2;}
- CAMP_RTTI();
- };
-
- struct MyClass3 : public MyClass1, public MyClass2
- {
- MyClass3() : p3(30), po3(30) {}
- virtual ~MyClass3() {}
- int p3;
- int f3() const {return 3;}
- virtual int fv() const {return p3;}
- int po3;
- int fo3() {return 3;}
- CAMP_RTTI();
- };
-
- struct MyClass4 : public MyClass3
- {
- MyClass4() : p4(40), po4(40) {}
- virtual ~MyClass4() {}
- int p4;
- int f4() const {return 4;}
- virtual int fv() const {return p4;}
- int po4;
- int fo4() {return 4;}
- CAMP_RTTI();
- };
-
- void declare()
- {
- camp::Class::declare<MyClass1>("InheritanceTest::MyClass1")
- .function("f1", &MyClass1::f1)
- .property("p1", &MyClass1::p1)
- .function("overridden", &MyClass1::fo1)
- .property("overridden", &MyClass1::po1);
-
- camp::Class::declare<MyClass2>("InheritanceTest::MyClass2")
- .function("f2", &MyClass2::f2)
- .property("p2", &MyClass2::p2)
- .function("virtual", &MyClass2::fv)
- .function("overridden", &MyClass2::fo2)
- .property("overridden", &MyClass2::po2);
-
- camp::Class::declare<MyClass3>("InheritanceTest::MyClass3")
- .base<MyClass1>()
- .base<MyClass2>()
- .function("f3", &MyClass3::f3)
- .property("p3", &MyClass3::p3)
- .function("overridden", &MyClass3::fo3)
- .property("overridden", &MyClass3::po3);
-
- camp::Class::declare<MyClass4>("InheritanceTest::MyClass4")
- .base<MyClass3>()
- .function("f4", &MyClass4::f4)
- .property("p4", &MyClass4::p4)
- .function("overridden", &MyClass4::fo4)
- .property("overridden", &MyClass4::po4);
- }
-}
-
-CAMP_AUTO_TYPE(InheritanceTest::MyClass1, &InheritanceTest::declare)
-CAMP_AUTO_TYPE(InheritanceTest::MyClass2, &InheritanceTest::declare)
-CAMP_AUTO_TYPE(InheritanceTest::MyClass3, &InheritanceTest::declare)
-CAMP_AUTO_TYPE(InheritanceTest::MyClass4, &InheritanceTest::declare)
-
-#endif // CAMPTEST_INHERITANCE_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CAMPTEST_INHERITANCE_HPP
+#define CAMPTEST_INHERITANCE_HPP
+
+#include <camp/camptype.hpp>
+#include <camp/class.hpp>
+
+namespace InheritanceTest
+{
+ struct MyClass1
+ {
+ MyClass1() : p1(10), po1(10) {}
+ virtual ~MyClass1() {}
+ int p1;
+ int f1() const {return 1;}
+ int po1;
+ int fo1() {return 1;}
+ CAMP_RTTI();
+ };
+
+ struct MyClass2
+ {
+ MyClass2() : p2(20), po2(20) {}
+ virtual ~MyClass2() {}
+ int p2;
+ int f2() const {return 2;}
+ virtual int fv() const {return p2;}
+ int po2;
+ int fo2() {return 2;}
+ CAMP_RTTI();
+ };
+
+ struct MyClass3 : public MyClass1, public MyClass2
+ {
+ MyClass3() : p3(30), po3(30) {}
+ virtual ~MyClass3() {}
+ int p3;
+ int f3() const {return 3;}
+ virtual int fv() const {return p3;}
+ int po3;
+ int fo3() {return 3;}
+ CAMP_RTTI();
+ };
+
+ struct MyClass4 : public MyClass3
+ {
+ MyClass4() : p4(40), po4(40) {}
+ virtual ~MyClass4() {}
+ int p4;
+ int f4() const {return 4;}
+ virtual int fv() const {return p4;}
+ int po4;
+ int fo4() {return 4;}
+ CAMP_RTTI();
+ };
+
+ void declare()
+ {
+ camp::Class::declare<MyClass1>("InheritanceTest::MyClass1")
+ .function("f1", &MyClass1::f1)
+ .property("p1", &MyClass1::p1)
+ .function("overridden", &MyClass1::fo1)
+ .property("overridden", &MyClass1::po1);
+
+ camp::Class::declare<MyClass2>("InheritanceTest::MyClass2")
+ .function("f2", &MyClass2::f2)
+ .property("p2", &MyClass2::p2)
+ .function("virtual", &MyClass2::fv)
+ .function("overridden", &MyClass2::fo2)
+ .property("overridden", &MyClass2::po2);
+
+ camp::Class::declare<MyClass3>("InheritanceTest::MyClass3")
+ .base<MyClass1>()
+ .base<MyClass2>()
+ .function("f3", &MyClass3::f3)
+ .property("p3", &MyClass3::p3)
+ .function("overridden", &MyClass3::fo3)
+ .property("overridden", &MyClass3::po3);
+
+ camp::Class::declare<MyClass4>("InheritanceTest::MyClass4")
+ .base<MyClass3>()
+ .function("f4", &MyClass4::f4)
+ .property("p4", &MyClass4::p4)
+ .function("overridden", &MyClass4::fo4)
+ .property("overridden", &MyClass4::po4);
+ }
+}
+
+CAMP_AUTO_TYPE(InheritanceTest::MyClass1, &InheritanceTest::declare)
+CAMP_AUTO_TYPE(InheritanceTest::MyClass2, &InheritanceTest::declare)
+CAMP_AUTO_TYPE(InheritanceTest::MyClass3, &InheritanceTest::declare)
+CAMP_AUTO_TYPE(InheritanceTest::MyClass4, &InheritanceTest::declare)
+
+#endif // CAMPTEST_INHERITANCE_HPP
diff --git a/test/mapper.hpp b/test/mapper.hpp
index 2b0347f..cb7fb7f 100644
--- a/test/mapper.hpp
+++ b/test/mapper.hpp
@@ -1,148 +1,148 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef CAMPTEST_MAPPER_HPP
-#define CAMPTEST_MAPPER_HPP
-
-#include <camp/camptype.hpp>
-#include <camp/class.hpp>
-#include <camp/simpleproperty.hpp>
-#include <camp/function.hpp>
-#include <map>
-#include <string>
-
-namespace MapperTest
-{
- struct MyClass
- {
- enum
- {
- propertyCount = 5,
- functionCount = 3
- };
-
- static std::string property(std::size_t index)
- {
- const char* names[] = {"prop0", "prop1", "prop2", "prop3", "prop4"};
- return names[index];
- }
-
- static std::string function(std::size_t index)
- {
- const char* names[] = {"func0", "func1", "func2"};
- return names[index];
- }
-
- MyClass()
- {
- m_props[property(0)] = 0;
- m_props[property(1)] = 10;
- m_props[property(2)] = 20;
- m_props[property(3)] = 30;
- m_props[property(4)] = 40;
- }
-
- int& prop(const std::string& name)
- {
- return m_props[name];
- }
-
- std::string func(const std::string& name)
- {
- return name + "_called";
- }
-
- std::map<std::string, int> m_props;
- };
-
- template <typename T>
- struct MyMapper
- {
- std::size_t propertyCount()
- {
- return T::propertyCount;
- }
-
- camp::Property* property(std::size_t index)
- {
- return new MyProperty(T::property(index));
- }
-
- std::size_t functionCount()
- {
- return T::functionCount;
- }
-
- camp::Function* function(std::size_t index)
- {
- return new MyFunction(T::function(index));
- }
-
- struct MyProperty : public camp::SimpleProperty
- {
- public:
-
- MyProperty(const std::string& name)
- : camp::SimpleProperty(name, camp::intType)
- {
- }
-
- virtual camp::Value getValue(const camp::UserObject& object) const
- {
- T& t = object.get<T>();
- return t.prop(name());
- }
-
- virtual void setValue(const camp::UserObject& object, const camp::Value& value) const
- {
- T& t = object.get<T>();
- t.prop(name()) = value.to<int>();
- }
- };
-
- class MyFunction : public camp::Function
- {
- public:
-
- MyFunction(const std::string& name)
- : camp::Function(name, camp::stringType)
- {
- }
-
- virtual camp::Value execute(const camp::UserObject& object, const camp::Args&) const
- {
- T& t = object.get<T>();
- return t.func(name());
- }
- };
- };
-
- void declare()
- {
- camp::Class::declare<MyClass>("MapperTest::MyClass")
- .external<MyMapper>();
- }
-}
-
-CAMP_AUTO_TYPE(MapperTest::MyClass, &MapperTest::declare)
-
-#endif // CAMPTEST_MAPPER_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CAMPTEST_MAPPER_HPP
+#define CAMPTEST_MAPPER_HPP
+
+#include <camp/camptype.hpp>
+#include <camp/class.hpp>
+#include <camp/simpleproperty.hpp>
+#include <camp/function.hpp>
+#include <map>
+#include <string>
+
+namespace MapperTest
+{
+ struct MyClass
+ {
+ enum
+ {
+ propertyCount = 5,
+ functionCount = 3
+ };
+
+ static std::string property(std::size_t index)
+ {
+ const char* names[] = {"prop0", "prop1", "prop2", "prop3", "prop4"};
+ return names[index];
+ }
+
+ static std::string function(std::size_t index)
+ {
+ const char* names[] = {"func0", "func1", "func2"};
+ return names[index];
+ }
+
+ MyClass()
+ {
+ m_props[property(0)] = 0;
+ m_props[property(1)] = 10;
+ m_props[property(2)] = 20;
+ m_props[property(3)] = 30;
+ m_props[property(4)] = 40;
+ }
+
+ int& prop(const std::string& name)
+ {
+ return m_props[name];
+ }
+
+ std::string func(const std::string& name)
+ {
+ return name + "_called";
+ }
+
+ std::map<std::string, int> m_props;
+ };
+
+ template <typename T>
+ struct MyMapper
+ {
+ std::size_t propertyCount()
+ {
+ return T::propertyCount;
+ }
+
+ camp::Property* property(std::size_t index)
+ {
+ return new MyProperty(T::property(index));
+ }
+
+ std::size_t functionCount()
+ {
+ return T::functionCount;
+ }
+
+ camp::Function* function(std::size_t index)
+ {
+ return new MyFunction(T::function(index));
+ }
+
+ struct MyProperty : public camp::SimpleProperty
+ {
+ public:
+
+ MyProperty(const std::string& name)
+ : camp::SimpleProperty(name, camp::intType)
+ {
+ }
+
+ virtual camp::Value getValue(const camp::UserObject& object) const
+ {
+ T& t = object.get<T>();
+ return t.prop(name());
+ }
+
+ virtual void setValue(const camp::UserObject& object, const camp::Value& value) const
+ {
+ T& t = object.get<T>();
+ t.prop(name()) = value.to<int>();
+ }
+ };
+
+ class MyFunction : public camp::Function
+ {
+ public:
+
+ MyFunction(const std::string& name)
+ : camp::Function(name, camp::stringType)
+ {
+ }
+
+ virtual camp::Value execute(const camp::UserObject& object, const camp::Args&) const
+ {
+ T& t = object.get<T>();
+ return t.func(name());
+ }
+ };
+ };
+
+ void declare()
+ {
+ camp::Class::declare<MyClass>("MapperTest::MyClass")
+ .external<MyMapper>();
+ }
+}
+
+CAMP_AUTO_TYPE(MapperTest::MyClass, &MapperTest::declare)
+
+#endif // CAMPTEST_MAPPER_HPP
diff --git a/test/propertyaccess.hpp b/test/propertyaccess.hpp
index 3097232..20628c6 100644
--- a/test/propertyaccess.hpp
+++ b/test/propertyaccess.hpp
@@ -1,74 +1,74 @@
-/****************************************************************************
-**
-** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
-** Contact: Technogerma Systems France Information (contact at technogerma.fr)
-**
-** This file is part of the CAMP library.
-**
-** CAMP is free software: you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** CAMP is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef CAMPTEST_PROPERTYACCESS_HPP
-#define CAMPTEST_PROPERTYACCESS_HPP
-
-#include <camp/camptype.hpp>
-#include <camp/class.hpp>
-
-namespace PropertyAccessTest
-{
- struct MyClass
- {
- MyClass(bool b = true)
- : m_b(b)
- {
- }
-
- void set(int x) {p = x;}
- int get() const {return p;}
- int& ref() {return p;}
- int p;
-
- bool m_b;
- bool b1() {return true;}
- bool b2() const {return false;}
- };
-
- void declare()
- {
- camp::Class::declare<MyClass>("PropertyAccessTest::MyClass")
-
- // ***** constant value *****
- .property("p0", &MyClass::p).readable(false).writable(true)
- .property("p1", &MyClass::p).readable(true).writable(false)
- .property("p2", &MyClass::p).readable(false).writable(false)
-
- // ***** function *****
- .property("p3", &MyClass::p).readable(&MyClass::b1)
- .property("p4", &MyClass::p).readable(&MyClass::b2)
- .property("p5", &MyClass::p).readable(boost::bind(&MyClass::b1, _1))
- .property("p6", &MyClass::p).readable(&MyClass::m_b)
- .property("p7", &MyClass::p).readable(boost::function<bool (MyClass&)>(&MyClass::m_b))
-
- // ***** implicit - based on the availability of a getter/setter *****
- .property("p8", &MyClass::get)
- .property("p9", &MyClass::ref)
- .property("p10", &MyClass::get, &MyClass::set)
- ;
- }
-}
-
-CAMP_AUTO_TYPE(PropertyAccessTest::MyClass, &PropertyAccessTest::declare)
-
-#endif // CAMPTEST_PROPERTYACCESS_HPP
+/****************************************************************************
+**
+** Copyright (C) 2009-2010 TECHNOGERMA Systems France and/or its subsidiary(-ies).
+** Contact: Technogerma Systems France Information (contact at technogerma.fr)
+**
+** This file is part of the CAMP library.
+**
+** CAMP is free software: you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** CAMP is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with CAMP. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CAMPTEST_PROPERTYACCESS_HPP
+#define CAMPTEST_PROPERTYACCESS_HPP
+
+#include <camp/camptype.hpp>
+#include <camp/class.hpp>
+
+namespace PropertyAccessTest
+{
+ struct MyClass
+ {
+ MyClass(bool b = true)
+ : m_b(b)
+ {
+ }
+
+ void set(int x) {p = x;}
+ int get() const {return p;}
+ int& ref() {return p;}
+ int p;
+
+ bool m_b;
+ bool b1() {return true;}
+ bool b2() const {return false;}
+ };
+
+ void declare()
+ {
+ camp::Class::declare<MyClass>("PropertyAccessTest::MyClass")
+
+ // ***** constant value *****
+ .property("p0", &MyClass::p).readable(false).writable(true)
+ .property("p1", &MyClass::p).readable(true).writable(false)
+ .property("p2", &MyClass::p).readable(false).writable(false)
+
+ // ***** function *****
+ .property("p3", &MyClass::p).readable(&MyClass::b1)
+ .property("p4", &MyClass::p).readable(&MyClass::b2)
+ .property("p5", &MyClass::p).readable(boost::bind(&MyClass::b1, _1))
+ .property("p6", &MyClass::p).readable(&MyClass::m_b)
+ .property("p7", &MyClass::p).readable(boost::function<bool (MyClass&)>(&MyClass::m_b))
+
+ // ***** implicit - based on the availability of a getter/setter *****
+ .property("p8", &MyClass::get)
+ .property("p9", &MyClass::ref)
+ .property("p10", &MyClass::get, &MyClass::set)
+ ;
+ }
+}
+
+CAMP_AUTO_TYPE(PropertyAccessTest::MyClass, &PropertyAccessTest::declare)
+
+#endif // CAMPTEST_PROPERTYACCESS_HPP
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/camp.git
More information about the debian-med-commit
mailing list