AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxData::EntityPtr Class Reference

Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to be accessed using a AOS (array of structures) pattern. More...

#include <EntityPtr.h>

+ Inheritance diagram for agxData::EntityPtr:

Public Member Functions

 EntityPtr ()
 
 EntityPtr (agxData::EntityStorage *storage, agx::Index id)
 
 EntityPtr (const agxData::EntityPtr &other)=default
 
 EntityPtr (const agxData::EntityInstance &instance)
 
 ~EntityPtr ()=default
 
agx::Index calculateIndex () const
 Calculate the index using the indirect id. More...
 
agxData::EntityPtr copy ()
 Create a copy instance in the same storage. More...
 
agxData::EntityPtr copy (agxData::EntityStorage *target)
 Copy instance to another storage. More...
 
void copyAttributes (agxData::EntityPtr source)
 Copy instance attributes to an existing target instance. More...
 
template<typename T >
T & dataSet ()
 
template<typename T >
const T & dataSet () const
 
void destroy ()
 Remove the entity from the active storage. More...
 
agxData::EntityData * getData ()
 
const agxData::EntityData * getData () const
 
agx::Index getId () const
 
agxData::EntityModel * getModel ()
 
const agxData::EntityModel * getModel () const
 
agxData::EntityStorage * getStorage () const
 
agx::UInt32 hash () const
 
void init (agxData::EntityStorage *storage, agx::Index id)
 Set the target storage and id. More...
 
agxData::EntityInstance instance ()
 
const agxData::EntityInstance instance () const
 
void invalidate ()
 Invalidate the entity pointer. More...
 
bool isInstanceOf (agxData::EntityModel *model) const
 
bool isValid () const
 
 operator bool () const
 
bool operator! () const
 
bool operator!= (const EntityPtr &rhs) const
 
template<typename T >
T & operator() (const agxData::ScalarAttributeT< T > *attribute)
 Access the value of a specific attribute. More...
 
template<typename T >
const T & operator() (const agxData::ScalarAttributeT< T > *attribute) const
 
template<typename T >
T & operator() (const agxData::PointerAttributeT< T > *attribute)
 Pointer attribute. More...
 
template<typename T >
const T & operator() (const agxData::PointerAttributeT< T > *attribute) const
 
template<typename T >
agxData::VectorAttributeT< T >
::Type & 
operator() (const agxData::VectorAttributeT< T > *attribute)
 Vector attribute. More...
 
template<typename T >
const
agxData::VectorAttributeT< T >
::Type & 
operator() (const agxData::VectorAttributeT< T > *attribute) const
 
template<typename T >
agxData::HashSetAttributeT< T >
::Type & 
operator() (const agxData::HashSetAttributeT< T > *attribute)
 HashSet attribute. More...
 
template<typename T >
const
agxData::HashSetAttributeT< T >
::Type & 
operator() (const agxData::HashSetAttributeT< T > *attribute) const
 
template<typename T >
agxData::ArrayAttributeT< T >
::Type & 
operator() (const agxData::ArrayAttributeT< T > *attribute)
 Array attribute. More...
 
template<typename T >
const agxData::ArrayAttributeT
< T >::Type & 
operator() (const agxData::ArrayAttributeT< T > *attribute) const
 
template<typename T >
T & operator() (const agxData::SharedAttributeT< T > *attribute)
 Shared attribute. More...
 
template<typename T >
const T & operator() (const agxData::SharedAttributeT< T > *attribute) const
 
template<typename T >
ArrayAttributeT< T >::Type & operator() (const ArrayAttributeT< T > *attribute)
 
template<typename T >
const ArrayAttributeT< T >::Type & operator() (const ArrayAttributeT< T > *attribute) const
 
template<typename T >
VectorAttributeT< T >::Type & operator() (const VectorAttributeT< T > *attribute)
 
template<typename T >
const VectorAttributeT< T >::Type & operator() (const VectorAttributeT< T > *attribute) const
 
template<typename T >
HashSetAttributeT< T >::Type & operator() (const HashSetAttributeT< T > *attribute)
 
template<typename T >
const HashSetAttributeT< T >
::Type & 
operator() (const HashSetAttributeT< T > *attribute) const
 
bool operator< (const EntityPtr &rhs) const
 
EntityPtr & operator= (const EntityPtr &other)=default
 
EntityPtr & operator= (EntityPtr &&)=default
 
bool operator== (const EntityPtr &rhs) const
 
bool operator> (const EntityPtr &rhs) const
 
void print (std::ostream &stream) const
 
void print () const
 
void swapId (EntityPtr &other)
 Swap id with another instance. More...
 
void swapIndex (EntityPtr &other)
 Swap index with another instance. More...
 
void transfer (agxData::EntityStorage *target)
 Transfer instance to another storage. More...
 
void verifyIndex () const
 Check for broken ptr, by verifying that the id is active in the storage. More...
 

Static Public Member Functions

static EntityPtr createWithIndex (EntityStorage *storage, agx::Index index)
 
static void TransformToAscii (void *targetBuffer, const void *sourceBuffer, size_t numElements)
 

Detailed Description

Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to be accessed using a AOS (array of structures) pattern.

The entity pointer has a indirect id to its data inside the storage. The actual array index where the data is stored may change as the storage is reordered, but the EntityPtr is valid as long as the instance is not destroyed or transferred to another storage.

Definition at line 51 of file EntityPtr.h.

Constructor & Destructor Documentation

agxData::EntityPtr::EntityPtr ( )

Definition at line 264 of file EntityPtr.h.

Referenced by createWithIndex().

agxData::EntityPtr::EntityPtr ( agxData::EntityStorage *  storage,
agx::Index  id 
)

Definition at line 265 of file EntityPtr.h.

References init().

agxData::EntityPtr::EntityPtr ( const agxData::EntityPtr &  other)
default
agxData::EntityPtr::EntityPtr ( const agxData::EntityInstance &  instance)
agxData::EntityPtr::~EntityPtr ( )
default

Member Function Documentation

agx::Index agxData::EntityPtr::calculateIndex ( ) const
agxData::EntityPtr agxData::EntityPtr::copy ( )

Create a copy instance in the same storage.

agxData::EntityPtr agxData::EntityPtr::copy ( agxData::EntityStorage *  target)

Copy instance to another storage.

void agxData::EntityPtr::copyAttributes ( agxData::EntityPtr  source)

Copy instance attributes to an existing target instance.

EntityPtr agxData::EntityPtr::createWithIndex ( EntityStorage *  storage,
agx::Index  index 
)
inlinestatic

Definition at line 791 of file EntityStorage.h.

References agxAssert, EntityPtr(), and agxData::EntityStorage::indexToId().

Referenced by agx::createCell().

template<typename T >
T & agxData::EntityPtr::dataSet ( )

Definition at line 604 of file EntityStorage.h.

References agxAssert, and getData().

template<typename T >
const T & agxData::EntityPtr::dataSet ( ) const

Definition at line 611 of file EntityStorage.h.

void agxData::EntityPtr::destroy ( )

Remove the entity from the active storage.

EntityData * agxData::EntityPtr::getData ( )
Returns
The data set for this entity.

Definition at line 595 of file EntityStorage.h.

References agxAssert, and agxData::EntityStorage::getData().

Referenced by dataSet(), agxData::EntityInstance::EntityInstance(), getData(), and instance().

const EntityData * agxData::EntityPtr::getData ( ) const

Definition at line 601 of file EntityStorage.h.

References getData().

EntityModel * agxData::EntityPtr::getModel ( )
Returns
The entity model for this instance.

Definition at line 758 of file EntityStorage.h.

References agxData::EntityStorage::getEntityModel().

const EntityModel * agxData::EntityPtr::getModel ( ) const

Definition at line 763 of file EntityStorage.h.

References agxData::EntityStorage::getEntityModel().

EntityStorage * agxData::EntityPtr::getStorage ( ) const
Returns
The storage in which the entity is instantiated. nullptr if invalid pointer.

Definition at line 272 of file EntityPtr.h.

Referenced by agxCollide::CollisionGroupManager::canSetsCollide(), agxData::EntityStorage::dereferenceMultipliedAttribute(), operator!=(), and operator==().

agx::UInt32 agxData::EntityPtr::hash ( ) const

Definition at line 281 of file EntityPtr.h.

References agx::hash().

void agxData::EntityPtr::init ( agxData::EntityStorage *  storage,
agx::Index  id 
)

Set the target storage and id.

Definition at line 589 of file EntityStorage.h.

Referenced by EntityPtr().

EntityInstance agxData::EntityPtr::instance ( void  )
inline
Returns
an entity instance accessor.

Definition at line 269 of file EntityPtr.h.

References calculateIndex(), and getData().

const EntityInstance agxData::EntityPtr::instance ( void  ) const
inline

Definition at line 270 of file EntityPtr.h.

References calculateIndex(), and getData().

void agxData::EntityPtr::invalidate ( )

Invalidate the entity pointer.

Definition at line 275 of file EntityPtr.h.

References agx::InvalidIndex.

bool agxData::EntityPtr::isInstanceOf ( agxData::EntityModel *  model) const
Returns
True if the pointer is an instance of a specified model or sub-model

Definition at line 785 of file EntityStorage.h.

References agxData::EntityStorage::getEntityModel(), and agx::Model::is().

bool agxData::EntityPtr::isValid ( ) const
Returns
True if the pointer is valid (non-nullptr)

Definition at line 287 of file EntityPtr.h.

Referenced by operator!().

agxData::EntityPtr::operator bool ( ) const

Definition at line 289 of file EntityPtr.h.

bool agxData::EntityPtr::operator! ( ) const

Definition at line 288 of file EntityPtr.h.

References isValid().

bool agxData::EntityPtr::operator!= ( const EntityPtr &  rhs) const

Definition at line 306 of file EntityPtr.h.

References getId(), and getStorage().

template<typename T >
T & agxData::EntityPtr::operator() ( const agxData::ScalarAttributeT< T > *  attribute)

Access the value of a specific attribute.

Definition at line 642 of file EntityStorage.h.

template<typename T >
const T & agxData::EntityPtr::operator() ( const agxData::ScalarAttributeT< T > *  attribute) const

Definition at line 648 of file EntityStorage.h.

template<typename T >
T & agxData::EntityPtr::operator() ( const agxData::PointerAttributeT< T > *  attribute)

Pointer attribute.

Definition at line 654 of file EntityStorage.h.

template<typename T >
const T & agxData::EntityPtr::operator() ( const agxData::PointerAttributeT< T > *  attribute) const

Definition at line 660 of file EntityStorage.h.

template<typename T >
agxData::VectorAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::VectorAttributeT< T > *  attribute)

Vector attribute.

template<typename T >
const agxData::VectorAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::VectorAttributeT< T > *  attribute) const
template<typename T >
agxData::HashSetAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::HashSetAttributeT< T > *  attribute)

HashSet attribute.

template<typename T >
const agxData::HashSetAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::HashSetAttributeT< T > *  attribute) const
template<typename T >
agxData::ArrayAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::ArrayAttributeT< T > *  attribute)

Array attribute.

template<typename T >
const agxData::ArrayAttributeT<T>::Type& agxData::EntityPtr::operator() ( const agxData::ArrayAttributeT< T > *  attribute) const
template<typename T >
T & agxData::EntityPtr::operator() ( const agxData::SharedAttributeT< T > *  attribute)

Shared attribute.

Definition at line 744 of file EntityStorage.h.

References agxAssert, agxData::Value::get(), agx::Object::getName(), and agx::Component::getObject().

template<typename T >
const T & agxData::EntityPtr::operator() ( const agxData::SharedAttributeT< T > *  attribute) const

Definition at line 752 of file EntityStorage.h.

template<typename T >
ArrayAttributeT<T>::Type& agxData::EntityPtr::operator() ( const ArrayAttributeT< T > *  attribute)

Definition at line 667 of file EntityStorage.h.

template<typename T >
const ArrayAttributeT<T>::Type& agxData::EntityPtr::operator() ( const ArrayAttributeT< T > *  attribute) const

Definition at line 673 of file EntityStorage.h.

template<typename T >
VectorAttributeT<T>::Type& agxData::EntityPtr::operator() ( const VectorAttributeT< T > *  attribute)

Definition at line 681 of file EntityStorage.h.

template<typename T >
const VectorAttributeT<T>::Type& agxData::EntityPtr::operator() ( const VectorAttributeT< T > *  attribute) const

Definition at line 687 of file EntityStorage.h.

template<typename T >
HashSetAttributeT<T>::Type& agxData::EntityPtr::operator() ( const HashSetAttributeT< T > *  attribute)

Definition at line 693 of file EntityStorage.h.

template<typename T >
const HashSetAttributeT<T>::Type& agxData::EntityPtr::operator() ( const HashSetAttributeT< T > *  attribute) const

Definition at line 699 of file EntityStorage.h.

bool agxData::EntityPtr::operator< ( const EntityPtr &  rhs) const

Definition at line 291 of file EntityPtr.h.

References getId().

EntityPtr& agxData::EntityPtr::operator= ( const EntityPtr &  other)
default
EntityPtr& agxData::EntityPtr::operator= ( EntityPtr &&  )
default
bool agxData::EntityPtr::operator== ( const EntityPtr &  rhs) const

Definition at line 301 of file EntityPtr.h.

References getId(), and getStorage().

bool agxData::EntityPtr::operator> ( const EntityPtr &  rhs) const

Definition at line 296 of file EntityPtr.h.

References getId().

void agxData::EntityPtr::print ( std::ostream &  stream) const
void agxData::EntityPtr::print ( ) const
void agxData::EntityPtr::swapId ( EntityPtr &  other)

Swap id with another instance.

Both must be part of the same storage.

Definition at line 768 of file EntityStorage.h.

References agxAssert.

void agxData::EntityPtr::swapIndex ( EntityPtr &  other)

Swap index with another instance.

Both must be part of the same storage.

Definition at line 776 of file EntityStorage.h.

References agxAssert, calculateIndex(), and agxData::EntityStorage::swapInstances().

void agxData::EntityPtr::transfer ( agxData::EntityStorage *  target)

Transfer instance to another storage.

static void agxData::EntityPtr::TransformToAscii ( void *  targetBuffer,
const void *  sourceBuffer,
size_t  numElements 
)
static
void agxData::EntityPtr::verifyIndex ( ) const

Check for broken ptr, by verifying that the id is active in the storage.

Only used in debug mode.

Definition at line 632 of file EntityStorage.h.

References agxAssertN, agx::Path::c_str(), calculateIndex(), agx::Object::getPath(), and agxData::EntityStorage::size().


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