MMCore  1.4
Configuration.h
1 // FILE: Configuration.h
3 // PROJECT: Micro-Manager
4 // SUBSYSTEM: MMCore
5 //-----------------------------------------------------------------------------
6 // DESCRIPTION: Set of properties defined as a high level command
7 // AUTHOR: Nenad Amodaj, nenad@amodaj.com, 09/08/2005
8 // COPYRIGHT: University of California, San Francisco, 2006
9 //
10 // LICENSE: This file is distributed under the "Lesser GPL" (LGPL) license.
11 // License text is included with the source distribution.
12 //
13 // This file is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty
15 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 //
17 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
20 // CVS: $Id: Configuration.h 16305 2017-02-11 05:01:12Z mark $
21 //
22 #ifndef _CONFIGURATION_H_
23 #define _CONFIGURATION_H_
24 
25 #ifdef WIN32
26 // disable exception scpecification warnings in MSVC
27 #pragma warning( disable : 4290 )
28 #endif
29 
30 #include <string>
31 #include <vector>
32 #include <map>
33 #include "Error.h"
34 
35 
41 {
48  PropertySetting(const char* deviceLabel, const char* prop, const char* value, bool readOnly = false) :
49  deviceLabel_(deviceLabel), propertyName_(prop), value_(value), readOnly_(readOnly)
50  {
51  key_ = generateKey(deviceLabel, prop);
52  }
53 
54  PropertySetting() : readOnly_(false) {}
55  ~PropertySetting() {}
56 
60  std::string getDeviceLabel() const {return deviceLabel_;}
64  std::string getPropertyName() const {return propertyName_;}
68  bool getReadOnly() const {return readOnly_;}
72  std::string getPropertyValue() const {return value_;}
73 
74  std::string getKey() const {return key_;}
75 
76  static std::string generateKey(const char* device, const char* prop);
77 
78  std::string getVerbose() const;
79  bool isEqualTo(const PropertySetting& ps);
80 
81 private:
82  std::string deviceLabel_;
83  std::string propertyName_;
84  std::string value_;
85  std::string key_;
86  bool readOnly_;
87 };
88 
94 {
100  PropertyPair(const char* prop, const char* value) :
101  propertyName_(prop), value_(value) {}
102 
103  PropertyPair() {}
104  ~PropertyPair() {}
108  std::string getPropertyName() const {return propertyName_;}
112  std::string getPropertyValue() const {return value_;}
113 
114 private:
115  std::string propertyName_;
116  std::string value_;
117 };
118 
124 {
125 public:
126 
127  Configuration() {}
128  ~Configuration() {}
129 
133  void addSetting(const PropertySetting& setting);
134  void deleteSetting(const char* device, const char* prop);
135 
136  bool isPropertyIncluded(const char* device, const char* property);
137  bool isSettingIncluded(const PropertySetting& ps);
138  bool isConfigurationIncluded(const Configuration& cfg);
139 
140  PropertySetting getSetting(size_t index) const throw (CMMError);
141  PropertySetting getSetting(const char* device, const char* prop);
142 
146  size_t size() const {return settings_.size();}
147  std::string getVerbose() const;
148 
149 private:
150  std::vector<PropertySetting> settings_;
151  std::map<std::string, int> index_;
152 };
153 
159 {
160 public:
161 
162  PropertyBlock() {}
163  ~PropertyBlock() {}
164 
165  void addPair(const PropertyPair& pair);
166  PropertyPair getPair(size_t index) const throw (CMMError);
170  size_t size() const {return pairs_.size();}
171  std::string getValue(const char* key) const throw (CMMError);
172 
173 private:
174  std::map<std::string, PropertyPair> pairs_;
175 };
176 
177 #endif //_CONFIGURATION_H_
size_t size() const
Definition: Configuration.h:146
Definition: Configuration.h:40
std::string getDeviceLabel() const
Definition: Configuration.h:60
std::string getPropertyName() const
Definition: Configuration.h:108
Definition: Configuration.h:158
PropertySetting(const char *deviceLabel, const char *prop, const char *value, bool readOnly=false)
Definition: Configuration.h:48
PropertyPair(const char *prop, const char *value)
Definition: Configuration.h:100
bool getReadOnly() const
Definition: Configuration.h:68
std::string getPropertyValue() const
Definition: Configuration.h:72
Definition: Configuration.h:93
std::string getPropertyName() const
Definition: Configuration.h:64
Core error class. Exceptions thrown by the Core public API are of this type.
Definition: Error.h:60
Definition: Configuration.h:123
std::string getVerbose() const
Definition: Configuration.cpp:43
std::string getPropertyValue() const
Definition: Configuration.h:112
size_t size() const
Definition: Configuration.h:170