--- trunk/src/utils/GenericData.hpp 2005/04/15 22:03:16 506 +++ trunk/src/utils/GenericData.hpp 2005/04/15 22:04:00 507 @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a @@ -56,200 +56,200 @@ namespace oopse{ #include namespace oopse{ - /** - * @ class GenericData GenericData.hpp "utils/GenericData.hpp" - * @brief Base class for generic data which is associated with an id - */ - class GenericData{ - public: - GenericData() : id_("UndefinedGenericData"){} + /** + * @ class GenericData GenericData.hpp "utils/GenericData.hpp" + * @brief Base class for generic data which is associated with an id + */ + class GenericData{ + public: + GenericData() : id_("UndefinedGenericData"){} - GenericData(const std::string& id) { setID(id); } + GenericData(const std::string& id) { setID(id); } - /** virtual destructor */ - virtual ~GenericData() {} + /** virtual destructor */ + virtual ~GenericData() {} - /** - * Returns the id of this generic data - * - * @return the id of this generic data - * - * @see #setID - */ - const std::string getID() const { return id_; } + /** + * Returns the id of this generic data + * + * @return the id of this generic data + * + * @see #setID + */ + const std::string getID() const { return id_; } - /** - * Sets the id of this generic data - * - * @param id the id to be set - * - * @see #getID - */ - void setID(const std::string& id) { id_ = id; } + /** + * Sets the id of this generic data + * + * @param id the id to be set + * + * @see #getID + */ + void setID(const std::string& id) { id_ = id; } - private: - GenericData(const GenericData&); - GenericData& operator=(GenericData&); - std::string id_; + private: + GenericData(const GenericData&); + GenericData& operator=(GenericData&); + std::string id_; - }; + }; - /** - * @class SimpleTypeData - * @brief SimpleTypeData class is a POD repository class - * @warning ElemDataType must be copy constructible, and copy assignable - */ - template class SimpleTypeData : public GenericData{ + /** + * @class SimpleTypeData + * @brief SimpleTypeData class is a POD repository class + * @warning ElemDataType must be copy constructible, and copy assignable + */ + template class SimpleTypeData : public GenericData{ - public: - SimpleTypeData() : GenericData(), data_(ElemDataType()) {} - SimpleTypeData(const std::string& id) : GenericData(id), data_(ElemDataType()) {} - SimpleTypeData(const std::string&id , const ElemDataType& data) : GenericData(id), data_(data) {} - template - SimpleTypeData(const SimpleTypeData& s) { - data_ = s.getData(); - } + public: + SimpleTypeData() : GenericData(), data_(ElemDataType()) {} + SimpleTypeData(const std::string& id) : GenericData(id), data_(ElemDataType()) {} + SimpleTypeData(const std::string&id , const ElemDataType& data) : GenericData(id), data_(data) {} + template + SimpleTypeData(const SimpleTypeData& s) { + data_ = s.getData(); + } - SimpleTypeData& operator =(const SimpleTypeData& s) { - if (this == &s) - return *this; + SimpleTypeData& operator =(const SimpleTypeData& s) { + if (this == &s) + return *this; - data_ = s.getData(); - return *this; - } + data_ = s.getData(); + return *this; + } - template - SimpleTypeData& operator =(const SimpleTypeData& s) { - data_ = s.getData(); - return *this; - } + template + SimpleTypeData& operator =(const SimpleTypeData& s) { + data_ = s.getData(); + return *this; + } - /** Returns POD data */ - const ElemDataType& getData() const {return data_;} - ElemDataType& getData() {return data_;} - /** - * Sets POD data - * @data POD data to be set - */ - void setData(const ElemDataType& data) { data_ = data; } + /** Returns POD data */ + const ElemDataType& getData() const {return data_;} + ElemDataType& getData() {return data_;} + /** + * Sets POD data + * @data POD data to be set + */ + void setData(const ElemDataType& data) { data_ = data; } - private: - ElemDataType data_; - }; + private: + ElemDataType data_; + }; - /** BoolGenericData is a generic data type contains a bool variable */ - typedef SimpleTypeData BoolGenericData; + /** BoolGenericData is a generic data type contains a bool variable */ + typedef SimpleTypeData BoolGenericData; - /** IntGenericData is a generic data type contains an integer variable */ - typedef SimpleTypeData IntGenericData; + /** IntGenericData is a generic data type contains an integer variable */ + typedef SimpleTypeData IntGenericData; - /** FloatGenericData is a generic data type contains a float variable */ - typedef SimpleTypeData FloatGenericData; + /** FloatGenericData is a generic data type contains a float variable */ + typedef SimpleTypeData FloatGenericData; - /** DoubleGenericData is a generic data type contains a double variable */ - typedef SimpleTypeData DoubleGenericData; + /** DoubleGenericData is a generic data type contains a double variable */ + typedef SimpleTypeData DoubleGenericData; - /** - * @typedef StringGenericData - * A generic data type contains a std::string variable - * - * @code - * StringGenericData* s = new StringGenericData("MyStringGenericData"); - * PropertyMap propMap; - * GenericData* gdata; - * - * s->setData("OOPSE"); - * propMap->addProperty(s); - * - * gdata = propMap->getPropertyByName("MyStringGenericData"); - * if (gdata != NULL){ - * s = dynamic_cast(gdata); - * if (s != NULL) - * std::cout << s->getData() << std::endl; - * } - * - * @endcode - */ - typedef SimpleTypeData StringGenericData; + /** + * @typedef StringGenericData + * A generic data type contains a std::string variable + * + * @code + * StringGenericData* s = new StringGenericData("MyStringGenericData"); + * PropertyMap propMap; + * GenericData* gdata; + * + * s->setData("OOPSE"); + * propMap->addProperty(s); + * + * gdata = propMap->getPropertyByName("MyStringGenericData"); + * if (gdata != NULL){ + * s = dynamic_cast(gdata); + * if (s != NULL) + * std::cout << s->getData() << std::endl; + * } + * + * @endcode + */ + typedef SimpleTypeData StringGenericData; - /** - * @class STLContainerTypeData - * @brief STL container type generic data which is associated with an id - * - * @template ContainerType - * @template ElemDataType - */ - template - class VectorTypeData : public GenericData { - public: - typedef VectorTypeData SelfType; + /** + * @class STLContainerTypeData + * @brief STL container type generic data which is associated with an id + * + * @template ContainerType + * @template ElemDataType + */ + template + class VectorTypeData : public GenericData { + public: + typedef VectorTypeData SelfType; - VectorTypeData(const std::string& id) - : GenericData(id){} + VectorTypeData(const std::string& id) + : GenericData(id){} - VectorTypeData(const SelfType& s) : SelfType(s){} + VectorTypeData(const SelfType& s) : SelfType(s){} - SelfType& operator =(const SelfType& s){ - if (this == &s) - return *this; + SelfType& operator =(const SelfType& s){ + if (this == &s) + return *this; - this->data_ = s.data_; - return *this; - } + this->data_ = s.data_; + return *this; + } - private: - std::vector data_; - }; + private: + std::vector data_; + }; - /** - * @typedef IntVectorGenericData - * A generic data type contains a std::vector variable. - */ - typedef VectorTypeData IntVectorGenericData; + /** + * @typedef IntVectorGenericData + * A generic data type contains a std::vector variable. + */ + typedef VectorTypeData IntVectorGenericData; - /** - * @typedef IntVectorGenericData - * A generic data type contains a std::vector variable. - */ - typedef VectorTypeData FloatVectorGenericData; + /** + * @typedef IntVectorGenericData + * A generic data type contains a std::vector variable. + */ + typedef VectorTypeData FloatVectorGenericData; - /** - * @typedef IntVectorGenericData - * A generic data type contains a std::vector variable. - */ - typedef VectorTypeData DoubleVectorGenericData; + /** + * @typedef IntVectorGenericData + * A generic data type contains a std::vector variable. + */ + typedef VectorTypeData DoubleVectorGenericData; - /** - * @typedef StringVectorGenericData - * A generic data type contains a std::vector variable. - * - * @code - * StringVectorGenericData* sv = new StringVectorGenericData("MyStringVector"); - * GenericData* gdata; - * PropertyMap propMap; - * std::vector::iterator iter; - * - * sv->push_back("Hello World"); - * sv->push_back("OOPSE"); - * - * propMap.addProperty(sv); - * - * gdata = propMap.getPropertyByName("MyStringVector"); - * - * if (gdata != NULL){ - * - * sv = dynamic_cast(gdata); - * - * if (sv != NULL){ - * for (iter = sv->begin(); iter != sv->end(); ++ iter) - * std::cout << *iter << std::endl; - * } - * } - * @endcode - */ - typedef VectorTypeData StringVectorGenericData; + /** + * @typedef StringVectorGenericData + * A generic data type contains a std::vector variable. + * + * @code + * StringVectorGenericData* sv = new StringVectorGenericData("MyStringVector"); + * GenericData* gdata; + * PropertyMap propMap; + * std::vector::iterator iter; + * + * sv->push_back("Hello World"); + * sv->push_back("OOPSE"); + * + * propMap.addProperty(sv); + * + * gdata = propMap.getPropertyByName("MyStringVector"); + * + * if (gdata != NULL){ + * + * sv = dynamic_cast(gdata); + * + * if (sv != NULL){ + * for (iter = sv->begin(); iter != sv->end(); ++ iter) + * std::cout << *iter << std::endl; + * } + * } + * @endcode + */ + typedef VectorTypeData StringVectorGenericData; } // namespace oopse