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

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

◆ EntityPtr() [1/4]

agxData::EntityPtr::EntityPtr ( )

Definition at line 264 of file EntityPtr.h.

Referenced by createWithIndex().

◆ EntityPtr() [2/4]

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

Definition at line 265 of file EntityPtr.h.

References init().

◆ EntityPtr() [3/4]

agxData::EntityPtr::EntityPtr ( const agxData::EntityPtr other)
default

◆ EntityPtr() [4/4]

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

◆ ~EntityPtr()

agxData::EntityPtr::~EntityPtr ( )
default

Member Function Documentation

◆ calculateIndex()

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

◆ copy() [1/2]

agxData::EntityPtr agxData::EntityPtr::copy ( )

Create a copy instance in the same storage.

◆ copy() [2/2]

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

Copy instance to another storage.

◆ copyAttributes()

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

Copy instance attributes to an existing target instance.

◆ createWithIndex()

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

Definition at line 790 of file EntityStorage.h.

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

Referenced by agx::createCell().

◆ dataSet() [1/2]

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

Definition at line 603 of file EntityStorage.h.

References agxAssert, and getData().

◆ dataSet() [2/2]

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

Definition at line 610 of file EntityStorage.h.

◆ destroy()

void agxData::EntityPtr::destroy ( )

Remove the entity from the active storage.

◆ getData() [1/2]

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

Definition at line 594 of file EntityStorage.h.

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

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

◆ getData() [2/2]

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

Definition at line 600 of file EntityStorage.h.

References getData().

◆ getId()

◆ getModel() [1/2]

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

Definition at line 757 of file EntityStorage.h.

References agxData::EntityStorage::getEntityModel().

◆ getModel() [2/2]

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

Definition at line 762 of file EntityStorage.h.

References agxData::EntityStorage::getEntityModel().

◆ getStorage()

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

◆ hash()

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

Definition at line 281 of file EntityPtr.h.

References agx::hash().

◆ init()

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

Set the target storage and id.

Definition at line 588 of file EntityStorage.h.

Referenced by EntityPtr().

◆ instance() [1/2]

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

Definition at line 269 of file EntityPtr.h.

References calculateIndex(), and getData().

Referenced by EntityPtr().

◆ instance() [2/2]

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

Definition at line 270 of file EntityPtr.h.

References calculateIndex(), and getData().

◆ invalidate()

void agxData::EntityPtr::invalidate ( )

Invalidate the entity pointer.

Definition at line 275 of file EntityPtr.h.

References agx::InvalidIndex.

◆ isInstanceOf()

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 784 of file EntityStorage.h.

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

◆ isValid()

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

◆ operator bool()

agxData::EntityPtr::operator bool ( ) const

Definition at line 289 of file EntityPtr.h.

◆ operator!()

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

Definition at line 288 of file EntityPtr.h.

References isValid().

◆ operator!=()

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

Definition at line 306 of file EntityPtr.h.

References getId(), and getStorage().

◆ operator()() [1/18]

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

Array attribute.

◆ operator()() [2/18]

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

◆ operator()() [3/18]

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

HashSet attribute.

◆ operator()() [4/18]

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

◆ operator()() [5/18]

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

Pointer attribute.

Definition at line 653 of file EntityStorage.h.

◆ operator()() [6/18]

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

Definition at line 659 of file EntityStorage.h.

◆ operator()() [7/18]

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

Access the value of a specific attribute.

Definition at line 641 of file EntityStorage.h.

◆ operator()() [8/18]

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

Definition at line 647 of file EntityStorage.h.

◆ operator()() [9/18]

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

Shared attribute.

Definition at line 743 of file EntityStorage.h.

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

◆ operator()() [10/18]

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

Definition at line 751 of file EntityStorage.h.

◆ operator()() [11/18]

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

Vector attribute.

◆ operator()() [12/18]

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

◆ operator()() [13/18]

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

Definition at line 666 of file EntityStorage.h.

◆ operator()() [14/18]

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

Definition at line 672 of file EntityStorage.h.

◆ operator()() [15/18]

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

Definition at line 692 of file EntityStorage.h.

◆ operator()() [16/18]

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

Definition at line 698 of file EntityStorage.h.

◆ operator()() [17/18]

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

Definition at line 680 of file EntityStorage.h.

◆ operator()() [18/18]

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

Definition at line 686 of file EntityStorage.h.

◆ operator<()

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

Definition at line 291 of file EntityPtr.h.

References getId().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

EntityPtr & agxData::EntityPtr::operator= ( EntityPtr &&  )
default

◆ operator==()

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

Definition at line 301 of file EntityPtr.h.

References getId(), and getStorage().

◆ operator>()

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

Definition at line 296 of file EntityPtr.h.

References getId().

◆ print() [1/2]

void agxData::EntityPtr::print ( ) const

◆ print() [2/2]

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

◆ swapId()

void agxData::EntityPtr::swapId ( EntityPtr other)

Swap id with another instance.

Both must be part of the same storage.

Definition at line 767 of file EntityStorage.h.

References agxAssert.

◆ swapIndex()

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

Swap index with another instance.

Both must be part of the same storage.

Definition at line 775 of file EntityStorage.h.

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

◆ transfer()

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

Transfer instance to another storage.

◆ TransformToAscii()

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

◆ verifyIndex()

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 631 of file EntityStorage.h.

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


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