00001 #ifndef PROPERTIES_H 00002 #define PROPERTIES_H 00003 00004 #include <map> 00005 #include <string> 00006 #include <vector> 00007 #include <memory> 00008 #include <stdexcept> 00009 00010 namespace acsalarm 00011 { 00012 typedef std::map< std::string, std::string >::value_type PropertyMapEntryType; 00013 00014 /* 00015 * Utility class containing a collection of properties, which are name/value pairs of strings. 00016 */ 00017 class Properties 00018 { 00019 private: 00020 00021 std::map<std::string, std::string> propertiesMap; 00022 00023 public: 00024 00025 // constructors 00026 Properties(); 00027 Properties(const Properties &); 00028 00029 // destructor 00030 virtual ~Properties(); 00031 00032 // assignment operator 00033 Properties & operator=(const Properties & rhs); 00034 00035 // equality operator 00036 bool operator==(const Properties &rhs) ; 00037 00038 // operator != 00039 bool operator!=(const Properties &rhs) ; 00040 00048 std::string getProperty(std::string key) ; 00049 00050 // Returns an enumeration of all the keys in this property list, 00051 // including distinct keys in the default property list if a key 00052 // of the same name has not already been found from the main properties list. 00053 std::auto_ptr<std::vector<std::string> > propertyNames(); 00054 00061 void setProperty(std::string key, std::string value) throw(std::invalid_argument); 00062 00063 // Returns an XML fragment (NOT a complete document) representing all of 00064 // the properties contained in this table, for use in the message transported 00065 // from an alarm source to the alarm server. 00066 // @param amountToIndent - used to specify a level of indentation (in spaces) for readability 00067 std::string toXML(int amountToIndent = 6); 00068 00072 unsigned int getSize() const { return propertiesMap.size(); } 00073 }; 00074 } 00075 #endif
1.6.2