24 #include "drwnSmartPointer.h"
31 typedef enum _drwnPropertyType {
32 DRWN_INVALID_PROPERTY, DRWN_BOOLEAN_PROPERTY, DRWN_INTEGER_PROPERTY,
33 DRWN_DOUBLE_PROPERTY, DRWN_STRING_PROPERTY, DRWN_FILENAME_PROPERTY,
34 DRWN_DIRECTORY_PROPERTY, DRWN_LIST_PROPERTY, DRWN_SELECTION_PROPERTY,
35 DRWN_VECTOR_PROPERTY, DRWN_MATRIX_PROPERTY, DRWN_USER_PROPERTY
47 _bReadOnly(bReadOnly), _bSerialize(bSerialize) { }
53 virtual drwnPropertyType type()
const = 0;
54 virtual string asString()
const = 0;
56 inline bool isReadOnly()
const {
return _bReadOnly; }
57 inline bool isSerializeable()
const {
return _bSerialize; }
60 virtual bool setProperty(
bool value);
61 virtual bool setProperty(
int value);
62 virtual bool setProperty(
double value);
63 virtual bool setProperty(
const string& value);
64 virtual bool setProperty(
const char *value);
65 virtual bool setProperty(
const Eigen::VectorXd& value);
66 virtual bool setProperty(
const Eigen::MatrixXd& value);
69 virtual void read(drwnXMLNode& xml);
70 virtual void write(drwnXMLNode& xml)
const;
74 iface->_bReadOnly |= bReadOnly;
75 iface->_bSerialize = bSerialize;
91 inline const T& getValue()
const {
return *_storage; }
92 inline bool setValue(
const T& value) { *_storage = value;
return true; }
105 drwnPropertyType type()
const {
return DRWN_BOOLEAN_PROPERTY; }
106 string asString()
const;
109 bool setProperty(
bool value);
110 bool setProperty(
int value);
111 bool setProperty(
double value);
112 bool setProperty(
const string& value);
113 bool setProperty(
const Eigen::VectorXd& value);
114 bool setProperty(
const Eigen::MatrixXd& value);
123 drwnPropertyType type()
const {
return DRWN_INTEGER_PROPERTY; }
124 string asString()
const;
127 bool setProperty(
bool value);
128 bool setProperty(
int value);
129 bool setProperty(
double value);
130 bool setProperty(
const string& value);
131 bool setProperty(
const Eigen::VectorXd& value);
132 bool setProperty(
const Eigen::MatrixXd& value);
149 bool setProperty(
int value);
158 drwnPropertyType type()
const {
return DRWN_DOUBLE_PROPERTY; }
159 string asString()
const;
162 bool setProperty(
bool value);
163 bool setProperty(
int value);
164 bool setProperty(
double value);
165 bool setProperty(
const string& value);
166 bool setProperty(
const Eigen::VectorXd& value);
167 bool setProperty(
const Eigen::MatrixXd& value);
184 bool setProperty(
double value);
193 drwnPropertyType type()
const {
return DRWN_STRING_PROPERTY; }
194 string asString()
const;
198 bool setProperty(
bool value);
199 bool setProperty(
int value);
200 bool setProperty(
double value);
201 bool setProperty(
const string& value);
202 bool setProperty(
const Eigen::VectorXd& value);
203 bool setProperty(
const Eigen::MatrixXd& value);
211 drwnPropertyType type()
const {
return DRWN_FILENAME_PROPERTY; }
220 drwnPropertyType type()
const {
return DRWN_DIRECTORY_PROPERTY; }
230 drwnPropertyType type()
const {
return DRWN_LIST_PROPERTY; }
231 string asString()
const;
235 bool setProperty(
bool value);
236 bool setProperty(
int value);
237 bool setProperty(
double value);
238 bool setProperty(
const string& value);
239 bool setProperty(
const Eigen::VectorXd& value);
240 bool setProperty(
const Eigen::MatrixXd& value);
245 const vector<string> *_choices;
250 _choices(choices) { }
252 drwnPropertyType type()
const {
return DRWN_SELECTION_PROPERTY; }
253 string asString()
const;
256 const vector<string> *getChoices()
const {
return _choices; }
258 bool setProperty(
bool value);
259 bool setProperty(
int value);
260 bool setProperty(
double value);
261 bool setProperty(
const string& value);
264 void read(drwnXMLNode& xml);
265 void write(drwnXMLNode& xml)
const;
274 drwnPropertyType type()
const {
return DRWN_VECTOR_PROPERTY; }
275 string asString()
const;
278 bool setProperty(
bool value);
279 bool setProperty(
int value);
280 bool setProperty(
double value);
281 bool setProperty(
const string& value);
282 bool setProperty(
const Eigen::VectorXd& value);
283 bool setProperty(
const Eigen::MatrixXd& value);
286 void read(drwnXMLNode& xml);
287 void write(drwnXMLNode& xml)
const;
296 drwnPropertyType type()
const {
return DRWN_MATRIX_PROPERTY; }
297 string asString()
const;
300 bool setProperty(
bool value);
301 bool setProperty(
int value);
302 bool setProperty(
double value);
303 bool setProperty(
const string& value);
304 bool setProperty(
const Eigen::VectorXd& value);
305 bool setProperty(
const Eigen::MatrixXd& value);
308 void read(drwnXMLNode& xml);
309 void write(drwnXMLNode& xml)
const;
351 vector<pair<string, drwnPropertyInterfacePtr> > _properties;
352 map<string, unsigned> _propertiesIndex;
360 unsigned numProperties()
const {
return _properties.size(); }
361 bool hasProperty(
const string& name)
const;
362 bool hasProperty(
const char *name)
const {
return hasProperty(
string(name)); }
363 unsigned findProperty(
const string& name)
const;
364 unsigned findProperty(
const char *name)
const {
return findProperty(
string(name)); }
368 void setProperty(
unsigned indx,
bool value);
369 void setProperty(
unsigned indx,
int value);
370 void setProperty(
unsigned indx,
double value);
371 void setProperty(
unsigned indx,
const string& value);
372 void setProperty(
unsigned indx,
const char *value);
373 void setProperty(
unsigned indx,
const Eigen::VectorXd& value);
374 void setProperty(
unsigned indx,
const Eigen::MatrixXd& value);
376 void setProperty(
const char *name,
bool value);
377 void setProperty(
const char *name,
int value);
378 void setProperty(
const char *name,
double value);
379 void setProperty(
const char *name,
const string& value);
380 void setProperty(
const char *name,
const char *value);
381 void setProperty(
const char *name,
const Eigen::VectorXd& value);
382 void setProperty(
const char *name,
const Eigen::MatrixXd& value);
385 string getPropertyAsString(
unsigned indx)
const;
386 drwnPropertyType getPropertyType(
unsigned indx)
const;
387 bool isReadOnly(
unsigned indx)
const;
391 bool getBoolProperty(
unsigned indx)
const;
392 int getIntProperty(
unsigned indx)
const;
393 double getDoubleProperty(
unsigned indx)
const;
394 const string& getStringProperty(
unsigned indx)
const;
395 const list<string>& getListProperty(
unsigned indx)
const;
396 int getSelectionProperty(
unsigned indx)
const;
397 const Eigen::VectorXd& getVectorProperty(
unsigned indx)
const;
398 const Eigen::MatrixXd& getMatrixProperty(
unsigned indx)
const;
401 const string& getPropertyName(
unsigned indx)
const;
402 vector<string> getPropertyNames()
const;
405 void readProperties(drwnXMLNode& xml,
const char *tag =
"property");
406 void writeProperties(drwnXMLNode& xml,
const char *tag =
"property")
const;
407 void printProperties(ostream &os)
const;
418 void undeclareProperty(
const string& name);
423 void exposeProperties(
drwnProperties *opts,
const string& prefix =
string(
""),
424 bool bSerializable =
false);
432 virtual void propertyChanged(
const string& name) {
446 vector<pair<void *, bool> > _data;
455 void propertyChanged(
const string& name);
Provides an abstract interface for dynamic properties.
Definition: drwnProperties.h:338
Definition: drwnProperties.h:152
Definition: drwnProperties.h:290
Definition: drwnProperties.h:243
Definition: drwnProperties.h:135
Definition: drwnProperties.h:99
Definition: drwnProperties.h:40
Definition: drwnProperties.h:215
Definition: drwnProperties.h:443
Definition: drwnProperties.h:206
Definition: drwnProperties.h:187
Definition: drwnProperties.h:224
Definition: drwnProperties.h:83
Provides XML parsing functionality for serializing and deserializing objects and containers of object...
Definition: drwnProperties.h:117
Definition: drwnProperties.h:268
Definition: drwnProperties.h:170