17#ifndef AGX_PARAMETER_H
18#define AGX_PARAMETER_H
21# pragma warning( disable: 4714 )
32namespace agxData {
class FunctionValue; }
93 size_t getIndex()
const;
98 MetaType getMetaType()
const;
108 bool isRequired()
const;
130 UInt8 getAccessMode()
const;
193 void setTask(
Task *task,
size_t index);
195 virtual void prepareGlobalResultSorting(
size_t numJobs);
221 virtual void configure(TiXmlElement *eParameter)
override;
261 virtual void configure(TiXmlElement *eParameter)
override;
273 template <
typename T>
274 const T& get()
const;
281 template <
typename T>
282 void set(
const T& value);
285 template <
typename T>
286 void write(
const T& value,
const Task* owner);
301 void setReal(
Real value );
335 virtual void configure(TiXmlElement *eParameter)
override;
359 template <
typename T>
362 template <
typename T>
373 size_t getLocalSize()
const;
378 size_t getNumElements()
const;
389 UInt getGlobalResultMode()
const;
414 void parentBindCallback(
Parameter *parent);
415 void parentUnbindCallback(
Parameter *parent);
422 size_t m_localMemorySize;
423 UInt m_globalResultMode;
440 virtual void configure(TiXmlElement *eParameter)
override;
447 const Object* get()
const;
449 template <
typename T>
452 template <
typename T>
453 const T* get()
const;
489 virtual void configure(TiXmlElement *eParameter)
override;
510 agxData::EntityData *getData();
512 template <
typename T>
523 UInt getGlobalResultMode()
const;
558 agxData::EntityDataRef m_dataSet;
560 UInt m_globalResultMode;
562 bool m_childrenNeedCommit;
575 virtual void configure(TiXmlElement *eParameter)
override;
594 template <
typename T>
614 struct AttributeAccess
616 AttributeAccess() : attribute(nullptr), buffer(nullptr), mode(
agx::
InvalidIndex) {}
624 VectorPOD<AttributeAccess> m_attributeAccessVector;
637 virtual void configure(TiXmlElement *eParameter)
override;
656 template <
typename T>
676 struct AttributeAccess
678 AttributeAccess() : attribute(nullptr), buffer(nullptr), mode(
agx::
InvalidIndex) {}
686 VectorPOD<AttributeAccess> m_attributeAccessVector;
716 template <
typename T>
719 agxAssertN(agxData::getFormat<T>() ==
m_format,
"%s: Type mismatch, parameter is type %s, dereferencing using type %s", this->
getPath().c_str(),
m_format->fullName().c_str(), agxData::getFormat<T>()->fullName().c_str());
720 agxAssertN(m_value && m_value->
isValid(),
"%s: Can not dereference an unbound parameter", this->getPath().c_str());
721 return m_value->
get<T>();
724 template <
typename T>
735 template <
typename T>
743 agxAssert(m_format->is(agxData::getFormat<T>()));
744 *(T*)this->ptr() = value;
749 return const_cast<void *
>(m_value->ptr());
760 return this->get<Real>();
770 template <
typename T>
774 agxAssertN(agxData::getFormat<T>() ==
m_format,
"%s: Type mismatch, parameter is type %s, dereferencing using type %s", this->
getPath().c_str(),
m_format->fullName().c_str(), agxData::getFormat<T>()->fullName().c_str());
776 return m_buffer ? m_buffer->getArray<T>() :
static_cast<agxData::Array<T>&
>(s_dummyArray);
779 template <
typename T>
798 template <
typename T>
808 template <
typename T>
818 template <
typename T>
834 template <
typename T>
842 template <
typename T>
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGX_DECLARE_VECTOR_TYPES(type)
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
Type-specific Array used for fast access into the data held by a Buffer.
An abstract attribute description, part of an Entity.
Abstract representation of a data buffer.
size_t getElementArraySize() const
Entity instance provides access to a single instance in an EntityStorage.
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Data storage for a collection of entity instances of a specified EntityModel.
Abstract representation of a value.
agxData::Array< T > & get()
Access the data of the current buffer binding.
ArrayParameter(const agx::Name &name, agxData::Type *type, UInt8 accessMode=agxData::READ, const Path &bindPath=Path())
virtual bool isValid() const override
virtual void prepareGlobalResultSorting(size_t numJobs) override
size_t getNumElements() const
ArrayParameter(const agx::Name &name, agxData::Format *format, UInt8 accessMode=agxData::READ, const Path &bindPath=Path())
UInt getGlobalResultMode() const
GlobalResultBuffer * getGlobalResult()
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
ArrayParameter(const agx::Name &name, agxData::Format *format, UInt8 accessMode, agxData::Buffer *binding)
virtual void update() override
static agx::Model * ClassModel()
agxData::Buffer * getBuffer()
void setLocalSize(size_t numElements)
Create a local memory allocation.
virtual void _bind(Object *binding) override
virtual void commit() override
virtual void configure(TiXmlElement *eParameter) override
size_t getLocalSize() const
virtual bool hasGlobalResult() const override
virtual ~ArrayParameter()
void setGlobalResultMode(UInt mode)
Set the global result mode.
ArrayParameter(const agx::Name &name, agxData::Type *type, UInt8 accessMode, agxData::Buffer *binding)
static ArrayParameter * load(TiXmlElement *eParameter, Device *device)
agxData::Type * getType() override
An agx::Device is an abstract representation of a device on which data can be stored and processed.
void addChildParameter(ArrayParameter *parameter)
agxData::EntityModel * getEntityModel()
virtual void _bind(Object *binding) override
static EntityDataParameter * load(TiXmlElement *eParameter, Device *device)
virtual void commit() override
virtual void update() override
virtual void configure(TiXmlElement *eParameter) override
GlobalResultStorage * getGlobalResult()
virtual void prepareGlobalResultSorting(size_t numJobs) override
void addChildParameter(ScalarParameter *parameter)
void setData(agxData::EntityData *dataSet)
void addChildParameter(Parameter *parameter)
EntityDataParameter(const agx::Name &name, agxData::EntityModel *entity, const Path &bindPath)
agxData::EntityData * getData()
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
virtual ~EntityDataParameter()
agxData::EntityStorage * getStorage()
virtual bool hasGlobalResult() const override
UInt getGlobalResultMode() const
virtual bool isValid() const override
static agx::Model * ClassModel()
void setGlobalResultMode(UInt mode)
Set the global result mode.
const ParameterRefVector & getChildParameters() const
EntityInstance parameter.
virtual ~EntityInstanceParameter()
static EntityInstanceParameter * load(TiXmlElement *eParameter, Device *device)
virtual void configure(TiXmlElement *eParameter) override
void registerAttributeAccess(const agxData::Attribute *attribute, agx::UInt8 mode)
virtual void commit() override
void bind(agxData::EntityInstance instance)
agxData::EntityModel * getEntityModel()
virtual bool isValid() const override
virtual void _bind(Object *binding) override
virtual void update() override
static agx::Model * ClassModel()
EntityInstanceParameter(const agx::Name &name, agxData::EntityModel *entity)
agxData::EntityInstance getBinding()
agxData::EntityPtr getBinding()
static EntityPtrParameter * load(TiXmlElement *eParameter, Device *device)
virtual void commit() override
virtual void configure(TiXmlElement *eParameter) override
virtual ~EntityPtrParameter()
void bind(agxData::EntityPtr ptr)
void registerAttributeAccess(const agxData::Attribute *attribute, agx::UInt8 mode)
virtual bool isValid() const override
virtual void update() override
EntityPtrParameter(const agx::Name &name, agxData::EntityModel *entity)
virtual void _bind(Object *binding) override
agxData::EntityModel * getEntityModel()
static agx::Model * ClassModel()
An event with one argument.
Inheritance with partial specialization due to bug with ref_ptr containers.
A model is an abstract representation of the class of an agx::Object.
Representation of a name string.
agx::Object is a refcounted object with a name.
agx::Path getPath() const
A representation of a task/kernel parameter, which can be bound using a string path or explicitly to ...
static agx::Model * ClassModel()
void bind(const agx::Path &path)
Set parameter bind path.
const agx::Path & getBindPath() const
agx::Object * getBinding()
agxData::FormatRef m_format
Parameter(Model *model, MetaType type, const Name &name, agxData::Format *format, UInt8 accessMode, const Path &bindPath=Path())
MetaType getMetaType() const
void setRequired(bool flag)
Set if the parameter is required, default is true.
UInt8 getAccessMode() const
const agx::String & getMetaTypeName() const
void unbind()
Remove current binding and bind path.
virtual void _bind(Object *binding)=0
Event1< Parameter * > Event
virtual bool isValid() const =0
void bind(agx::Object *binding)
Set explicit binding.
MetaType
Specify which kind of parameter.
virtual bool hasGlobalResult() const
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
agxData::Format * getFormat()
virtual agxData::Type * getType()
virtual void rebind() override
void set(agx::Object *binding)
Set the parameter, alias for bind.
Representation of a path, a list of name components.
virtual ~PointerParameter()
PointerParameter(const agx::Name &name, const Path &bindPath=Path())
virtual void _bind(Object *binding) override
static PointerParameter * load(TiXmlElement *eParameter, Device *device)
virtual void configure(TiXmlElement *eParameter) override
virtual void commit() override
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
virtual void update() override
virtual bool isValid() const override
virtual void destroyCallback(agx::Object *object) override
static agx::Model * ClassModel()
PointerParameter(const agx::Name &name, Object *binding)
virtual ~ScalarParameter()
virtual void commit() override
agxData::Value * getValue()
void set(agxData::Value *value)
Set the parameter value.
static ScalarParameter * load(TiXmlElement *eParameter, Device *device)
static agx::Model * ClassModel()
virtual Object * getResourceImpl(const Path &path, agx::Model *model) override
void setExpression(const String &expression)
Set the parameter using an expression.
ScalarParameter(const agx::Name &name, agxData::Format *format, UInt8 accessMode, agxData::Value *binding)
virtual void _bind(Object *binding) override
virtual void configure(TiXmlElement *eParameter) override
void write(const T &value, const Task *owner)
Only for internal use from the task containing this Parameter.
ScalarParameter(const agx::Name &name, agxData::Format *format, UInt8 accessMode=agxData::READ, const String &expression="")
virtual void update() override
virtual bool isValid() const override
A representation of a generic task.
UnresolvedParameter(const agx::Name &name, const agx::String &expression)
static UnresolvedParameter * load(TiXmlElement *eParameter, Device *device)
virtual void configure(TiXmlElement *eParameter) override
void triggerUpdateCallback(agxData::Value *value)
agxData::Type * getType() override
const agxData::Type * getType() const override
virtual void _bind(Object *binding) override
virtual void update() override
UnresolvedParameter(const agx::Name &name, MetaType type, const agx::String &expression)
virtual void commit() override
virtual ~UnresolvedParameter()
void init(const String &expression)
virtual bool isValid() const override
static agx::Model * ClassModel()
#define agxAssertN(expr, format,...)
Contains classes for low level data storage for AGX.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
HashTable< String, UnresolvedParameterRef > ParameterTable
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.