| 38 | 
  | 
#include <string> | 
| 39 | 
  | 
#include <vector> | 
| 40 | 
  | 
 | 
| 41 | 
< | 
#include <GenericData.hpp> | 
| 41 | 
> | 
#include <utils/GenericData.hpp> | 
| 42 | 
  | 
 | 
| 43 | 
  | 
namespace oopse{ | 
| 44 | 
  | 
 | 
| 45 | 
< | 
  /** | 
| 46 | 
< | 
   * @class PropertyMap | 
| 47 | 
< | 
   * PropertyMap class maintains a list of GenericData. Type of Property is actually GenericData. | 
| 48 | 
< | 
   */ | 
| 49 | 
< | 
  class PropertyMap{ | 
| 50 | 
< | 
    public: | 
| 51 | 
< | 
       | 
| 52 | 
< | 
      /** trivial constructor */ | 
| 53 | 
< | 
      PropertyMap(); | 
| 45 | 
> | 
    /** | 
| 46 | 
> | 
    * @class PropertyMap | 
| 47 | 
> | 
    * PropertyMap class maintains a list of GenericData. Type of Property is actually GenericData. | 
| 48 | 
> | 
    */ | 
| 49 | 
> | 
    class PropertyMap{ | 
| 50 | 
> | 
        public: | 
| 51 | 
  | 
 | 
| 52 | 
< | 
      /** | 
| 53 | 
< | 
       * Virtual Destructor responsible for deleting all of the generc data in PropertyMap | 
| 57 | 
< | 
       */ | 
| 58 | 
< | 
      virtual ~PropertyMap(); | 
| 52 | 
> | 
            /** trivial constructor */ | 
| 53 | 
> | 
            PropertyMap() {} | 
| 54 | 
  | 
 | 
| 55 | 
< | 
      /** | 
| 56 | 
< | 
       * Adds property into property map | 
| 57 | 
< | 
       * | 
| 58 | 
< | 
       * @param genData GenericData to be added into PropertyMap | 
| 64 | 
< | 
       * | 
| 65 | 
< | 
       * @see #removeProperty | 
| 66 | 
< | 
       * @see #clearProperties | 
| 67 | 
< | 
       */ | 
| 68 | 
< | 
      void addProperty(GenericData* genData); | 
| 55 | 
> | 
            /** | 
| 56 | 
> | 
            * Virtual Destructor responsible for deleting all of the generc data in PropertyMap | 
| 57 | 
> | 
            */ | 
| 58 | 
> | 
            virtual ~PropertyMap(); | 
| 59 | 
  | 
 | 
| 60 | 
< | 
      /** | 
| 61 | 
< | 
       * Removes property from PropertyMap by name | 
| 62 | 
< | 
       * | 
| 63 | 
< | 
       * @param propName the name of property to be removed | 
| 64 | 
< | 
       * | 
| 65 | 
< | 
       * @see #addProperty | 
| 66 | 
< | 
       * @see #clearProperties | 
| 67 | 
< | 
       */ | 
| 68 | 
< | 
      void removeProperty(std::string& propName); | 
| 60 | 
> | 
            /** | 
| 61 | 
> | 
            * Adds property into property map | 
| 62 | 
> | 
            * | 
| 63 | 
> | 
            * @param genData GenericData to be added into PropertyMap | 
| 64 | 
> | 
            * | 
| 65 | 
> | 
            * @see #removeProperty | 
| 66 | 
> | 
            * @see #clearProperties | 
| 67 | 
> | 
            */ | 
| 68 | 
> | 
            void addProperty(GenericData* genData); | 
| 69 | 
  | 
 | 
| 70 | 
< | 
      /** | 
| 71 | 
< | 
       * clear all of the properties | 
| 72 | 
< | 
       * | 
| 73 | 
< | 
       * @see #addProperty | 
| 74 | 
< | 
       * @see #removeProperty | 
| 75 | 
< | 
       */ | 
| 76 | 
< | 
      void clearProperties(); | 
| 70 | 
> | 
            /** | 
| 71 | 
> | 
            * Removes property from PropertyMap by name | 
| 72 | 
> | 
            * | 
| 73 | 
> | 
            * @param propName the name of property to be removed | 
| 74 | 
> | 
            * | 
| 75 | 
> | 
            * @see #addProperty | 
| 76 | 
> | 
            * @see #clearProperties | 
| 77 | 
> | 
            */ | 
| 78 | 
> | 
            bool removeProperty(const std::string& propName); | 
| 79 | 
  | 
 | 
| 80 | 
< | 
      /** | 
| 81 | 
< | 
       * Returns all names of properties | 
| 82 | 
< | 
       * | 
| 83 | 
< | 
       * @return all names of properties | 
| 84 | 
< | 
       */ | 
| 85 | 
< | 
      std::vector<std::string> getPropertyNames(); | 
| 80 | 
> | 
            /** | 
| 81 | 
> | 
            * clear all of the properties | 
| 82 | 
> | 
            * | 
| 83 | 
> | 
            * @see #addProperty | 
| 84 | 
> | 
            * @see #removeProperty | 
| 85 | 
> | 
            */ | 
| 86 | 
> | 
            void clearProperties(); | 
| 87 | 
  | 
 | 
| 88 | 
< | 
      /** | 
| 89 | 
< | 
       * Returns all of the properties in PropertyMap | 
| 90 | 
< | 
       * | 
| 91 | 
< | 
       * @return all of the properties in PropertyMap | 
| 92 | 
< | 
       * | 
| 93 | 
< | 
       * @see #getPropertyByName | 
| 101 | 
< | 
       */       | 
| 102 | 
< | 
      std::vector<GenericData*> getProperties(); | 
| 88 | 
> | 
            /** | 
| 89 | 
> | 
            * Returns all names of properties | 
| 90 | 
> | 
            * | 
| 91 | 
> | 
            * @return all names of properties | 
| 92 | 
> | 
            */ | 
| 93 | 
> | 
            std::vector<std::string> getPropertyNames(); | 
| 94 | 
  | 
 | 
| 95 | 
< | 
      /** | 
| 96 | 
< | 
       * Returns property  | 
| 97 | 
< | 
       * | 
| 98 | 
< | 
       * @param propName name of property | 
| 99 | 
< | 
       * | 
| 100 | 
< | 
       * @return a pointer point to property with propName. If no property named propName | 
| 101 | 
< | 
       * exists, return NULL | 
| 102 | 
< | 
       * | 
| 112 | 
< | 
       * @see #getProperties | 
| 113 | 
< | 
       */       | 
| 114 | 
< | 
      GenericData* getPropertyByName(std:string& propName); | 
| 115 | 
< | 
      template<typename T = GenericData*> T getPropertyByName(std:string& propName); | 
| 116 | 
< | 
       | 
| 117 | 
< | 
    protected: | 
| 118 | 
< | 
      std::map<std::string, GenericData*> propMap_; | 
| 95 | 
> | 
            /** | 
| 96 | 
> | 
            * Returns all of the properties in PropertyMap | 
| 97 | 
> | 
            * | 
| 98 | 
> | 
            * @return all of the properties in PropertyMap | 
| 99 | 
> | 
            * | 
| 100 | 
> | 
            * @see #getPropertyByName | 
| 101 | 
> | 
            */       | 
| 102 | 
> | 
            std::vector<GenericData*> getProperties(); | 
| 103 | 
  | 
 | 
| 104 | 
< | 
    private: | 
| 104 | 
> | 
            /** | 
| 105 | 
> | 
            * Returns property  | 
| 106 | 
> | 
            * | 
| 107 | 
> | 
            * @param propName name of property | 
| 108 | 
> | 
            * | 
| 109 | 
> | 
            * @return a pointer point to property with propName. If no property named propName | 
| 110 | 
> | 
            * exists, return NULL | 
| 111 | 
> | 
            * | 
| 112 | 
> | 
            * @see #getProperties | 
| 113 | 
> | 
            */       | 
| 114 | 
> | 
            GenericData* getPropertyByName(const std::string& propName); | 
| 115 | 
> | 
            //template<typename T = GenericData*> T getPropertyByName(std:string& propName); | 
| 116 | 
  | 
 | 
| 117 | 
< | 
      /** prevent copy constructing */ | 
| 118 | 
< | 
      PropertyMap(const PropertyMap&); | 
| 117 | 
> | 
            protected: | 
| 118 | 
> | 
            std::map<std::string, GenericData*> propMap_; | 
| 119 | 
  | 
 | 
| 120 | 
< | 
      /** prevent copy assignment */ | 
| 126 | 
< | 
      PropertyMap& operator=(const PropertyMap&); | 
| 127 | 
< | 
  }; | 
| 120 | 
> | 
        private: | 
| 121 | 
  | 
 | 
| 122 | 
+ | 
            /** prevent copy constructing */ | 
| 123 | 
+ | 
            PropertyMap(const PropertyMap&); | 
| 124 | 
+ | 
 | 
| 125 | 
+ | 
            /** prevent copy assignment */ | 
| 126 | 
+ | 
            PropertyMap& operator=(const PropertyMap&); | 
| 127 | 
+ | 
    }; | 
| 128 | 
+ | 
 | 
| 129 | 
  | 
}// namespace oopse | 
| 130 | 
  | 
#endif //UTIL_PROPERTYMAP_HPP |