VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
propertyUtils.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
13 
14 #pragma once
15 
16 #include <boost/optional.hpp>
17 #include <readerWriter/rwTypes.h>
23 
27 inline const DtReaderWriter* findPropertyRw(const DtReaderWriter& properties, const DtString& propertyName);
28 inline DtReaderWriter* findPropertyRw(DtReaderWriter& properties, const DtString& propertyName);
30 
33 inline const DtReaderWriter* findVariableBindingValueRw(const DtReaderWriter& properties, const DtString& propertyName);
34 inline DtReaderWriter* findVariableBindingValueRw(DtReaderWriter& properties, const DtString& propertyName);
36 
41 template <typename RwType>
43  DtRwVariableBindings &variableBindings,
44  DtRwVariableBindings &defaultBindings,
45  const DtString& variableName);
46 
51 template <typename SpecificRwType>
52 const SpecificRwType* findProperty(const DtReaderWriter& properties, const DtString& propertyName);
53 template <typename SpecificRwType>
54 SpecificRwType* findProperty(DtReaderWriter& properties, const DtString& propertyName);
56 
59 template <typename SpecificRwType>
60 const SpecificRwType* findTypedProperty(const DtReaderWriter& properties, const DtString& propertyName);
61 template <typename SpecificRwType>
62 SpecificRwType* findTypedProperty(DtReaderWriter& properties, const DtString& propertyName);
64 
70 template <typename SpecificRwType>
71 SpecificRwType* addProperty(DtReaderWriter& properties, const DtString& propertyName);
72 
75 inline void addProperty(DtReaderWriter& properties, DtRwProperties* property);
76 
78 
88 template <typename T>
89 boost::optional<T> getPropertyValue(const DtReaderWriter* prop);
90 
94 template <typename T>
95 boost::optional<T> findPropertyValue(const DtReaderWriter& properties, const DtString& propertyName);
96 
101 template <typename T>
102 void setPropertyValue(DtReaderWriter* prop, T val);
103 
109 template <typename T>
110 bool findAndSetPropertyValue(DtReaderWriter& properties, const DtString& propertyName, T val);
111 
114 template <typename T>
115 void setListProperty(DtReaderWriter* prop, const std::list<T>& l);
116 template <typename T>
117 void setListProperty(DtReaderWriter* prop, const std::vector<T>& l);
119 
127 template <typename T>
128 bool findAndSetListProperty(DtReaderWriter& properties, const DtString& propertyName, const std::list<T>& l);
129 template <typename T>
130 bool findAndSetListProperty(DtReaderWriter& properties, const DtString& propertyName, const std::vector<T>& l);
132 
134 template <typename K, typename T>
135 void setMapProperty(DtReaderWriter* prop, const std::map<K, T>& l);
136 
144 template <typename K, typename T>
145 bool findAndSetMapProperty(DtReaderWriter& properties, const DtString& propertyName, const std::map<K, T>& m);
146 
148 template <typename T>
149 boost::optional<T> findVariableBindingValue(const DtReaderWriter& properties, const DtString& propertyName);
150 
152 template <typename T>
153 boost::optional<T> findVariableBindingValue(const DtReaderWriter& properties, const DtReaderWriter& defaultProperties,
154  const DtString& propertyName);
155 
159 inline const DtReaderWriter* findMapItemRw(const DtRwPropertiesMap& propertiesMap, const DtString& itemName);
160 inline DtReaderWriter* findMapItemRw(DtRwPropertiesMap& propertiesMap, const DtString& itemName);
162 
167 template <typename SpecificRwType>
168 const SpecificRwType* findMapItem(const DtRwPropertiesMap& propertiesMap, const DtString& itemName);
169 template <typename SpecificRwType>
170 SpecificRwType* findMapItem(DtRwPropertiesMap& propertiesMap, const DtString& itemName);
172 
173 
174 
175 #include "propertyUtils.inl"
176 
bool findAndSetListProperty(DtReaderWriter &properties, const DtString &propertyName, const std::list< T > &l)
Finds the ReaderWriter object in the given set of properties with the specified name, checks that it is a list with elements of type T, and sets it. This effectively a convenience function for calling findPropertyRw() and setting each item in the list. Only works with lists of simple data types (i.e. numerical values, bools, strings). Returns false if no property with that name can be found.
SpecificRwType * addProperty(DtReaderWriter &properties, const DtString &propertyName)
Adds a property with the specified name to the given set of properties. SpecificRwType must be a subc...
boost::optional< T > getPropertyValue(const DtReaderWriter *prop)
Extracts the value from the given ReaderWriter property. The template parameter type must be an appro...
Definition: readerWriter.h:85
boost::optional< T > findPropertyValue(const DtReaderWriter &properties, const DtString &propertyName)
Finds the ReaderWriter object in the given set of properties with the specified name and returns its ...
const SpecificRwType * findMapItem(const DtRwPropertiesMap &propertiesMap, const DtString &itemName)
Finds the ReaderWriter object in the given DtRwPropertiesMap that matches the specified name...
ReaderWriter object that maintains a list of reader-writer variable bindings. It keeps a list of name...
Definition: rwVariableBindings.h:27
const SpecificRwType * findProperty(const DtReaderWriter &properties, const DtString &propertyName)
Finds the ReaderWriter object in the given set of properties with the specified name. Then verifies that the ReaderWriter matches the type specified as the template argument. Returns a valid pointer if successful.
boost::optional< T > findVariableBindingValue(const DtReaderWriter &properties, const DtString &propertyName)
Same as findPropertyValue but assumes variable bindings.
Defines the DtRwPropertiesStructure class, a structure containing fields, which are themselves proper...
const DtReaderWriter * findPropertyRw(const DtReaderWriter &properties, const DtString &propertyName)
Contains utility functions to make it easier to find and extract data from a set of extended properti...
void setMapProperty(DtReaderWriter *prop, const std::map< K, T > &l)
Sets the values of the given map ReaderWriter property.
Acts as a map for properties. A map is a definition that has a key and a prototype, with values being the key and prototype pair. The key can only be a string (DtRwStringType), int (DtRwIntType, DtRwInt8Type, DtRwInt16Type, DtRwInt32Type), or real (DtRwRealType, DtRwReal32Type, DtRwReal64Type).
Definition: rwPropertiesMap.h:41
const DtReaderWriter * findVariableBindingValueRw(const DtReaderWriter &properties, const DtString &propertyName)
Same as findPropertyRw but for variable bindings.
const SpecificRwType * findTypedProperty(const DtReaderWriter &properties, const DtString &propertyName)
Same as findProperty() but with a specific name to avoid name conflicts in some use cases...
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:126
void setPropertyValue(DtReaderWriter *prop, T val)
Sets the value of the given ReaderWriter property. The template parameter type must be an appropriate...
bool findAndSetMapProperty(DtReaderWriter &properties, const DtString &propertyName, const std::map< K, T > &m)
Finds the ReaderWriter object in the given set of properties with the specified name, checks that it is a map with keys of type K and elements of type T, and sets it. This effectively a convenience function for calling findPropertyRw() and setting each item in the map. Only works with lists of simple data types (i.e. numerical values, bools, strings). Returns false if no property with that name can be found.
const DtReaderWriter * findMapItemRw(const DtRwPropertiesMap &propertiesMap, const DtString &itemName)
Finds the generic ReaderWriter object in the given DtRwPropertiesMap that matches the specified name...
bool findAndSetPropertyValue(DtReaderWriter &properties, const DtString &propertyName, T val)
Finds the ReaderWriter object in the given set of properties with the specified name and sets its val...
RwType * findVariableBindingWithDefault(DtRwVariableBindings &variableBindings, DtRwVariableBindings &defaultBindings, const DtString &variableName)
Finds a RW corresponding to the given variable name, as with the above functions, but also looks in t...
void setListProperty(DtReaderWriter *prop, const std::list< T > &l)
Sets the values of the given list ReaderWriter property.

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)