API 4.4.1-2022-10-19-2c4045e59
For MATLAB, Python, Java, and C++ users
OpenSim::PropertyObjArray< T > Class Template Reference

Class PropertyObjArray extends class Property. More...

+ Inheritance diagram for OpenSim::PropertyObjArray< T >:

Public Member Functions

 PropertyObjArray (const std::string &aName="", const ArrayPtrs< T > &aArray=ArrayPtrs< T >())
 
 PropertyObjArray (const PropertyObjArray< T > &aProperty)
 
bool isArrayProperty () const override
 Return true if this is an array property. More...
 
PropertyObjArrayclone () const override
 Return a new instance of this concrete property object, containing new copies of this property's values. More...
 
int getNumValues () const override
 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...
 
bool isObjectProperty () const override
 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...
 
bool isAcceptableObjectTag (const std::string &objectTypeTag) const override
 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...
 
const ObjectgetValueAsObject (int index) const override
 For an object property, the values can be obtained as references to the abstract base class Object from which all the objects derive. More...
 
ObjectupdValueAsObject (int index) override
 Get writable access to an existing object value. More...
 
void setValueAsObject (const Object &obj, int index) override
 Set the indicated value element to a new copy of the supplied object. More...
 
PropertyObjArrayoperator= (const PropertyObjArray &aProperty)
 
void assign (const AbstractProperty &that) override
 Assign (copy) property that to this object. More...
 
bool isValidObject (const Object *obj) const override
 
std::string getTypeName () const override
 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...
 
std::string toString () const override
 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...
 
int getArraySize () const override
 
const ObjectgetValueObjPtr (int index) const override
 
void appendValue (Object *obj) override
 
void clearObjArray () override
 
void setValue (const ArrayPtrs< T > &aArray)
 
ArrayPtrs< T > & getValueObjArray ()
 
const ArrayPtrs< T > & getValueObjArray () const
 
bool operator== (const Property_Deprecated &aProperty) const override
 
virtual void setValue (bool aValue)
 
virtual void setValue (int aValue)
 
virtual void setValue (double aValue)
 
virtual void setValue (const std::string &aValue)
 
virtual void setValue (int aSize, const bool aArray[])
 
virtual void setValue (const Array< bool > &aArray)
 
virtual void setValue (int aSize, const int aArray[])
 
virtual void setValue (const Array< int > &aArray)
 
virtual void setValue (int aSize, const double aArray[])
 
virtual void setValue (const Array< double > &aArray)
 
virtual void setValue (int aSize, const std::string aArray[])
 
virtual void setValue (const Array< std::string > &aArray)
 
virtual void setValue (Object *aValue)
 
- Public Member Functions inherited from OpenSim::Property_Deprecated
 Property_Deprecated ()
 
 Property_Deprecated (PropertyType aType, const std::string &aName)
 
 Property_Deprecated (const Property_Deprecated &aProperty)
 
virtual PropertyType getPropertyType () const
 Return the enum value corresponding to the concrete property. More...
 
void setMatchName (bool aMatchName)
 By default deprecated PropertyObj properties will ignore the name associated with the read-in object. More...
 
bool getMatchName () const
 Return the value of the matchName flag for this (deprecated) property. More...
 
bool isEqualTo (const AbstractProperty &other) const override
 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) override
 Read in a new value for this property from the XML element propertyElement. More...
 
virtual void writeToXMLElement (SimTK::Xml::Element &propertyElement) const override
 Output a serialized representation of this property by writing its value to the given XML property element. More...
 
void clearValues () override
 If the concrete property allows it, clear the value list. More...
 
bool isUnnamedProperty () const override
 An unnamed property is a one-object property whose name was given as null or as the contained object's type tag. More...
 
void setNull ()
 
Property_Deprecatedoperator= (const Property_Deprecated &aProperty)
 
virtual bool operator< (const Property_Deprecated &aProperty) const
 
void setType (PropertyType aType)
 
PropertyType getType () const
 
virtual bool & getValueBool ()
 
virtual const bool & getValueBool () const
 
virtual int & getValueInt ()
 
virtual const int & getValueInt () const
 
virtual double & getValueDbl ()
 
virtual const double & getValueDbl () const
 
virtual std::string & getValueStr ()
 
virtual const std::string & getValueStr () const
 
virtual Array< bool > & getValueBoolArray ()
 
virtual const Array< bool > & getValueBoolArray () const
 
virtual Array< int > & getValueIntArray ()
 
virtual const Array< int > & getValueIntArray () const
 
virtual Array< double > & getValueDblArray ()
 
virtual const Array< double > & getValueDblArray () const
 
virtual Array< std::string > & getValueStrArray ()
 
virtual const Array< std::string > & getValueStrArray () const
 
virtual ObjectgetValueObj ()
 
virtual const ObjectgetValueObj () const
 
virtual const ObjectgetValueObjPtr () const
 
template<class T >
T & getValue ()
 
template<class T >
const T & getValue () const
 
template<class T >
Array< T > & getValueArray ()
 
template<class T >
const Array< T > & getValueArray () const
 
template<>
bool & getValue ()
 
template<>
const bool & getValue () const
 
template<>
Array< bool > & getValueArray ()
 
template<>
const Array< bool > & getValueArray () const
 
- Public Member Functions inherited from OpenSim::AbstractProperty
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 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...
 
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...
 
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...
 
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...
 

Detailed Description

template<class T = Object>
class OpenSim::PropertyObjArray< T >

Class PropertyObjArray extends class Property.

Assumes template T is a class derived from Object.

Version
1.0
Author
Frank C. Anderson

Constructor & Destructor Documentation

◆ PropertyObjArray() [1/2]

template<class T = Object>
OpenSim::PropertyObjArray< T >::PropertyObjArray ( const std::string &  aName = "",
const ArrayPtrs< T > &  aArray = ArrayPtrs<T>() 
)
inline

◆ PropertyObjArray() [2/2]

template<class T = Object>
OpenSim::PropertyObjArray< T >::PropertyObjArray ( const PropertyObjArray< T > &  aProperty)
inline

Member Function Documentation

◆ appendValue()

template<class T = Object>
void OpenSim::PropertyObjArray< T >::appendValue ( Object obj)
inlineoverridevirtual

◆ assign()

template<class T = Object>
void OpenSim::PropertyObjArray< T >::assign ( const AbstractProperty that)
inlineoverridevirtual

Assign (copy) property that to this object.

Implements OpenSim::AbstractProperty.

References OpenSim::AbstractProperty::getTypeName(), and OpenSim::PropertyObjArray< T >::getTypeName().

◆ clearObjArray()

template<class T = Object>
void OpenSim::PropertyObjArray< T >::clearObjArray ( )
inlineoverridevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ clone()

template<class T = Object>
PropertyObjArray * OpenSim::PropertyObjArray< T >::clone ( ) const
inlineoverridevirtual

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.

Implements OpenSim::Property_Deprecated.

◆ getArraySize()

template<class T = Object>
int OpenSim::PropertyObjArray< T >::getArraySize ( ) const
inlineoverridevirtual

◆ getNumValues()

template<class T = Object>
int OpenSim::PropertyObjArray< T >::getNumValues ( ) const
inlineoverridevirtual

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.

Reimplemented from OpenSim::Property_Deprecated.

References OpenSim::PropertyObjArray< T >::getArraySize().

◆ getTypeName()

template<class T = Object>
std::string OpenSim::PropertyObjArray< T >::getTypeName ( ) const
inlineoverridevirtual

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".

Implements OpenSim::Property_Deprecated.

Referenced by OpenSim::PropertyObjArray< T >::assign().

◆ getValueAsObject()

template<class T = Object>
const Object & OpenSim::PropertyObjArray< T >::getValueAsObject ( int  index) const
inlineoverridevirtual

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>()

Reimplemented from OpenSim::Property_Deprecated.

References OpenSim::Property_Deprecated::getValueObjPtr().

◆ getValueObjArray() [1/2]

template<class T = Object>
ArrayPtrs< T > & OpenSim::PropertyObjArray< T >::getValueObjArray ( )
inline

◆ getValueObjArray() [2/2]

template<class T = Object>
const ArrayPtrs< T > & OpenSim::PropertyObjArray< T >::getValueObjArray ( ) const
inline

◆ getValueObjPtr()

template<class T = Object>
const Object * OpenSim::PropertyObjArray< T >::getValueObjPtr ( int  index) const
inlineoverridevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ isAcceptableObjectTag()

template<class T = Object>
bool OpenSim::PropertyObjArray< T >::isAcceptableObjectTag ( const std::string &  objectTypeTag) const
inlineoverridevirtual

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.

Reimplemented from OpenSim::Property_Deprecated.

◆ isArrayProperty()

template<class T = Object>
bool OpenSim::PropertyObjArray< T >::isArrayProperty ( ) const
inlineoverridevirtual

Return true if this is an array property.

Reimplemented from OpenSim::Property_Deprecated.

◆ isObjectProperty()

template<class T = Object>
bool OpenSim::PropertyObjArray< T >::isObjectProperty ( ) const
inlineoverridevirtual

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.

Reimplemented from OpenSim::Property_Deprecated.

◆ isValidObject()

template<class T = Object>
bool OpenSim::PropertyObjArray< T >::isValidObject ( const Object obj) const
inlineoverridevirtual

◆ operator=()

template<class T = Object>
PropertyObjArray & OpenSim::PropertyObjArray< T >::operator= ( const PropertyObjArray< T > &  aProperty)
inline

◆ operator==()

template<class T = Object>
bool OpenSim::PropertyObjArray< T >::operator== ( const Property_Deprecated aProperty) const
inlineoverridevirtual

◆ setValue() [1/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( bool  aValue)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [2/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( const Array< bool > &  aArray)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [3/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( const Array< double > &  aArray)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [4/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( const Array< int > &  aArray)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [5/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( const Array< std::string > &  aArray)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [6/14]

template<class T = Object>
void OpenSim::PropertyObjArray< T >::setValue ( const ArrayPtrs< T > &  aArray)
inline

◆ setValue() [7/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( const std::string &  aValue)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [8/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( double  aValue)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [9/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( int  aSize,
const bool  aArray[] 
)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [10/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( int  aSize,
const double  aArray[] 
)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [11/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( int  aSize,
const int  aArray[] 
)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [12/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( int  aSize,
const std::string  aArray[] 
)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [13/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( int  aValue)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValue() [14/14]

template<class T = Object>
virtual void OpenSim::Property_Deprecated::setValue ( Object aValue)
inlinevirtual

Reimplemented from OpenSim::Property_Deprecated.

◆ setValueAsObject()

template<class T = Object>
void OpenSim::PropertyObjArray< T >::setValueAsObject ( const Object obj,
int  index 
)
inlineoverridevirtual

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().

Reimplemented from OpenSim::Property_Deprecated.

References OpenSim::Object::clone().

◆ toString()

template<class T = Object>
std::string OpenSim::PropertyObjArray< T >::toString ( ) const
inlineoverridevirtual

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.

Implements OpenSim::Property_Deprecated.

◆ updValueAsObject()

template<class T = Object>
Object & OpenSim::PropertyObjArray< T >::updValueAsObject ( int  index)
inlineoverridevirtual

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>()

Reimplemented from OpenSim::Property_Deprecated.

References OpenSim::Property_Deprecated::getValueObjPtr().


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