DynamicObject Class Reference

Dynamic extension of class attributes. More...

#include <DynamicObject.h>

Inheritance diagram for DynamicObject:

Inheritance graph

List of all members.

Public Member Functions

virtual void merge (const DynamicObject *pObject)=0
virtual void adoptiveMerge (DynamicObject *pObject)=0
template<class T>
bool setAttribute (const std::string &name, const T &value)
virtual bool adoptAttribute (const std::string &name, DataVariant &value)=0
template<class T>
bool setAttributeByPath (const std::string &path, const T &value)
virtual bool adoptAttributeByPath (const std::string &path, DataVariant &value)=0
template<class T>
bool setAttributeByPath (const std::string pComponents[], const T &value)
virtual bool adoptAttributeByPath (const std::string pComponents[], DataVariant &value)=0
virtual const DataVariantgetAttribute (const std::string &name) const =0
virtual DataVariantgetAttribute (const std::string &name)=0
virtual const DataVariantgetAttributeByPath (const std::string &path) const =0
virtual DataVariantgetAttributeByPath (const std::string &path)=0
virtual const DataVariantgetAttributeByPath (const std::string pComponents[]) const =0
virtual DataVariantgetAttributeByPath (const std::string pComponents[])=0
virtual void getAttributeNames (std::vector< std::string > &attributeNames) const =0
virtual unsigned int getNumAttributes () const =0
virtual const DataVariantfindFirstOf (const QRegExp &name, const QRegExp &value) const =0
virtual DataVariantfindFirstOf (const QRegExp &name, const QRegExp &value)=0
virtual bool removeAttribute (const std::string &name)=0
virtual bool removeAttributeByPath (const std::string pComponents[])=0
virtual bool removeAttributeByPath (const std::string &path)=0
virtual bool compare (const DynamicObject *pObject) const =0
virtual void clear ()=0

Static Public Member Functions

static const std::string & signalAttributeAdded ()
static const std::string & signalAttributeModified ()
static const std::string & signalAttributeRemoved ()
static const std::string & signalCleared ()

Protected Member Functions

virtual ~DynamicObject ()


Detailed Description

Dynamic extension of class attributes.

Dynamic Object refers to a class that allows attributes to be added during runtime. Many classes extend the Dynamic Object to provide future support for new attributes without changing the class specification.

This subclass of Subject will notify upon the following conditions:

Definition at line 41 of file DynamicObject.h.


Constructor & Destructor Documentation

virtual DynamicObject::~DynamicObject (  )  [protected, virtual]

This should be destroyed by calling ObjectFactory::destroyObject.

Definition at line 530 of file DynamicObject.h.


Member Function Documentation

static const std::string& DynamicObject::signalAttributeAdded (  )  [static]

Emitted just after a new attribute is added with boost::any<std::pair<std::string, DataVariant*> > containing the attribute name and value.

Definition at line 49 of file DynamicObject.h.

static const std::string& DynamicObject::signalAttributeModified (  )  [static]

Emitted just after an existing attribute is modified with boost::any<std::pair<std::string, DataVariant*> > containing the attribute name and the new value.

Definition at line 56 of file DynamicObject.h.

static const std::string& DynamicObject::signalAttributeRemoved (  )  [static]

Emitted just before an existing attribute is removed with boost::any<std::pair<std::string, DataVariant*> > containing the name and value of the attribute that will be removed. The attribute value is guaranteed to be valid when the signal is emitted.

Definition at line 64 of file DynamicObject.h.

static const std::string& DynamicObject::signalCleared (  )  [static]

Emitted just before the dynamic object is cleared. All existing attribute values are guaranteed to be valid when the signal is emitted.

Definition at line 70 of file DynamicObject.h.

virtual void DynamicObject::merge ( const DynamicObject pObject  )  [pure virtual]

Sets attributes from those of another dynamic object.

This method parses the given object's attributes, adding them to or setting them in this object. Any existing attributes that are not contained in the given object are not removed.

Parameters:
pObject The object from which to set this object's attributes. Cannot be NULL.
Subject Notifications:
This method will notify Subject::signalModified once for each attribute which gets merged. The parameters will depend on the attribute modified.
See also:
setAttribute()

virtual void DynamicObject::adoptiveMerge ( DynamicObject pObject  )  [pure virtual]

Sets attributes from those of another dynamic object.

This method parses the given object's attributes, adopting them into the destination object. Any existing attributes that are not contained in the given object are not removed. The attributes of the given dynamic object will be modified in an undefined manner.

This method is intended for use when the given object will be discarded after being merged into the destination object and can be much faster than using the merge() method which sets the attributes rather than adopting them.

Parameters:
pObject The object from which to adopt into this object's attributes. Cannot be NULL.
Subject Notifications:
This method will notify Subject::signalModified once for each attribute which gets adopted. The parameters will depend on the attribute modified.
See also:
adoptAttribute()

template<class T>
bool DynamicObject::setAttribute ( const std::string &  name,
const T &  value 
)

Creates a new attribute or sets an existing dynamic attribute.

This method is preferred to adoptAttribute() unless you are passing an already constructed DataVariant in which case, adoptAttribute() will be faster because it avoids a deep copy.

Parameters:
name The name of the attribute to set the value. If an attribute with the given name does not exist, an attribute is added.
value The attribute's value.
Returns:
Returns true if the attributes was successfully created or set, otherwise false.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
adoptAttribute()

Definition at line 138 of file DynamicObject.h.

virtual bool DynamicObject::adoptAttribute ( const std::string &  name,
DataVariant value 
) [pure virtual]

Creates a new attribute or sets an existing dynamic attribute.

This method should not be used; generally setAttribute() is preferred. This method and setAttribute() have identical performance characteristics and setAttribute() is easier to call. This method is faster than setAttribute() though if you have an already constructed DataVariant and is preferred to setAttribute() in this case.

Parameters:
name The name of the attribute to set the value. If an attribute with the given name does not exist, an attribute is added.
value A variant holding the attribute's value. On return, this will contain the value previously stored in the DynamicObject. If the value did not previously exist in the DynamicObject, then this will contain an invalid DataVariant.
Returns:
Returns true if the attributes was successfully created or set, otherwise false.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
setAttribute()

template<class T>
bool DynamicObject::setAttributeByPath ( const std::string &  path,
const T &  value 
)

Sets the value within the DynamicObject hierarchy as described in the path.

This method will create DynamicObjects as needed to set the value. This method is preferred to adoptAttributeByPath() unless you are passing an already constructed DataVariant in which case, adoptAttributeByPath() will be faster because it avoids a deep copy.

Parameters:
path The path of names within names for the DynamicObjects, separated by '/'. A slash in the name can be represented by escaping the slash with another slash (e.g. '//'). If the path ends in a single slash, it will be ignored.
value The value to set into the DynamicObject.
Returns:
Returns true if the operation was a success, false otherwise. This method will fail if any object along the path already exists but is not a DynamicObject.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
adoptAttributeByPath()

Definition at line 198 of file DynamicObject.h.

virtual bool DynamicObject::adoptAttributeByPath ( const std::string &  path,
DataVariant value 
) [pure virtual]

Sets the value within the DynamicObject hierarchy as described in the path.

This method should not be used; generally setAttributeByPath() is preferred. This method and setAttributeByPath() have identical performance characteristics and setAttributeByPath() is easier to call. This method is faster than setAttributeByPath() though if you have an already constructed DataVariant and is preferred to setAttributeByPath() in this case.

Parameters:
path The path of names within names for the DynamicObjects, separated by '/'. A slash in the name can be represented by escaping the slash with another slash (e.g. '//'). If the path ends in a single slash, it will be ignored.
value The value to set into the DynamicObject. On return, this will contain the value previously stored in the DynamicObject. If the value did not previously exist in the DynamicObject, then this will contain an invalid DataVariant.
Returns:
Returns true if the operation was a success, false otherwise. This method will fail if any object along the path already exists but is not a DynamicObject.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
setAttributeByPath()

template<class T>
bool DynamicObject::setAttributeByPath ( const std::string  pComponents[],
const T &  value 
)

Sets the value within the DynamicObject hierarchy as described in the path.

This method will create DynamicObjects as needed to set the value. This method is preferred to adoptAttributeByPath() unless you are passing an already constructed DataVariant in which case, adoptAttributeByPath() will be faster because it avoids a deep copy.

Parameters:
pComponents An array of path components to the desired object as std::strings. Must end with END_METADATA_NAME.
value The value to set into the DynamicObject.
Returns:
Returns true if the operation was a success, false otherwise. This method will fail if any object along the path already exists but is not a DynamicObject.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
adoptAttributeByPath()

Definition at line 260 of file DynamicObject.h.

virtual bool DynamicObject::adoptAttributeByPath ( const std::string  pComponents[],
DataVariant value 
) [pure virtual]

Sets the value within the DynamicObject hierarchy as described in the path.

This method should not be used; generally setAttributeByPath() is preferred. This method and setAttributeByPath() have identical performance characteristics and setAttributeByPath() is easier to call. This method is faster than setAttributeByPath() though if you have an already constructed DataVariant and is preferred to setAttributeByPath() in this case.

Parameters:
pComponents An array of path components to the desired object as std::strings. Must end with END_METADATA_NAME.
value The value to set into the DynamicObject. On return, this will contain the value previously stored in the DynamicObject. If the value did not previously exist in the DynamicObject, then this will contain an invalid DataVariant.
Returns:
Returns true if the operation was a success, false otherwise. This method will fail if any object along the path already exists but is not a DynamicObject.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
setAttributeByPath()

virtual const DataVariant& DynamicObject::getAttribute ( const std::string &  name  )  const [pure virtual]

Returns an attribute value.

Parameters:
name The name of the attribute for which to get the value.
Returns:
A variant holding the attributes value. The variant will be invalid if the attribute did not exist.
See also:
DataVariant::isValid()

virtual DataVariant& DynamicObject::getAttribute ( const std::string &  name  )  [pure virtual]

Returns an attribute value.

Parameters:
name The name of the attribute for which to get the value.
Returns:
A variant holding the attributes value. The variant will be invalid if the attribute did not exist.
See also:
DataVariant::isValid()

virtual const DataVariant& DynamicObject::getAttributeByPath ( const std::string &  path  )  const [pure virtual]

Get the value within the DynamicObject hierarchy as described in the path.

Parameters:
path The path of names within names for the DynamicObjects, separated by '/'. A slash in the name can be represented by escaping the slash with another slash (e.g. '//'). If the path ends in a single slash, it will be ignored.
Returns:
A variant holding the attributes value. The variant will be empty if the attribute did not exist.

virtual DataVariant& DynamicObject::getAttributeByPath ( const std::string &  path  )  [pure virtual]

Get the value within the DynamicObject hierarchy as described in the path.

Parameters:
path The path of names within names for the DynamicObjects, separated by '/'. A slash in the name can be represented by escaping the slash with another slash (e.g. '//'). If the path ends in a single slash, it will be ignored.
Returns:
A variant holding the attributes value. The variant will be empty if the attribute did not exist.

virtual const DataVariant& DynamicObject::getAttributeByPath ( const std::string  pComponents[]  )  const [pure virtual]

Get the value within the DynamicObject hierarchy as described in the path.

Parameters:
pComponents An array of path components to the desired object as std::strings. Must end with END_METADATA_NAME.
Returns:
A variant holding the attributes value. The variant will be empty if the attribute did not exist.

virtual DataVariant& DynamicObject::getAttributeByPath ( const std::string  pComponents[]  )  [pure virtual]

Get the value within the DynamicObject hierarchy as described in the path.

Parameters:
pComponents An array of path components to the desired object as std::strings. Must end with END_METADATA_NAME.
Returns:
A variant holding the attributes value. The variant will be empty if the attribute did not exist.

virtual void DynamicObject::getAttributeNames ( std::vector< std::string > &  attributeNames  )  const [pure virtual]

Retrieves the names of all attributes in the object.

Parameters:
attributeNames A vector of strings that is populated with the attribute names.
See also:
getNumAttributes()

getAttribute()

virtual unsigned int DynamicObject::getNumAttributes (  )  const [pure virtual]

Retrieves the total number of attributes in the object.

Returns:
The number of attributes in the object.
See also:
getAttributeNames()

virtual const DataVariant& DynamicObject::findFirstOf ( const QRegExp &  name,
const QRegExp &  value 
) const [pure virtual]

Searches the object for an attribute with a given name and/or value.

Warning:
This method only searches this object's attributes and not any attributes of a child DynamicObject.
Parameters:
name The name of the attribute for which to search, which can be a fixed string or any regular expression supported by QRegExp. If name is empty, then the first attribute found with the given value is returned.
value The value of the attribute for which to search, which can be a fixed string or any regular expression supported by QRegExp. If value is empty, then the first attribute found with the given name is returned.
Returns:
Returns a const reference to the first attribute found with the given name and/or value. A const reference to an invalid value is returned if both name and value are empty, or if this object does not have an attribute with the given name and/or value.
See also:
findFirstOf(const QRegExp&, const QRegExp&)

virtual DataVariant& DynamicObject::findFirstOf ( const QRegExp &  name,
const QRegExp &  value 
) [pure virtual]

Searches the object for an attribute with a given name and/or value.

Warning:
This method only searches this object's attributes and not any attributes of a child DynamicObject.
Parameters:
name The name of the attribute for which to search, which can be a fixed string or any regular expression supported by QRegExp. If name is empty, then the first attribute found with the given value is returned.
value The value of the attribute for which to search, which can be a fixed string or any regular expression supported by QRegExp. If value is empty, then the first attribute found with the given name is returned.
Returns:
Returns a non-const reference to the first attribute found with the given name and/or value. A non-const reference to an invalid value is returned if both name and value are empty, or if this object does not have an attribute with the given name and/or value.
See also:
findFirstOf(const QRegExp&, const QRegExp&) const

virtual bool DynamicObject::removeAttribute ( const std::string &  name  )  [pure virtual]

Removes an attribute from the object.

Parameters:
name The name of the attribute to remove.
Returns:
Returns true if the attribute was was successfully removed from the object, otherwise false.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
clear()

virtual bool DynamicObject::removeAttributeByPath ( const std::string  pComponents[]  )  [pure virtual]

Removes an attribute from the object.

Parameters:
pComponents An array of path components to the desired object as std::strings. Must end with END_METADATA_NAME.
Returns:
Returns true if the attribute was was successfully removed from the object, otherwise false.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
clear()

virtual bool DynamicObject::removeAttributeByPath ( const std::string &  path  )  [pure virtual]

Removes an attribute from the object.

Parameters:
path The path of names within names for the DynamicObjects, separated by '/'. A slash in the name can be represented by escaping the slash with another slash (e.g. '//'). If the path ends in a single slash, it will be ignored.
Returns:
Returns true if the attribute was was successfully removed from the object, otherwise false.
Subject Notifications:
This method will notify Subject::signalModified.
See also:
clear()

virtual bool DynamicObject::compare ( const DynamicObject pObject  )  const [pure virtual]

Compares all attributes in this DynamicObject with those of another DynamicObject.

Warning:
Based on the number of attributes present in the DynamicObject, calling this method could be time intensive.
Parameters:
pObject The DynamicObject with which to compare attributes in this DynamicObject. This method does nothing and returns false if NULL is passed in.
Returns:
Returns true if all attributes in pObject are present and have the same values as the attributes in this DynamicObject; otherwise returns false.

virtual void DynamicObject::clear (  )  [pure virtual]

Erases all attributes in the object.

Subject Notifications:
This method will notify Subject::signalModified.
See also:
remove()


Software Development Kit - Opticks 4.9.0 Build 16218