![]() |
VR-Forces 4.8 Class Documentation
|
Interface class used to define minimal interface for a property. More...

Public Types | |
| enum | MergeFlags { Replace = 0x00000001, MinimalSimilarityCheck = 0x00000002, RollUp = 0x00000004, AddMissing = 0x00000008, KeepIsPublished = 0x00000010 } |
| Determines how two lists of properties will be merged by the merge function. More... | |
Public Member Functions | |
| virtual | ~DtPropertyInterface () |
| virtual const char * | propertyType () const =0 |
| Typically returns reader/writer type. More... | |
| virtual DtSymbolString | propertyName () const =0 |
| The name of this property. More... | |
| virtual void | setPropertyName (const DtString &propertyName)=0 |
| Sets name of this property. Should generally only be called when initially created. More... | |
| virtual DtString | stringRep (const DtString &root="") const =0 |
| int | getSize () const |
| virtual bool | isSimilarProperty (const DtPropertyInterface *rhs, bool strict=true) const |
| Returns true if the readerWriterType is the same. More... | |
| virtual bool | merge (const DtPropertyInterface &target, MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >())=0 |
| Takes the contents of the supplied properties and merges with the following rules if replace is false: 1) If the same named property of the same type (and prototype and key) exists regardless of what the contents are in this property, it is replaced with the contents of the target 2) If a property in the target does not exist in source, it is not merged in 3) All other items are kept in the source. More... | |
| virtual DtlObjPtr | getData (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)=0 |
| Override to allow a variable to be assigned to a property of derived type. More... | |
| virtual bool | isPublishedArg (DtlObjPtr arg, unsigned &disVarRecType) const |
| Tests whether the argument specified indicates this property should be published. More... | |
| virtual void | reset ()=0 |
| Override to clear out variable value. More... | |
Getting and setting the property value | |
Returns the value of this property. If the value cannot be converted to the specified type, the boost::optional will have a value of false. If it can be, the boost::optional will have a value of true and can then be dereferenced to get the value itself. Example: * int val;
* boost::optional<int> propVal = property->propertyValue<int>();
* if (propVal)
* {
* val = *propVal;
* }
*
| |
| template<typename ValueType > | |
| boost::optional< ValueType > | propertyValue () const |
| template<typename ValueType > | |
| bool | setPropertyValue (ValueType val) |
| Sets the value of this property. More... | |
Generic property lookup functions | |
These functions return the DtPropertyInterface for the named property, assuming it is found within this property. This will only work if this property is composed of other properties (i.e. a structure or an overall DtRwProperties). If this property cannot be found, a null pointer is returned. Example: * DtPropertyInterface* property =
* obj->vrfState()->stateProperties().findPropertyInterface("My-Property-Name");
* if (property)
* {
* // Property was found.
* }
*
Additionally, if you want to find the a field within a structure, you can use the '.' character to indicate this relationship. So the code to find a field with the name "Field1" in the property "My-Structure" would look like this: * DtPropertyInterface* field =
* obj->vrfState()->stateProperties().findPropertyInterface("My-Structure.Field1");
*
| |
| virtual const DtPropertyInterface * | findPropertyInterface (const DtString &propertyName) const |
| virtual DtPropertyInterface * | findPropertyInterface (const DtString &propertyName) |
Specific property type lookup functions | |
These functions return the specific property type for the named property, assuming it is found within this property and matches this type. This will only work if this property is composed of other properties (i.e. a structure or an overall DtRwProperties). If this property cannot be found or is of the wrong type, a null pointer is returned. Example: * DtRwPropertiesStructure* property =
* if (property)
* {
* // Property was found and it was of the expected type.
* }
*
Additionally, if you want to find the a field within a structure, you can use the '.' character to indicate this relationship. So the code to find a field with the name "Field1" in the property "My-Structure" would look like this: DtRwPropertyInt* field = obj->vrfState()->stateProperties().findProperty<DtRwPropertyInt>("My-Structure.Field1"); | |
| template<typename SpecificPropType > | |
| const SpecificPropType * | findProperty (const DtString &propertyName) const |
| template<typename SpecificPropType > | |
| SpecificPropType * | findProperty (const DtString &propertyName) |
Convenience functions for finding and getting/setting property value | |
This is a convenience function that combines the functionality of findProperty and propertyValue to immediately return the value of the property with the given name, assuming it can be found within this property and its value can be converted to the specified type. If not, the boost::optional will be false. Example: * int val;
* boost::optional<int> propVal =
* obj->vrfState()->stateProperties().findPropertyValue<int>("My-Property-Name");
* if (propVal)
* {
* val = *propVal;
* }
*
Additionally, if you want to find the value of a field within a structure, you can use the '.' character to indicate this relationship. So the code to find the value of a field with the name "Field1" in the property "My-Structure" would look like this: * boost::optional<int> fieldVal =
* obj->vrfState()->stateProperties().findPropertyValue("My-Structure.Field1");
*
| |
| template<typename ValueType > | |
| boost::optional< ValueType > | findPropertyValue (const DtString &propertyName) const |
| template<typename ValueType > | |
| bool | findAndSetPropertyValue (const DtString &propertyName, ValueType val) |
| This is a convenience function that combines the functionality of findProperty and setPropertyValue to immediately set the value of the property with the given name, assuming it can be found within this property and its value can be converted from the specified type. More... | |
Property addition functions | |
These functions can be used to add new properties to a properties container. This can be used to add new fields to a DtRwPropertiesStructure or a new property to a DtRwProperties. If this property is not of supported properties container type these functions will fail. Adds an existing property to the properties container. The container will take ownership of the given property. Returns false if this operation was not possible. * obj->vrfState()->stateProperties().addProperty(newProp);
*
| |
| virtual bool | addProperty (DtPropertyInterface *property) |
| template<typename SpecificPropType > | |
| SpecificPropType * | addNewProperty (const DtString &propertyName) |
| Adds a new property of the specified type and returns pointer to the new item. More... | |
Property removal functions | |
These functions can be used to removed properties from a properties container. This can be used to remove fields from a DtRwPropertiesStructure or an existing property from a DtRwProperties. If this property is not of supported properties container type this function will fail. Returns true if successful. | |
| virtual bool | removeProperty (const DtString &propertyName) |
| virtual bool | removeProperty (const DtPropertyInterface *property) |
Network encoding and decoding | |
Encodes the property into the supplied buffer. | |
| virtual char * | encode (char *) const =0 |
| virtual const char * | decode (const char *)=0 |
| Decodes the property from the specified buffer. More... | |
| virtual void | getSize (int &size) const =0 |
| Returns the network size of this item. More... | |
| virtual int | hlaAlignment () const =0 |
| Returns alignment necessary to encode this item in HLA. More... | |
| virtual DtReaderWriter * | readerWriter ()=0 |
| virtual const DtReaderWriter * | readerWriter () const =0 |
| virtual bool | isPublished () const =0 |
| Whether this property should be published. More... | |
| virtual void | setIsPublished (bool isPub)=0 |
| virtual unsigned | disRecordType () const =0 |
| If this property is published, which DIS record type should it use. More... | |
| virtual void | setDisRecordType (unsigned recType)=0 |
Interface class used to define minimal interface for a property.
The DtPropertyInterface class provides the basic interface to a VR-Forces state or parameter property. Properties fall into one of three categories:
Each sim object has a list of both state properties (which are dynamic) and parameters properties (which are static). All properties are defined in the state-data and parameter-data sections of the OPE file used by the sim object. The VR-Forces Users Guide has more general information on properties.
The state and parameter properties are maintained by the DtVrfObjectStateRepository of the object. These lists of state properties and parameter properties are implemented as DtRwProperties, which is itself a subclass of DtPropertyInterface. Therefore you can find any property of an object using the same API as you would to find a property or field that is a subcomponent of another property (as in a structure).
The DtPropertyInterface has a number of functions to help you find and access state and parameter properties. These are documented with some example code as well. The DtRwPropertiesStructure, DtRwPropertiesList, and DtRwPropertiesMap classes have further functions that will help you access their constituent fields and elements.
Determines how two lists of properties will be merged by the merge function.
| Enumerator | |
|---|---|
| Replace | |
| MinimalSimilarityCheck | |
| RollUp | |
| AddMissing | |
| KeepIsPublished | |
|
virtual |
| boost::optional<ValueType> DtPropertyInterface::propertyValue | ( | ) | const |
| bool DtPropertyInterface::setPropertyValue | ( | ValueType | val | ) |
Sets the value of this property.
If the value cannot be converted from the specified type, the operation will fail and false will be returned. Otherwise returns true. Example:
|
inlinevirtual |
Reimplemented in DtRwProperties.
|
inlinevirtual |
Reimplemented in DtRwProperties.
| const SpecificPropType* DtPropertyInterface::findProperty | ( | const DtString & | propertyName | ) | const |
| SpecificPropType* DtPropertyInterface::findProperty | ( | const DtString & | propertyName | ) |
| boost::optional<ValueType> DtPropertyInterface::findPropertyValue | ( | const DtString & | propertyName | ) | const |
| bool DtPropertyInterface::findAndSetPropertyValue | ( | const DtString & | propertyName, |
| ValueType | val | ||
| ) |
This is a convenience function that combines the functionality of findProperty and setPropertyValue to immediately set the value of the property with the given name, assuming it can be found within this property and its value can be converted from the specified type.
If successful, returns true, otherwise returns false. Example:
Additionally, if you want to find and set the value of a field within a structure, you can use the '.' character to indicate this relationship. So the code to find and set the value of a field with the name "Field1" in the property "My-Structure" would look like this:
|
inlinevirtual |
Reimplemented in DtRwProperties.
| SpecificPropType* DtPropertyInterface::addNewProperty | ( | const DtString & | propertyName | ) |
Adds a new property of the specified type and returns pointer to the new item.
Returns a null pointer if a property with that name already existed.
Reimplemented in DtRwProperties.
|
inlinevirtual |
Reimplemented in DtRwProperties.
Implemented in DtRwPropertySizedString, DtRwProperties, DtRwPropertyWithThreshold< _RwType >, DtRwPropertyWithThreshold< DtRwInt >, DtRwPropertyWithThreshold< DtRwInt8 >, DtRwPropertyWithThreshold< DtRwInt16 >, DtRwPropertyWithThreshold< DtRwReal >, DtRwPropertyWithThreshold< DtRwVector >, DtRwPropertyWithThreshold< DtRwReal64 >, DtRwPropertyWithThreshold< DtRwOffsetVector >, DtRwPropertyWithThreshold< DtRwInt32 >, DtRwPropertyWithThreshold< DtRwReal32 >, DtRwPropertiesList, DtRwPropertiesFixedArray, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
Decodes the property from the specified buffer.
Implemented in DtRwPropertySizedString, DtRwProperties, DtRwPropertiesList, DtRwPropertiesFixedArray, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Returns the network size of this item.
Implemented in DtRwPropertySizedString, DtRwProperties, DtRwPropertiesList, DtRwPropertiesFixedArray, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Returns alignment necessary to encode this item in HLA.
Implemented in DtRwPropertySizedString, DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Typically returns reader/writer type.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, DtRwProperty< DtRwReal32 >, and DtRwPropertiesRangeItem.
|
pure virtual |
The name of this property.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
Referenced by DtPropertiesIterator::key(), and DtPropertiesConstIterator::key().
|
pure virtual |
Sets name of this property. Should generally only be called when initially created.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
Referenced by DtVrfStatePropertyPrinter::processObjectUpdated().
| int DtPropertyInterface::getSize | ( | ) | const |
|
pure virtual |
Returns a ReaderWriter pointer of the property. If property is not a ReaderWriter, this should be overridden to return 0.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
virtual |
Returns true if the readerWriterType is the same.
Subclasses can do extra checking. If strict is true, some property types will do extra checking and fail if the types do not exactly match. If false, these types will do a basic check, which can be useful when the the types are similar enough to perform a merge.
Reimplemented in DtRwPropertiesMap, DtRwPropertiesStructure, DtRwPropertiesList, and DtRwPropertiesFixedArray.
|
pure virtual |
Takes the contents of the supplied properties and merges with the following rules if replace is false: 1) If the same named property of the same type (and prototype and key) exists regardless of what the contents are in this property, it is replaced with the contents of the target 2) If a property in the target does not exist in source, it is not merged in 3) All other items are kept in the source.
If replace is true, any matching items are replaced by their target. This will add/remove properties
This is a non-recursive function. It only looks at top level property items. Returns true if merge was successful
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Override to allow a variable to be assigned to a property of derived type.
Implemented in DtRwProperties, DtRwPropertiesList, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
virtual |
Tests whether the argument specified indicates this property should be published.
If a specific DIS variable record type is indicated, this is returned in disVarRecType.
|
pure virtual |
Whether this property should be published.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
If this property is published, which DIS record type should it use.
Default is 0, which indicates that the normal VRF generic attribute record type should be used.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.
|
pure virtual |
Override to clear out variable value.
Implemented in DtRwProperties, DtRwProperty< _RwType >, DtRwProperty< DtRwString >, DtRwProperty< DtRwInt >, DtRwProperty< DtRwInt8 >, DtRwProperty< DtRwInt16 >, DtRwProperty< DtRwReal >, DtRwProperty< DtRwVector >, DtRwProperty< DtRwReal64 >, DtRwProperty< DtRwBoolean >, DtRwProperty< DtRwOffsetVector >, DtRwProperty< DtRwInt32 >, and DtRwProperty< DtRwReal32 >.