Go to the documentation of this file.
8 #ifndef __SIM_DataUtils_h__
9 #define __SIM_DataUtils_h__
20 #define DECLARE_CLASSNAME(DataClass, SuperClass) \
22 typedef SuperClass BaseClass; \
23 typedef DataClass ThisClass; \
25 static inline const UT_StringHolder &classname() \
27 static constexpr UT_StringLit theType(#DataClass); \
28 return theType.asHolder(); \
31 const UT_StringHolder &getDataTypeSubclass() const override \
36 static void getDataTypeSuperclasses(UT_StringArray& classes) \
38 static constexpr UT_StringLit theSuperType(#SuperClass); \
39 classes.append(theSuperType.asHolder()); \
40 SuperClass::getDataTypeSuperclasses(classes); \
50 #define DECLARE_STANDARD_GETCASTTOTYPE() \
52 void *getCastToType(const UT_StringRef &totype) const override \
54 if( classname() == totype ) \
55 return (void *)this; \
56 return BaseClass::getCastToType(totype); \
63 #define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms) \
65 class DataClass##Factory : public SIM_DataFactory \
68 DataClass##Factory(SIM_Engine *engine) \
70 SYS_CONCAT(#DataClass,_UTsh), \
71 SYS_CONCAT(Description,_UTsh), \
72 DataClass::getDataTypeSuperclasses, \
73 DataClass::constructor, \
74 DataClass::destructor, \
75 DataClass::DopParms, \
79 static void createDataFactory(SIM_Engine *engine) \
81 SIM_DataFactory *factory; \
82 factory = new DataClass##Factory( \
84 SIM_DataFactoryCreator::addDataFactory \
87 friend class DataClass##Factory; \
89 DECLARE_CLASSNAME(DataClass, SuperClass); \
90 static SIM_Data *constructor(const SIM_DataFactory *factory) \
91 { return (BaseClass *)new \
92 DataClass(factory); } \
93 static void destructor(SIM_Data *data) \
94 { delete (DataClass *)data-> \
95 getPointerToType(#DataClass); } \
100 #define IMPLEMENT_DATAFACTORY(DataClass) \
101 static SIM_DataFactoryCreator \
102 DataClass##Creator(DataClass::createDataFactory);