AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::Parameter Class Referenceabstract

A representation of a task/kernel parameter, which can be bound using a string path or explicitly to a data node. More...

#include <Parameter.h>

+ Inheritance diagram for agx::Parameter:

Public Types

typedef Event1< Parameter * > Event
 
typedef agx::observer_ptr
< const Event > 
EventConstObserver
 
typedef agx::ref_ptr< const Event > EventConstRef
 
typedef agx::observer_ptr< Event > EventObserver
 
typedef agx::ref_ptr< Event > EventRef
 
enum  MetaType {
  SCALAR, ARRAY, POINTER, ENTITY_DATA,
  ENTITY_PTR, ENTITY_INSTANCE, UNRESOLVED
}
 Specify which kind of parameter. More...
 

Public Member Functions

void addListener (EventListener *listener)
 
 AGX_DECLARE_VECTOR_TYPES (Event)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
void bind (agx::Object *binding)
 Set explicit binding. More...
 
void bind (const agx::Path &path)
 Set parameter bind path. More...
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void commit ()=0
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
UInt8 getAccessMode () const
 
agx::Object * getAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::Object * getAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::Object * getBinding ()
 
const agx::Object * getBinding () const
 
const agx::Path & getBindPath () const
 
agx::Object * getContext ()
 
const agx::Object * getContext () const
 
template<typename T >
T * getContext ()
 
template<typename T >
const T * getContext () const
 
agxData::Format * getFormat ()
 
const agxData::Format * getFormat () const
 
agx::UInt32 getId () const
 
const agx::Name & getImplementationName () const
 
size_t getIndex () const
 
MetaType getMetaType () const
 
const agx::String & getMetaTypeName () const
 
agx::Model * getModel ()
 
const agx::Model * getModel () const
 
const agx::Name & getName () const
 
agx::Object * getNextSibling ()
 
const agx::Object * getNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
int getReferenceCount () const
 
agx::Object * getResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::Object * getResource (const agx::Path &path, agx::Model *model=nullptr) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
virtual Object * getResourceImpl (const Path &path, agx::Model *model) override
 
agx::Object * getRootContext ()
 
const agx::Object * getRootContext () const
 
agx::Task * getTask ()
 
const agx::Task * getTask () const
 
virtual agxData::Type * getType ()
 
virtual const agxData::Type * getType () const
 
virtual bool hasGlobalResult () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isRequired () const
 
bool isUnique () const
 
virtual bool isValid () const =0
 
bool needCommit ()
 
bool needUpdate ()
 
virtual void printSubtree () const
 
virtual void rebind () override
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
void set (agx::Object *binding)
 Set the parameter, alias for bind. More...
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically). More...
 
void setName (const agx::Name &name)
 Set the name of the object. More...
 
void setRequired (bool flag)
 Set if the parameter is required, default is true. More...
 
virtual void snapshot (TiXmlNode *, const String &) const
 
void unbind ()
 Remove current binding and bind path. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
virtual void update ()=0
 

Static Public Member Functions

static agx::Model * ClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting. More...
 
static Object * load (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static Object * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static Object * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting). More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Public Attributes

Event bindEvent
 
Event unbindEvent
 
Event updateEvent
 

Protected Member Functions

 Parameter (Model *model, MetaType type, const Name &name, agxData::Format *format, UInt8 accessMode, const Path &bindPath=Path())
 
virtual ~Parameter ()
 
virtual void _bind (Object *binding)=0
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

const UInt8 m_accessMode
 
ObjectObserver m_binding
 
Path m_bindPath
 
agxData::FormatRef m_format
 
size_t m_index
 
UInt8 m_metaType
 
Mutex m_mutex
 
bool m_needCommit
 
bool m_needUpdate
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
bool m_required
 
Task * m_task
 

Detailed Description

A representation of a task/kernel parameter, which can be bound using a string path or explicitly to a data node.

Definition at line 61 of file Parameter.h.

Member Typedef Documentation

Definition at line 66 of file Parameter.h.

Definition at line 62 of file Object.h.

typedef agx::ref_ptr< const Event > agx::Object::EventConstRef
inherited

Definition at line 62 of file Object.h.

Definition at line 62 of file Object.h.

Definition at line 62 of file Object.h.

Member Enumeration Documentation

Specify which kind of parameter.

Enumerator
SCALAR 
ARRAY 
POINTER 
ENTITY_DATA 
ENTITY_PTR 
ENTITY_INSTANCE 
UNRESOLVED 

Definition at line 72 of file Parameter.h.

Constructor & Destructor Documentation

agx::Parameter::Parameter ( Model *  model,
MetaType  type,
const Name &  name,
agxData::Format *  format,
UInt8  accessMode,
const Path &  bindPath = Path() 
)
protected
virtual agx::Parameter::~Parameter ( )
protectedvirtual

Member Function Documentation

void agx::Object::addListener ( EventListener *  listener)
inherited
agx::Object::AGX_DECLARE_VECTOR_TYPES ( Event  )
inherited
void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agx::Parameter::bind ( agx::Object *  binding)

Set explicit binding.

void agx::Parameter::bind ( const agx::Path &  path)

Set parameter bind path.

virtual void agx::Object::buildNavigationTree ( agxJson::Value &  eNode) const
virtualinherited
static agx::Model* agx::Parameter::ClassModel ( )
static
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
agx::String agx::Object::fullName ( ) const
inherited
agx::String agx::Object::fullPath ( ) const
inherited
Returns
path:implementation
agx::String agx::Object::fullPath ( const agx::Object *  root) const
inherited
static agx::String agx::Object::generateName ( const agx::String &  bindPath)
staticinherited
UInt8 agx::Parameter::getAccessMode ( ) const
Returns
The access mode of the parameter.

Definition at line 702 of file Parameter.h.

References m_accessMode.

static const HashSet<Object *>& agx::Object::getActiveObjects ( )
staticinherited
agx::Object* agx::Object::getAutoScopedResource ( const agx::Path &  path,
agx::Model *  model = nullptr 
)
inherited
Returns
The resource with the first matching subpath starting from this node and traversing upwards to the root.

Referenced by agx::Object::getAutoScopedResource().

const agx::Object* agx::Object::getAutoScopedResource ( const agx::Path &  path,
agx::Model *  model = nullptr 
) const
inherited
template<typename T >
T * agx::Object::getAutoScopedResource ( const agx::Path &  path)
inherited

Definition at line 428 of file Object.h.

References agx::Object::getAutoScopedResource(), and agx::Referenced::is().

template<typename T >
const T * agx::Object::getAutoScopedResource ( const agx::Path &  path) const
inherited

Definition at line 435 of file Object.h.

Object * agx::Parameter::getBinding ( )
Returns
The current parameter binding.

Definition at line 704 of file Parameter.h.

References m_binding.

const Object * agx::Parameter::getBinding ( ) const

Definition at line 705 of file Parameter.h.

References m_binding.

const Path & agx::Parameter::getBindPath ( ) const
Returns
The bind path of the parameter.

Definition at line 703 of file Parameter.h.

References m_bindPath.

T * agx::Object::getContext ( )
inherited
Returns
The parent node in the system tree.

Definition at line 373 of file Object.h.

Referenced by agxData::Value::get(), and agx::Model::getNamespace().

const T * agx::Object::getContext ( ) const
inherited

Definition at line 374 of file Object.h.

template<typename T >
T* agx::Object::getContext ( )
inherited
template<typename T >
const T* agx::Object::getContext ( ) const
inherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
static bool agx::Object::getEnableRebind ( )
staticinherited

Should rebinding be allowed? Right now a global setting.

agxData::Format * agx::Parameter::getFormat ( )
Returns
The parameter format.

Definition at line 700 of file Parameter.h.

References m_format.

const agxData::Format * agx::Parameter::getFormat ( ) const

Definition at line 701 of file Parameter.h.

References m_format.

UInt32 agx::Object::getId ( ) const
inherited
Returns
The global object id.

Definition at line 370 of file Object.h.

Referenced by agxData::EntityStorage::indexToId().

const agx::Name& agx::Object::getImplementationName ( ) const
inherited
Returns
The implementation name of the model. Alias for getModel()->getImplementationName()
size_t agx::Parameter::getIndex ( ) const
Returns
The parameter index.

Definition at line 697 of file Parameter.h.

References m_index.

Parameter::MetaType agx::Parameter::getMetaType ( ) const
Returns
The parameter meta type.

Definition at line 698 of file Parameter.h.

References m_metaType.

const agx::String& agx::Parameter::getMetaTypeName ( ) const
Returns
The parameter meta type as a string.
Model * agx::Object::getModel ( )
inherited
Returns
The object model.

Definition at line 371 of file Object.h.

const Model * agx::Object::getModel ( ) const
inherited

Definition at line 372 of file Object.h.

const Name & agx::Object::getName ( ) const
inherited
Returns
Then name of the object.

Definition at line 369 of file Object.h.

Referenced by agxData::Value::get(), agxData::EntityStorage::get(), agxData::FormatBinding< T >::getFormat(), and agxData::EntityPtr::operator()().

agx::Object* agx::Object::getNextSibling ( )
inherited
Returns
The next sibling with identical name.
const agx::Object* agx::Object::getNextSibling ( ) const
inherited
agx::Path agx::Object::getPath ( const agx::Object *  root) const
inherited
Returns
A relative path from a specified root
Parameters
rootA node along the parent path from this object.
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
agx::Object* agx::Object::getResource ( const agx::Path &  path,
agx::Model *  model = nullptr 
)
inherited
Returns
A resource in the subtree below this object.

Referenced by agx::Object::getResource().

const agx::Object* agx::Object::getResource ( const agx::Path &  path,
agx::Model *  model = nullptr 
) const
inherited
template<typename T >
T * agx::Object::getResource ( const agx::Path &  path)
inherited

Definition at line 414 of file Object.h.

References agx::Object::getResource(), and agx::Referenced::is().

template<typename T >
const T * agx::Object::getResource ( const agx::Path &  path) const
inherited

Definition at line 421 of file Object.h.

virtual Object* agx::Parameter::getResourceImpl ( const Path &  path,
agx::Model *  model 
)
overridevirtual
agx::Object* agx::Object::getRootContext ( )
inherited
Returns
The root context.
const agx::Object* agx::Object::getRootContext ( ) const
inherited
Task * agx::Parameter::getTask ( )
Returns
The task in which the parameter list contain this parameter.

Definition at line 695 of file Parameter.h.

References m_task.

const Task * agx::Parameter::getTask ( ) const

Definition at line 696 of file Parameter.h.

References m_task.

agxData::Type * agx::Parameter::getType ( )
virtual
Returns
The parameter type.

Reimplemented in agx::ArrayParameter, and agx::UnresolvedParameter.

Definition at line 706 of file Parameter.h.

References m_format.

const agxData::Type * agx::Parameter::getType ( ) const
virtual

Reimplemented in agx::ArrayParameter, and agx::UnresolvedParameter.

Definition at line 707 of file Parameter.h.

References m_format.

virtual bool agx::Parameter::hasGlobalResult ( ) const
virtual
Returns
True if the parameter has a global result

Reimplemented in agx::EntityDataParameter, and agx::ArrayParameter.

bool agx::Object::hasListener ( EventListener *  listener)
inherited
bool agx::Object::hasParent ( const agx::Object *  node) const
inherited
Returns
True if the specified node is located somewhere in the path above the object.
template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agx::Parameter::isRequired ( ) const
Returns
True if the parameter is required.

Definition at line 699 of file Parameter.h.

References m_required.

Referenced by agx::PointerParameter::get().

bool agx::Object::isUnique ( ) const
inherited

Definition at line 375 of file Object.h.

virtual bool agx::Parameter::isValid ( ) const
pure virtual
T * agx::Object::load ( TiXmlElement *  eObject,
Device *  device 
)
staticinherited

Definition at line 393 of file Object.h.

Referenced by agx::Object::load().

template<typename T >
static T* agx::Object::load ( TiXmlElement *  eObject,
Device *  device 
)
staticinherited
T * agx::Object::load ( const String &  path,
Device *  device,
const String &  type = "",
size_t  instance = 0 
)
staticinherited

Definition at line 379 of file Object.h.

References agx::Object::load().

T * agx::Object::load ( const String &  path,
Device *  device,
const String &  type,
const String &  attribute,
const String &  value 
)
staticinherited

Definition at line 386 of file Object.h.

References agx::Object::load().

static void agx::Object::load ( const String &  path,
Device *  device,
ObjectPtrVector &  loadedObjects 
)
staticinherited
template<typename T >
static T* agx::Object::load ( const String &  path,
Device *  device,
const String &  type = "",
size_t  instance = 0 
)
staticinherited
template<typename T >
static T* agx::Object::load ( const String &  path,
Device *  device,
const String &  type,
const String &  attribute,
const String &  value 
)
staticinherited
bool agx::Parameter::needCommit ( )

Definition at line 709 of file Parameter.h.

References m_needCommit.

bool agx::Parameter::needUpdate ( )

Definition at line 708 of file Parameter.h.

References m_needUpdate.

static TiXmlDocument agx::Object::openDocument ( const String &  path)
staticinherited
virtual void agx::Object::printSubtree ( ) const
inlinevirtualinherited

Reimplemented in agx::Component.

Definition at line 254 of file Object.h.

virtual void agx::Parameter::rebind ( )
overridevirtual

Reimplemented from agx::Object.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

void agx::Object::removeListener ( EventListener *  listener)
inherited
virtual void agx::Object::save ( TiXmlElement *  ) const
inlinevirtualinherited

Reimplemented in agx::Clock.

Definition at line 105 of file Object.h.

void agx::Parameter::set ( agx::Object *  binding)

Set the parameter, alias for bind.

virtual void agx::Object::setContext ( agx::Object *  context)
virtualinherited

Reimplemented in agx::Task, and agxData::FunctionValue.

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

static void agx::Object::setEnableRebind ( bool  flag)
staticinherited

Sets if rebinding of objects should be allowed (Right now a global setting).

Allowing it when adding larger parts to the system tree might hit performance, so it might be smarter to disable it first, then add, and then enable again.

void agx::Object::setId ( UInt32  id)
inherited
void agx::Object::setModel ( agx::Model *  model)
inherited

Set the object model (handled automatically).

void agx::Object::setName ( const agx::Name &  name)
inherited

Set the name of the object.

void agx::Parameter::setRequired ( bool  flag)

Set if the parameter is required, default is true.

virtual void agx::Object::snapshot ( TiXmlNode *  ,
const String &   
) const
inlinevirtualinherited

Reimplemented in agx::Component.

Definition at line 106 of file Object.h.

void agx::Parameter::unbind ( )

Remove current binding and bind path.

Referenced by agx::ScalarParameter::set().

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Event agx::Parameter::bindEvent

Definition at line 67 of file Parameter.h.

const UInt8 agx::Parameter::m_accessMode
protected

Definition at line 203 of file Parameter.h.

Referenced by getAccessMode().

ObjectObserver agx::Parameter::m_binding
protected

Definition at line 202 of file Parameter.h.

Referenced by agx::PointerParameter::get(), getBinding(), and agx::ScalarParameter::set().

Path agx::Parameter::m_bindPath
protected

Definition at line 201 of file Parameter.h.

Referenced by getBindPath().

agxData::FormatRef agx::Parameter::m_format
protected
size_t agx::Parameter::m_index
protected

Definition at line 199 of file Parameter.h.

Referenced by getIndex().

UInt8 agx::Parameter::m_metaType
protected

Definition at line 205 of file Parameter.h.

Referenced by getMetaType().

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

bool agx::Parameter::m_needCommit
protected

Definition at line 207 of file Parameter.h.

Referenced by needCommit().

bool agx::Parameter::m_needUpdate
protected

Definition at line 206 of file Parameter.h.

Referenced by needUpdate().

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

bool agx::Parameter::m_required
protected

Definition at line 204 of file Parameter.h.

Referenced by agx::ArrayParameter::get(), and isRequired().

Task* agx::Parameter::m_task
protected

Definition at line 198 of file Parameter.h.

Referenced by getTask().

Event agx::Parameter::unbindEvent

Definition at line 68 of file Parameter.h.

Event agx::Parameter::updateEvent

Definition at line 69 of file Parameter.h.


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