17 #ifndef AGXDATA_TYPE2_H 18 #define AGXDATA_TYPE2_H 41 #define AGX_TYPE_NAME_MAX_LENGTH 1023 113 const FormatTable& getFormats()
const;
124 template <
typename T>
127 template <
typename T>
133 Format *getDefaultFormat();
134 const Format *getDefaultFormat()
const;
136 void addFormat(
Format *format,
bool isDefault =
false);
137 void setDefaultFormat(
Format *format);
148 FormatTable m_formats;
155 template <
typename T>
168 template <
typename T>
173 Type *type = getType<T>();
179 #define AGX_TYPE_BINDING(_Type, _Name) \ 183 struct TypeBinding<_Type> \ 185 static Type *getType() \ 187 return agxData::getOrCreateType(_Name); \ 192 #define AGX_TEMPLATED_TYPE_BINDING(_Type, _Name) \ 195 template <typename T> \ 196 struct TypeBinding< _Type<T> > \ 198 static Type *getType() \ 200 Format *format = agxData::getFormat<T>(); \ 201 const agx::String& elementName = format->getName() == "default" ? format->getType()->getName().str() : format->fullName(); \ 202 agx::String typeName = _Name "<" + elementName + ">"; \ 203 Type *type = agxData::getOrCreateType(typeName); \ 205 if (!type->getDefaultFormat()) \ 206 type->addFormat(new FormatT< _Type<T> >("default"), true); \ 212 template <typename T> \ 213 struct FormatBinding< _Type<T> > \ 215 static Format *getFormat() \ 217 return getType< _Type<T> >()->getDefaultFormat(); \ 226 inline const FormatTable& Type::getFormats()
const {
return m_formats; }
227 inline Format *Type::getDefaultFormat() {
return m_defaultFormat; }
228 inline const Format *Type::getDefaultFormat()
const {
return m_defaultFormat; }
232 FormatTable::iterator it = m_formats.find(name);
233 return it == m_formats.end() ? nullptr : it->second;
243 template <
typename T>
246 for (FormatTable::iterator it = m_formats.begin(); it != m_formats.end(); ++it)
247 if (it->second->getImplementationName() ==
typeid(T).name())
253 template <
typename T>
256 return const_cast<Type *
>(
this)->getFormat<T>();
261 template <
typename T>
268 template <
typename T>
293 template <
typename T>
302 template <
typename T>
307 return getType<T*>()->getDefaultFormat();
312 template <>
AGX_FORCE_INLINE Format *getFormat<agx::String>() {
return agxData::getType<agx::String>()->getDefaultFormat(); }
agx::HashVector< agx::Name, TypeRef > TypeTable
Inheritance with partial specialization due to bug with ref_ptr containers.
const TypeTable & getTypes()
A model is an abstract representation of the class of an agx::Object.
#define agxAssertN(expr, format,...)
Format * getFormat(const agx::Name &name)
#define AGX_TYPE_BINDING(_Type, _Name)
#define AGX_DECLARE_POINTER_TYPES(type)
Representation of a name string.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
AGXCORE_EXPORT Type * getOrCreateType(const agx::String &name)
void printAllTypesAndFormats()
Print all types and formats to std::cout.
Format * getFormat< void >()
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Contains classes for low level data storage for AGX.
const char * c_str() const
const agx::Name & getName() const
AGXCORE_EXPORT Format * getGenericStructFormat(size_t numBytes)
#define AGX_TEMPLATED_TYPE_BINDING(_Type, _Name)
agx::HashTable< agx::Name, FormatRef > FormatTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Format * getDefaultFormat()
An agx::Device is an abstract representation of a device on which data can be stored and processed...
Type binding, templated type -> abstract type.
void addFormat(Format *format, bool isDefault=false)
agx::Object is a refcounted object with a name.