00001 #ifndef PROPERTIES_H 00002 #define PROPERTIES_H 00003 00004 /******************************************************************************* 00005 * ALMA - Atacama Large Millimeter Array 00006 * Copyright (c) ESO - European Southern Observatory, 2011 00007 * (in the framework of the ALMA collaboration). 00008 * All rights reserved. 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 *******************************************************************************/ 00024 #include <map> 00025 #include <string> 00026 #include <vector> 00027 #include <memory> 00028 #include <stdexcept> 00029 00030 namespace acsalarm 00031 { 00032 typedef std::map< std::string, std::string >::value_type PropertyMapEntryType; 00033 00034 /* 00035 * Utility class containing a collection of properties, which are name/value pairs of strings. 00036 */ 00037 class Properties 00038 { 00039 protected: 00040 00041 std::map<std::string, std::string> propertiesMap; 00042 00043 public: 00044 00045 // constructors 00046 Properties(); 00047 Properties(const Properties &); 00048 00049 // destructor 00050 virtual ~Properties(); 00051 00052 // assignment operator 00053 Properties & operator=(const Properties & rhs); 00054 00055 // equality operator 00056 bool operator==(const Properties &rhs) ; 00057 00058 // operator != 00059 bool operator!=(const Properties &rhs) ; 00060 00068 std::string getProperty(std::string key) const; 00069 00070 // Returns an enumeration of all the keys in this property list, 00071 // including distinct keys in the default property list if a key 00072 // of the same name has not already been found from the main properties list. 00073 std::auto_ptr<std::vector<std::string> > propertyNames(); 00074 00081 void setProperty(std::string key, std::string value) throw(std::invalid_argument); 00082 00086 unsigned int getSize() const { return propertiesMap.size(); } 00087 }; 00088 } 00089 #endif