iMSTK
Interactive Medical Simulation Toolkit
|
This class serves as the base class of DataArray, for typeless use. More...
#include <imstkAbstractDataArray.h>
Public Member Functions | |
AbstractDataArray (const int size) | |
virtual | ~AbstractDataArray () |
Ensure all observers are disconnected. | |
SIGNAL (AbstractDataArray, modified) | |
virtual void | resize (const int size)=0 |
Resizes the array, may reallocate. | |
virtual void | reserve (const int size)=0 |
Reserves a size for the array in memory, may reallocate. | |
virtual void * | getVoidPointer ()=0 |
Returns void pointer to data. | |
void | clear () |
Resizes to 0. | |
int | size () const |
Get number of values/tuples. | |
ScalarTypeId | getScalarType () const |
Returns the scalar type of this array. | |
int | getCapacity () const |
Return the capacity of the array. | |
virtual int | getNumberOfComponents () const |
Returns the number of components. | |
virtual std::shared_ptr< AbstractDataArray > | cast (ScalarTypeId)=0 |
cast the content to the given imstk scalar type without having to know the type of the enclosed array | |
void | postModified () |
emits signal to all observers, informing them on the current address in memory and size of array | |
std::unique_ptr< AbstractDataArray > | clone () |
polymorphic clone() function, utilize this to get a copy of the array without casting to the expected array type | |
![]() | |
template<typename T > | |
void | postEvent (const T &e) |
Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent. | |
template<typename T > | |
void | queueEvent (const T &e) |
Queues event directly to this. | |
void | doEvent () |
Do an event, if none exists return. | |
void | doAllEvents () |
Do all the events in the event queue. | |
void | foreachEvent (std::function< void(Command cmd)> func) |
Thread safe loop over all event commands, one can implement a custom handler. | |
void | rforeachEvent (std::function< void(Command cmd)> func) |
thread safe reverse loop over all event commands, one can implement a custom handler | |
void | clearEvents () |
Removes all events from queue cleans up copies of the event. | |
Protected Member Functions | |
void | setType (const ScalarTypeId type) |
Protected Attributes | |
ScalarTypeId | m_scalarType |
int | m_size |
int | m_capacity |
![]() | |
ParallelUtils::SpinLock | eventQueueLock |
std::deque< Command > | eventQueue |
std::vector< std::pair< std::string, std::vector< Observer > > > | queuedObservers |
std::vector< std::pair< std::string, std::vector< Observer > > > | directObservers |
Additional Inherited Members | |
![]() | |
using | Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> > |
This class serves as the base class of DataArray, for typeless use.
Definition at line 19 of file imstkAbstractDataArray.h.