API  4.3
For C++ developers
OpenSim::AbstractProperty Class Referenceabstract

An abstract property is a serializable (name,value) pair, for which we do not know the type of the value. More...

+ Inheritance diagram for OpenSim::AbstractProperty:

Public Member Functions

void setAllowableListSize (int aMin, int aMax)
 Require that the number of values n in the value list of this property be in the range aMin <= n <= aMax. More...
 
void setAllowableListSize (int aNum)
 Require that the number of values n in the value list of this property be exactly n=aNum values. More...
 
virtual ~AbstractProperty ()
 Return all heap space used by this property. More...
 
virtual AbstractPropertyclone () const =0
 Return a new instance of this concrete property object, containing new copies of this property's values. More...
 
virtual std::string toString () const =0
 For relatively simple types, return the current value of this property in a string suitable for displaying to a user in the GUI (i.e., this number may be rounded and not an exact representation of the actual value being used). More...
 
virtual std::string toStringForDisplay (const int precision) const
 For relatively simple types, return the current value of this property in a string suitable for displaying to a user in the GUI (i.e., this number may be rounded and not an exact representation of the actual value being used). More...
 
virtual std::string getTypeName () const =0
 This returns a string representation of this property's value type which will be the same as T::getClassName() for Object-derived types T, and some reasonably nice name for simple types, including at least "bool", "int", "double", "string", "Vec3", "Vector", and "Transform". More...
 
virtual bool isObjectProperty () const =0
 Return true if this is an "object property", meaning that its values are all concrete objects of types that ultimately derive from the OpenSim serializable base class Object. More...
 
virtual bool isUnnamedProperty () const =0
 An unnamed property is a one-object property whose name was given as null or as the contained object's type tag. More...
 
bool equals (const AbstractProperty &other) const
 Compare this property with another one; this is primarily used for testing. More...
 
bool isSamePropertyClass (const AbstractProperty &other) const
 Return true if the other property is an object of exactly the same concrete class as this one. More...
 
bool operator== (const AbstractProperty &other) const
 See the equals() method for the meaning of this operator. More...
 
void setAllPropertiesUseDefault (bool shouldUseDefault)
 This method sets the "use default" flag for this property and the properties of any objects it contains to the given value. More...
 
void readFromXMLParentElement (SimTK::Xml::Element &parent, int versionNumber)
 Given an XML parent element expected to contain a value for this property as an immediate child element, find that property element and set the property value from it. More...
 
void writeToXMLParentElement (SimTK::Xml::Element &parent) const
 Given an XML parent element, append a single child element representing the serialized form of this property. More...
 
void setName (const std::string &name)
 Set the property name. More...
 
void setComment (const std::string &aComment)
 Set a user-friendly comment to be associated with property. More...
 
void setValueIsDefault (bool isDefault)
 Set flag indicating whether the value of this property was simply taken from a default object and thus should not be written out when serializing. More...
 
const std::string & getName () const
 Get the property name. More...
 
const std::string & getComment () const
 Get the comment associated with this property. More...
 
bool getValueIsDefault () const
 Get the flag indicating whether the current value is just the default value for this property (in which case it doesn't need to be written out). More...
 
int getMinListSize () const
 Get the minimum number of values allowed in this property's value list. More...
 
int getMaxListSize () const
 Get the maximum number of values allowed in this property's value list. More...
 
bool isOptionalProperty () const
 This is an "optional" property if its value list can contain at most one value. More...
 
bool isListProperty () const
 This is a "list" property if its value list can contain more than one value. More...
 
bool isOneValueProperty () const
 This is a "one-value" property if its value list must always contain exactly one value. More...
 
bool isOneObjectProperty () const
 This is a "one-object" property if it is a "one-value" property and it contains an Object-derived value. More...
 
Container interface

A property can be viewed as a random-access container of values.

These methods provide a subset of the usual container methods modeled after std::vector. Note that any methods involving the actual property value type T must be templatized; they will be delegated to the concrete Property<T> for resolution.

int size () const
 Return the number of values currently in this property's value list. More...
 
bool empty () const
 Return true if this property's value list is currently empty. More...
 
void clear ()
 Empty the value list for this property; fails if zero is not an allowable size for this property. More...
 
virtual const ObjectgetValueAsObject (int index=-1) const =0
 For an object property, the values can be obtained as references to the abstract base class Object from which all the objects derive. More...
 
virtual ObjectupdValueAsObject (int index=-1)=0
 Get writable access to an existing object value. More...
 
virtual void setValueAsObject (const Object &obj, int index=-1)=0
 Set the indicated value element to a new copy of the supplied object. More...
 
template<class T >
const T & getValue (int index=-1) const
 Return one of the values in this property as type T; this works only if the underlying concrete property stores type T and if the indexed element is present, otherwise throws an exception. More...
 
template<class T >
T & updValue (int index=-1)
 Return a writable reference to one of the values in this property as type T; this works only if the underlying concrete property is actually of type T and the indexed element is present. More...
 
template<class T >
int appendValue (const T &value)
 Append a new value of type T to the end of the list of values currently contained in this property. More...
 
virtual void assign (const AbstractProperty &that)=0
 Assign (copy) property that to this object. More...
 

Protected Member Functions

 AbstractProperty ()
 
 AbstractProperty (const std::string &name, const std::string &comment)
 
 AbstractProperty (const AbstractProperty &)=default
 
 AbstractProperty (AbstractProperty &&)=default
 
AbstractPropertyoperator= (const AbstractProperty &)=default
 
AbstractPropertyoperator= (AbstractProperty &&)=default
 
virtual bool isEqualTo (const AbstractProperty &other) const =0
 The base class equals() method will have already done a lot of checking prior to calling this method, including verifying that both values are non-default and that the value lists are the same size; the concrete property need only compare the values. More...
 
virtual void readFromXMLElement (SimTK::Xml::Element &propertyElement, int versionNumber)=0
 Read in a new value for this property from the XML element propertyElement. More...
 
virtual void writeToXMLElement (SimTK::Xml::Element &propertyElement) const =0
 Output a serialized representation of this property by writing its value to the given XML property element. More...
 
virtual int getNumValues () const =0
 How may values are currently stored in this property? If this is an object property you can use this with getValueAsObject() to iterate over the contained objects. More...
 
virtual void clearValues ()=0
 If the concrete property allows it, clear the value list. More...
 
virtual bool isAcceptableObjectTag (const std::string &objectTypeTag) const =0
 Return true if the given string is the XML tag name for one of the Object-derived types that is allowed by this property. More...
 

Detailed Description

An abstract property is a serializable (name,value) pair, for which we do not know the type of the value.

Values may be simple types like int or string, or may be serializable objects derived from the OpenSim Object class.

AbstractProperty is an abstract base class that provides the functionality common to all properties that does not involve knowledge of the value type. Property<T> derives from AbstractProperty to represent properties where the type is known.

See also
Property, Object
Author
Cassidy Kelly, Ajay Seth, Michael Sherman

Constructor & Destructor Documentation

◆ ~AbstractProperty()

virtual OpenSim::AbstractProperty::~AbstractProperty ( )
inlinevirtual

Return all heap space used by this property.

◆ AbstractProperty() [1/4]

OpenSim::AbstractProperty::AbstractProperty ( )
protected

◆ AbstractProperty() [2/4]

OpenSim::AbstractProperty::AbstractProperty ( const std::string &  name,
const std::string &  comment 
)
protected

◆ AbstractProperty() [3/4]

OpenSim::AbstractProperty::AbstractProperty ( const AbstractProperty )
protecteddefault

◆ AbstractProperty() [4/4]

OpenSim::AbstractProperty::AbstractProperty ( AbstractProperty &&  )
protecteddefault

Member Function Documentation

◆ appendValue()

template<class T >
int OpenSim::AbstractProperty::appendValue ( const T &  value)
inline

Append a new value of type T to the end of the list of values currently contained in this property.

This works only if the underlying concrete property is of type T, the property holds a variable-length list, and the list isn't already of maximum size.

Returns
The index assigned to this value in the list.

References OpenSim::Property< T >::appendValue(), OpenSim::Property_Deprecated::getNumValues(), OpenSim::Property_Deprecated::getValueArray(), and OpenSim::Property_Deprecated::isArrayProperty().

◆ assign()

virtual void OpenSim::AbstractProperty::assign ( const AbstractProperty that)
pure virtual

Assign (copy) property that to this object.

Implemented in OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, OpenSim::PropertyDblVec_< M >, OpenSim::PropertyDblVec_< 2 >, OpenSim::PropertyDblVec_< 3 >, OpenSim::PropertyDblArray, OpenSim::PropertyObj, OpenSim::PropertyIntArray, OpenSim::PropertyBoolArray, OpenSim::PropertyStrArray, OpenSim::PropertyStr, OpenSim::PropertyBool, OpenSim::PropertyInt, and OpenSim::PropertyDbl.

Referenced by OpenSim::Property< T >::getTypeName().

◆ clear()

void OpenSim::AbstractProperty::clear ( )

Empty the value list for this property; fails if zero is not an allowable size for this property.

Referenced by OpenSim::Property< T >::setValue().

◆ clearValues()

virtual void OpenSim::AbstractProperty::clearValues ( )
protectedpure virtual

◆ clone()

virtual AbstractProperty* OpenSim::AbstractProperty::clone ( ) const
pure virtual

Return a new instance of this concrete property object, containing new copies of this property's values.

The new property object is allocated on the heap and it is up to the caller to delete it when done.

Implemented in OpenSim::Property< T >, OpenSim::Property_Deprecated, OpenSim::PropertyDblVec_< M >, OpenSim::PropertyDblVec_< 2 >, OpenSim::PropertyDblVec_< 3 >, OpenSim::PropertyDblArray, OpenSim::PropertyIntArray, OpenSim::PropertyBoolArray, OpenSim::PropertyStrArray, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, OpenSim::PropertyObj, OpenSim::PropertyTransform, OpenSim::PropertyBool, OpenSim::PropertyInt, OpenSim::PropertyStr, and OpenSim::PropertyDbl.

◆ empty()

bool OpenSim::AbstractProperty::empty ( ) const
inline

Return true if this property's value list is currently empty.

◆ equals()

bool OpenSim::AbstractProperty::equals ( const AbstractProperty other) const
inline

Compare this property with another one; this is primarily used for testing.

The properties must be of the identical concrete type, and their names and other base class attributes must be identical (including the comment). If they both have the "use default" flag set then we consider the values identical without looking. Otherwise, we delegate to the concrete property to determine if the values are equal; the meaning is determined by the concrete property depending on its type. Floating point values should be compared to a tolerance, and should be considered equal if both are the same infinity or both are NaN (the latter in contrast to normal IEEE floating point behavior, where NaN!=NaN).

References getComment(), getMaxListSize(), getMinListSize(), getName(), and size().

◆ getComment()

const std::string& OpenSim::AbstractProperty::getComment ( ) const
inline

Get the comment associated with this property.

Referenced by equals().

◆ getMaxListSize()

int OpenSim::AbstractProperty::getMaxListSize ( ) const
inline

Get the maximum number of values allowed in this property's value list.

Will be unlimited for list properties (unless explicitly changed), and one for optional and one-value properties.

Referenced by OpenSim::Property< T >::adoptAndAppendValue(), OpenSim::Property< T >::appendValue(), equals(), OpenSim::Property< T >::getTypeName(), OpenSim::Property< T >::getValue(), OpenSim::Property< T >::setValue(), and OpenSim::Property< T >::updValue().

◆ getMinListSize()

int OpenSim::AbstractProperty::getMinListSize ( ) const
inline

Get the minimum number of values allowed in this property's value list.

Will be zero for optional properties, zero for list properties (unless explicitly changed), and one for one-value properties.

Referenced by equals(), OpenSim::Property< T >::getTypeName(), and OpenSim::Property< T >::setValue().

◆ getName()

◆ getNumValues()

virtual int OpenSim::AbstractProperty::getNumValues ( ) const
protectedpure virtual

How may values are currently stored in this property? If this is an object property you can use this with getValueAsObject() to iterate over the contained objects.

Implemented in OpenSim::PropertyDblVec_< M >, OpenSim::PropertyDblVec_< 2 >, OpenSim::PropertyDblVec_< 3 >, OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyDblArray, OpenSim::PropertyIntArray, OpenSim::PropertyBoolArray, OpenSim::PropertyStrArray, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, and OpenSim::PropertyObjArray< Control >.

Referenced by OpenSim::Property< T >::adoptAndAppendValue(), OpenSim::Property< T >::appendValue(), OpenSim::Property< T >::findIndex(), OpenSim::Property< T >::getTypeName(), and OpenSim::Property< T >::setValue().

◆ getTypeName()

virtual std::string OpenSim::AbstractProperty::getTypeName ( ) const
pure virtual

This returns a string representation of this property's value type which will be the same as T::getClassName() for Object-derived types T, and some reasonably nice name for simple types, including at least "bool", "int", "double", "string", "Vec3", "Vector", and "Transform".

Implemented in OpenSim::Property< T >, OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, OpenSim::PropertyDblVec_< M >, OpenSim::PropertyDblVec_< 2 >, OpenSim::PropertyDblVec_< 3 >, OpenSim::PropertyDblArray, OpenSim::PropertyObj, OpenSim::PropertyIntArray, OpenSim::PropertyBoolArray, OpenSim::PropertyStrArray, OpenSim::PropertyStr, OpenSim::PropertyBool, OpenSim::PropertyInt, OpenSim::PropertyTransform, and OpenSim::PropertyDbl.

Referenced by OpenSim::PropertyDblVec_< 3 >::assign(), OpenSim::PropertyObjArray< Control >::assign(), OpenSim::PropertyObjPtr< OpenSim::Function >::assign(), and OpenSim::Property< T >::getTypeName().

◆ getValue()

template<class T >
const T & OpenSim::AbstractProperty::getValue ( int  index = -1) const
inline

Return one of the values in this property as type T; this works only if the underlying concrete property stores type T and if the indexed element is present, otherwise throws an exception.

References OpenSim::Property_Deprecated::getValue(), OpenSim::Property_Deprecated::getValueArray(), and OpenSim::Property_Deprecated::isArrayProperty().

◆ getValueAsObject()

virtual const Object& OpenSim::AbstractProperty::getValueAsObject ( int  index = -1) const
pure virtual

For an object property, the values can be obtained as references to the abstract base class Object from which all the objects derive.

If the property can hold a list of values you must provide an index to select the value, otherwise it is optional but if supplied must be 0. This will throw an exception if this is not an object property, that is, if it is a simple property, because its values can't be represented as an Object in that case.

Parameters
[in]indexIf supplied must be 0 <= index < getNumValues().
Returns
const reference to the value as an Object
See also
updValueAsObject(), getValue<T>()

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, and OpenSim::PropertyObj.

Referenced by OpenSim::Property< T >::getTypeName().

◆ getValueIsDefault()

bool OpenSim::AbstractProperty::getValueIsDefault ( ) const
inline

Get the flag indicating whether the current value is just the default value for this property (in which case it doesn't need to be written out).

Referenced by OpenSim::Property< T >::getTypeName(), OpenSim::ScaleTool::isDefaultGenericModelMaker(), OpenSim::ScaleTool::isDefaultMarkerPlacer(), OpenSim::ScaleTool::isDefaultModelScaler(), and OpenSim::Object_GetClassName< SimTK::Quaternion_< SimTK::Real > >::name().

◆ isAcceptableObjectTag()

virtual bool OpenSim::AbstractProperty::isAcceptableObjectTag ( const std::string &  objectTypeTag) const
protectedpure virtual

Return true if the given string is the XML tag name for one of the Object-derived types that is allowed by this property.

If so, we expect that an element with that tag could be deserialized into a value element of this property. This always returns false for a simple property.

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, and OpenSim::PropertyObj.

Referenced by OpenSim::Property< T >::getTypeName().

◆ isEqualTo()

virtual bool OpenSim::AbstractProperty::isEqualTo ( const AbstractProperty other) const
protectedpure virtual

The base class equals() method will have already done a lot of checking prior to calling this method, including verifying that both values are non-default and that the value lists are the same size; the concrete property need only compare the values.

Implemented in OpenSim::Property_Deprecated.

Referenced by OpenSim::Property< T >::getTypeName().

◆ isListProperty()

bool OpenSim::AbstractProperty::isListProperty ( ) const
inline

This is a "list" property if its value list can contain more than one value.

This is the kind of property created by the Object::addListProperty<T> method, for any type T.

Referenced by OpenSim::Property< T >::setValue().

◆ isObjectProperty()

virtual bool OpenSim::AbstractProperty::isObjectProperty ( ) const
pure virtual

Return true if this is an "object property", meaning that its values are all concrete objects of types that ultimately derive from the OpenSim serializable base class Object.

If this returns true then it is safe to call getValueAsObject(). Otherwise this property contains only simple types like "int" or "std::string", and you'll need to know the actual type in order to access the values.

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, and OpenSim::PropertyObj.

Referenced by OpenSim::Property< T >::getTypeName().

◆ isOneObjectProperty()

bool OpenSim::AbstractProperty::isOneObjectProperty ( ) const
inline

This is a "one-object" property if it is a "one-value" property and it contains an Object-derived value.

This is the kind of property created by the Object::addProperty<T> method when T is a type derived from OpenSim's Object serializable base class. One-object properties have a special, compact representation in XML.

◆ isOneValueProperty()

bool OpenSim::AbstractProperty::isOneValueProperty ( ) const
inline

This is a "one-value" property if its value list must always contain exactly one value.

This is the kind of property created by the Object::addProperty<T> method, for any type T.

Referenced by OpenSim::Property< T >::getTypeName().

◆ isOptionalProperty()

bool OpenSim::AbstractProperty::isOptionalProperty ( ) const
inline

This is an "optional" property if its value list can contain at most one value.

This is the kind of property created by the Object::addOptionalProperty<T> method, for any type T.

◆ isSamePropertyClass()

bool OpenSim::AbstractProperty::isSamePropertyClass ( const AbstractProperty other) const
inline

Return true if the other property is an object of exactly the same concrete class as this one.

◆ isUnnamedProperty()

virtual bool OpenSim::AbstractProperty::isUnnamedProperty ( ) const
pure virtual

An unnamed property is a one-object property whose name was given as null or as the contained object's type tag.

In that case getName() will return the object type tag, and the XML representation will just be the object, with name attribute ignored if there is one.

Implemented in OpenSim::Property_Deprecated.

Referenced by OpenSim::Property< T >::getTypeName().

◆ operator=() [1/2]

AbstractProperty& OpenSim::AbstractProperty::operator= ( const AbstractProperty )
protecteddefault

◆ operator=() [2/2]

AbstractProperty& OpenSim::AbstractProperty::operator= ( AbstractProperty &&  )
protecteddefault

◆ operator==()

bool OpenSim::AbstractProperty::operator== ( const AbstractProperty other) const
inline

See the equals() method for the meaning of this operator.

◆ readFromXMLElement()

virtual void OpenSim::AbstractProperty::readFromXMLElement ( SimTK::Xml::Element &  propertyElement,
int  versionNumber 
)
protectedpure virtual

Read in a new value for this property from the XML element propertyElement.

The element is expected to have the form

<propertyName> value(s) </propertyName>

where the values may be simple (like int or double) or may be objects contained in child elements for which the object type name serves as the element tag. Note that although the XML file may contain an abbreviated representation for one-object properties, it will have been canonicalized into the above form for the purpose of reading, so concrete properties may assume the above form always.

The format for the property value (and any of its contained objects) is assumed to be the one that was in use when the given ".osim" file version number was current; if necessary the in-memory version will be updated to the now-current format.

If this is an object property, the contained objects will be asked recursively to read themselves in from the same document. However, any object that has the "file" attribute will read in its contents from that file rather than from the supplied XML document, and the version number will be taken from that file rather than the argument supplied here.

Implemented in OpenSim::Property_Deprecated.

Referenced by OpenSim::Property< T >::getTypeName().

◆ readFromXMLParentElement()

void OpenSim::AbstractProperty::readFromXMLParentElement ( SimTK::Xml::Element &  parent,
int  versionNumber 
)

Given an XML parent element expected to contain a value for this property as an immediate child element, find that property element and set the property value from it.

If no such property element can be found, the "use default value" attribute of this property will be set on return; that is not an error. However, if the property element is found but is malformed or unsuitable in some way, an exception will be thrown with a message explaining what is wrong.

◆ setAllowableListSize() [1/2]

void OpenSim::AbstractProperty::setAllowableListSize ( int  aMin,
int  aMax 
)
inline

◆ setAllowableListSize() [2/2]

void OpenSim::AbstractProperty::setAllowableListSize ( int  aNum)
inline

Require that the number of values n in the value list of this property be exactly n=aNum values.

◆ setAllPropertiesUseDefault()

void OpenSim::AbstractProperty::setAllPropertiesUseDefault ( bool  shouldUseDefault)

This method sets the "use default" flag for this property and the properties of any objects it contains to the given value.

◆ setComment()

void OpenSim::AbstractProperty::setComment ( const std::string &  aComment)
inline

Set a user-friendly comment to be associated with property.

This will be displayed in XML and in "help" output for OpenSim Objects.

Referenced by OpenSim::Object::addListProperty(), OpenSim::Object::addOptionalProperty(), and OpenSim::Object::addProperty().

◆ setName()

void OpenSim::AbstractProperty::setName ( const std::string &  name)
inline

◆ setValueAsObject()

virtual void OpenSim::AbstractProperty::setValueAsObject ( const Object obj,
int  index = -1 
)
pure virtual

Set the indicated value element to a new copy of the supplied object.

If you already have a heap-allocated object you're willing to give up and want to avoid the extra copy, use adoptValueObject().

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, and OpenSim::PropertyObj.

Referenced by OpenSim::Property< T >::getTypeName().

◆ setValueIsDefault()

◆ size()

◆ toString()

virtual std::string OpenSim::AbstractProperty::toString ( ) const
pure virtual

For relatively simple types, return the current value of this property in a string suitable for displaying to a user in the GUI (i.e., this number may be rounded and not an exact representation of the actual value being used).

Objects just return something like "(Object)". For Propertys, This function calls toStringForDisplay() with precision = 6.

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyDblVec_< M >, OpenSim::PropertyDblVec_< 2 >, OpenSim::PropertyDblVec_< 3 >, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, OpenSim::PropertyDblArray, OpenSim::PropertyObj, OpenSim::PropertyIntArray, OpenSim::PropertyStrArray, OpenSim::PropertyBoolArray, OpenSim::PropertyTransform, OpenSim::PropertyStr, OpenSim::PropertyBool, OpenSim::PropertyDbl, and OpenSim::PropertyInt.

Referenced by OpenSim::Property< T >::getTypeName().

◆ toStringForDisplay()

virtual std::string OpenSim::AbstractProperty::toStringForDisplay ( const int  precision) const
inlinevirtual

For relatively simple types, return the current value of this property in a string suitable for displaying to a user in the GUI (i.e., this number may be rounded and not an exact representation of the actual value being used).

Objects just return something like "(Object)". This differs from toString() as it has an argument, precision, for controlling the number of digits printed to string for floats. If this function is not overridden in a derived class, this function uses toString() and the precision argument is ignored. For Propertys, in general, this means that floats will be represented with the number of significant digits denoted by the precision argument, and the default formatting of stringstream determines whether or not exponential notation is used.

Referenced by OpenSim::Property< T >::getTypeName().

◆ updValue()

template<class T >
T & OpenSim::AbstractProperty::updValue ( int  index = -1)
inline

Return a writable reference to one of the values in this property as type T; this works only if the underlying concrete property is actually of type T and the indexed element is present.

Otherwise it throws an exception.

References OpenSim::Property_Deprecated::getValue(), OpenSim::Property_Deprecated::getValueArray(), OpenSim::Property_Deprecated::isArrayProperty(), and OpenSim::Property< T >::updValue().

◆ updValueAsObject()

virtual Object& OpenSim::AbstractProperty::updValueAsObject ( int  index = -1)
pure virtual

Get writable access to an existing object value.

Note that you can't use this to install a different concrete object; see setValueAsObject() if you want to do that.

Parameters
[in]indexIf supplied must be 0 <= index < getNumValues().
Returns
writable reference to the value as an Object
See also
getValueAsObject(), updValue<T>()

Implemented in OpenSim::Property_Deprecated, OpenSim::PropertyObjPtr< T >, OpenSim::PropertyObjPtr< OpenSim::Function >, OpenSim::PropertyObjArray< T >, OpenSim::PropertyObjArray< AbstractPathPoint >, OpenSim::PropertyObjArray< ExternalForce >, OpenSim::PropertyObjArray< Bhargava2004MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< ContactGeometry >, OpenSim::PropertyObjArray< Umberger2010MuscleMetabolicsProbe_MetabolicMuscleParameter >, OpenSim::PropertyObjArray< Coordinate >, OpenSim::PropertyObjArray< OpenSim::Constraint >, OpenSim::PropertyObjArray< OpenSim::ObjectGroup >, OpenSim::PropertyObjArray< OpenSim::Actuator >, OpenSim::PropertyObjArray< WrapObject >, OpenSim::PropertyObjArray< IKTask >, OpenSim::PropertyObjArray< Force >, OpenSim::PropertyObjArray< MocoWeight >, OpenSim::PropertyObjArray< Joint >, OpenSim::PropertyObjArray< MarkerPair >, OpenSim::PropertyObjArray< Scale >, OpenSim::PropertyObjArray< OpenSim::Force >, OpenSim::PropertyObjArray< Probe >, OpenSim::PropertyObjArray< const OpenSim::Actuator >, OpenSim::PropertyObjArray< OpenSim::Muscle >, OpenSim::PropertyObjArray< Controller >, OpenSim::PropertyObjArray< ModelComponent >, OpenSim::PropertyObjArray< Function >, OpenSim::PropertyObjArray< OrientationWeight >, OpenSim::PropertyObjArray< TrackingTask >, OpenSim::PropertyObjArray< OpenSim::ControlLinearNode >, OpenSim::PropertyObjArray< Measurement >, OpenSim::PropertyObjArray< BodyScale >, OpenSim::PropertyObjArray< Marker >, OpenSim::PropertyObjArray< Analysis >, OpenSim::PropertyObjArray< Body >, OpenSim::PropertyObjArray< Constraint >, OpenSim::PropertyObjArray< Control >, and OpenSim::PropertyObj.

Referenced by OpenSim::Property< T >::getTypeName().

◆ writeToXMLElement()

virtual void OpenSim::AbstractProperty::writeToXMLElement ( SimTK::Xml::Element &  propertyElement) const
protectedpure virtual

Output a serialized representation of this property by writing its value to the given XML property element.

If the "use default value" attribute is set for this property (meaning we don't have a meaningful value for it) then you should not call this method unless you are trying to serialize the defaults. Note that this method unconditionally serializes the property; it does not check to see whether it should.

This method is not called for the special case of a one-object property, in which case only the object is written to the XML file (without the property element). In all other cases (simple property or property containing an array of objects), the format is

<propertyName> value(s) </propertyName>

and that is the only format produced here since the empty-valued property element is supplied (with the property name as its tag).

Implemented in OpenSim::Property_Deprecated.

Referenced by OpenSim::Property< T >::getTypeName().

◆ writeToXMLParentElement()

void OpenSim::AbstractProperty::writeToXMLParentElement ( SimTK::Xml::Element &  parent) const

Given an XML parent element, append a single child element representing the serialized form of this property.


The documentation for this class was generated from the following files: