AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agx::Component Class Reference

A component is an object containing other objects, enabling hierarchical structuring. More...

#include <Component.h>

+ Inheritance diagram for agx::Component:

Public Types

typedef Event2< Component *, Object * > ObjectEvent
 Event when adding removing child objects.
 
typedef Callback1< Object * > TraverseCallback
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const Event > EventConstObserver
 
typedef agx::ref_ptr< const Event > EventConstRef
 
typedef agx::observer_ptr< Event > EventObserver
 
typedef agx::Vector< EventObserver > EventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< Event > EventRef
 
typedef agx::Vector< EventRef > EventRefVector
 

Public Member Functions

 Component (const agx::Name &name=agx::Name(), agx::Model *model=agx::Component::ClassModel(), agx::Device *device=nullptr)
 
virtual void addObject (agx::Object *object, bool assignContext=true)
 Add an object to the component.
 
virtual String autoComplete (const String &partialName, StringVector &matchingNames) const
 
virtual void buildNavigationTree (agxJson::Value &eNode) const override
 
void configure (Model *model)
 
virtual void configure (TiXmlElement *eComponent) override
 
agx::Device * getDevice ()
 
template<typename T >
T * getDevice ()
 
const agx::Device * getDevice () const
 
template<typename T >
const T * getDevice () const
 
size_t getNumObjects (const agx::Name &name) const
 
agx::Object * getObject (const agx::Name &name, agx::Model *model, size_t index=0)
 
const agx::Object * getObject (const agx::Name &name, agx::Model *model, size_t index=0) const
 
agx::Object * getObject (const agx::Name &name, size_t index=0)
 
template<typename T >
T * getObject (const agx::Name &name, size_t index=0)
 
const agx::Object * getObject (const agx::Name &name, size_t index=0) const
 
template<typename T >
const T * getObject (const agx::Name &name, size_t index=0) const
 
const agx::ObjectRefVector & getObjects () const
 
template<typename T >
void getObjects (agx::ObjectPtrVector &result, bool recursive=false) const
 Returns All child objects of a specified type in the result container.
 
void getObjects (agx::ObjectPtrVector &result, const agx::Model *model, bool recursive=false) const
 
virtual Object * getResourceImpl (const Path &path, agx::Model *model) override
 
virtual void printSubtree () const override
 
void printSubtree (std::ostream &stream, int depth=0) const
 
virtual void rebind () override
 
void removeAllObjects ()
 Remove all components.
 
virtual void removeObject (agx::Object *object)
 Remove an object from the component.
 
void removeObject (const agx::Name &name, size_t index=0)
 Remove an object with a specified name (and optional index) from the component.
 
virtual void snapshot (TiXmlNode *eParent, const String &directory) const override
 
void traverse (ComponentVisitor *)
 
void traverse (const TraverseCallback &callback)
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) 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
 
agx::Object * getContext ()
 
template<typename T >
T * getContext ()
 
const agx::Object * getContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::Name & getImplementationName () 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
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) 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
 
virtual agx::Object * getResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::Object * getRootContext ()
 
const agx::Object * getRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Member Functions

static Component * _load (TiXmlElement *eComponent, Device *device)
 
static agx::Model * ClassModel ()
 
static Component * load (const Path &path, const Name &implementation, Device *device, const Path &_namespace=Path())
 
static Component * load (const String &path, const Path &_namespace=Path())
 
static Component * load (const String &path, Device *device, const Path &_namespace=Path())
 
static Component * load (TiXmlElement *eComponent, Device *device)
 
- Static Public Member Functions inherited from agx::Object
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.
 
static Object * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Object * 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="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Object * load (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Public Attributes

ObjectEvent addObjectEvent
 
ObjectEvent removeObjectEvent
 

Protected Member Functions

virtual ~Component ()
 
String expandAutoCompletionMatch (const String &query, const StringVector &matchingNames) const
 
void setDevice (Device *device)
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

A component is an object containing other objects, enabling hierarchical structuring.

Allows multiple child objects with same name.

Definition at line 38 of file Component.h.

Member Typedef Documentation

◆ ObjectEvent

Event when adding removing child objects.

NOTE: Events are triggered recursively up the parent structure Example: B is added to root node A, one event is triggered (A.addObjectEvent(A, B)). Then when C is added to B two events are triggered (B.addObjectEvent(B, C), and A.addObjectEvent(B,C))

Definition at line 61 of file Component.h.

◆ TraverseCallback

Definition at line 141 of file Component.h.

Constructor & Destructor Documentation

◆ Component()

agx::Component::Component ( const agx::Name &  name = agx::Name(),
agx::Model *  model = agx::Component::ClassModel(),
agx::Device *  device = nullptr 
)

◆ ~Component()

virtual agx::Component::~Component ( )
protectedvirtual

Member Function Documentation

◆ _load()

static Component * agx::Component::_load ( TiXmlElement *  eComponent,
Device *  device 
)
static

◆ addObject()

virtual void agx::Component::addObject ( agx::Object *  object,
bool  assignContext = true 
)
virtual

Add an object to the component.

Parameters
objectThe object to be added
assignContextTrue if the child get the component as the context, set to false to allow 'weak' coupled children

◆ autoComplete()

virtual String agx::Component::autoComplete ( const String &  partialName,
StringVector &  matchingNames 
) const
virtual

Reimplemented in agx::Namespace.

◆ buildNavigationTree()

virtual void agx::Component::buildNavigationTree ( agxJson::Value &  eNode) const
overridevirtual

Reimplemented from agx::Object.

Reimplemented in agx::Model, and agxData::Buffer.

◆ ClassModel()

static agx::Model * agx::Component::ClassModel ( )
static

◆ configure() [1/2]

void agx::Component::configure ( Model *  model)

◆ configure() [2/2]

virtual void agx::Component::configure ( TiXmlElement *  eComponent)
overridevirtual

Reimplemented from agx::Object.

Reimplemented in agx::Clock, agx::Clock, agx::Kernel, agx::Task, and agx::UnresolvedTask.

◆ expandAutoCompletionMatch()

String agx::Component::expandAutoCompletionMatch ( const String &  query,
const StringVector &  matchingNames 
) const
protected

◆ getDevice() [1/4]

Device * agx::Component::getDevice ( )
Returns
The device which the component stored on.

Definition at line 222 of file Component.h.

Referenced by getDevice().

◆ getDevice() [2/4]

template<typename T >
T * agx::Component::getDevice

Definition at line 226 of file Component.h.

References agxAssert.

◆ getDevice() [3/4]

const Device * agx::Component::getDevice ( ) const

Definition at line 223 of file Component.h.

References getDevice().

◆ getDevice() [4/4]

template<typename T >
const T * agx::Component::getDevice

Definition at line 233 of file Component.h.

References agxAssert.

◆ getNumObjects()

size_t agx::Component::getNumObjects ( const agx::Name &  name) const
Returns
The number of child objects with a specified name.

Referenced by getObject().

◆ getObject() [1/6]

Object * agx::Component::getObject ( const agx::Name &  name,
agx::Model *  model,
size_t  index = 0 
)

Definition at line 197 of file Component.h.

◆ getObject() [2/6]

const Object * agx::Component::getObject ( const agx::Name &  name,
agx::Model *  model,
size_t  index = 0 
) const

Definition at line 198 of file Component.h.

◆ getObject() [3/6]

Object * agx::Component::getObject ( const agx::Name &  name,
size_t  index = 0 
)
Returns
The child object with specified name (and optional index).

Definition at line 194 of file Component.h.

Referenced by agxData::EntityPtr::operator()().

◆ getObject() [4/6]

template<typename T >
T * agx::Component::getObject ( const agx::Name &  name,
size_t  index = 0 
)

Definition at line 202 of file Component.h.

References getNumObjects(), and agx::Object::getPath().

◆ getObject() [5/6]

const Object * agx::Component::getObject ( const agx::Name &  name,
size_t  index = 0 
) const

Definition at line 195 of file Component.h.

◆ getObject() [6/6]

template<typename T >
const T * agx::Component::getObject ( const agx::Name &  name,
size_t  index = 0 
) const

Definition at line 216 of file Component.h.

◆ getObjects() [1/3]

const ObjectRefVector & agx::Component::getObjects ( ) const
Returns
All child objects.

Definition at line 192 of file Component.h.

Referenced by getObjects().

◆ getObjects() [2/3]

template<typename T >
void agx::Component::getObjects ( agx::ObjectPtrVector &  result,
bool  recursive = false 
) const

Returns All child objects of a specified type in the result container.

Definition at line 241 of file Component.h.

References getObjects().

◆ getObjects() [3/3]

void agx::Component::getObjects ( agx::ObjectPtrVector &  result,
const agx::Model *  model,
bool  recursive = false 
) const

◆ getResourceImpl()

virtual Object * agx::Component::getResourceImpl ( const Path &  path,
agx::Model *  model 
)
overridevirtual

Reimplemented from agx::Object.

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

◆ load() [1/4]

static Component * agx::Component::load ( const Path &  path,
const Name &  implementation,
Device *  device,
const Path &  _namespace = Path() 
)
static

◆ load() [2/4]

static Component * agx::Component::load ( const String &  path,
const Path &  _namespace = Path() 
)
static

◆ load() [3/4]

static Component * agx::Component::load ( const String &  path,
Device *  device,
const Path &  _namespace = Path() 
)
static

◆ load() [4/4]

static Component * agx::Component::load ( TiXmlElement *  eComponent,
Device *  device 
)
static

◆ printSubtree() [1/2]

virtual void agx::Component::printSubtree ( ) const
overridevirtual

Reimplemented from agx::Object.

◆ printSubtree() [2/2]

void agx::Component::printSubtree ( std::ostream &  stream,
int  depth = 0 
) const

◆ rebind()

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

Reimplemented from agx::Object.

Reimplemented in agx::Clock, agx::Kernel, and agx::Task.

◆ removeAllObjects()

void agx::Component::removeAllObjects ( )

Remove all components.

◆ removeObject() [1/2]

virtual void agx::Component::removeObject ( agx::Object *  object)
virtual

Remove an object from the component.

◆ removeObject() [2/2]

void agx::Component::removeObject ( const agx::Name &  name,
size_t  index = 0 
)

Remove an object with a specified name (and optional index) from the component.

◆ setDevice()

void agx::Component::setDevice ( Device *  device)
protected

◆ snapshot()

virtual void agx::Component::snapshot ( TiXmlNode *  eParent,
const String &  directory 
) const
overridevirtual

Reimplemented from agx::Object.

◆ traverse() [1/2]

void agx::Component::traverse ( ComponentVisitor *  )

◆ traverse() [2/2]

void agx::Component::traverse ( const TraverseCallback &  callback)

Member Data Documentation

◆ addObjectEvent

ObjectEvent agx::Component::addObjectEvent

Definition at line 63 of file Component.h.

◆ removeObjectEvent

ObjectEvent agx::Component::removeObjectEvent

Definition at line 64 of file Component.h.


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