HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_DataUtils.h File Reference
#include "SIM_Data.h"
#include "SIM_DataFactory.h"
#include "SIM_Utils.h"
#include <UT/UT_StringArray.h>
#include <UT/UT_StringHolder.h>
#include <SYS/SYS_Compiler.h>
+ Include dependency graph for SIM_DataUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DECLARE_CLASSNAME(DataClass, SuperClass)
 
#define DECLARE_STANDARD_GETCASTTOTYPE()
 
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
 
#define IMPLEMENT_DATAFACTORY(DataClass)
 

Macro Definition Documentation

#define DECLARE_CLASSNAME (   DataClass,
  SuperClass 
)
Value:
private: \
typedef SuperClass BaseClass; \
typedef DataClass ThisClass; \
static inline UT_StringHolder classname() \
{ return SYS_CONCAT(#DataClass,_UTsh); } \
virtual const UT_String &getDataTypeSubclass() const \
{ \
static UT_String theType(classname()); \
return theType; \
} \
protected: \
static void getDataTypeSuperclasses(UT_StringArray& classes) \
{ \
classes.append(SYS_CONCAT(#SuperClass,_UTsh)); \
SuperClass::getDataTypeSuperclasses(classes); \
} \
private: \
#define SYS_CONCAT(a, b)
Definition: SYS_Compiler.h:38
#define const
Definition: zconf.h:214

This macro provides a quick way to define a static function called classname() which returns the provided class name as a string.

Definition at line 20 of file SIM_DataUtils.h.

#define DECLARE_DATAFACTORY (   DataClass,
  SuperClass,
  Description,
  DopParms 
)

This macro simplifies the calling and casting the return value from This macro quickly defines all the static functions needed to declare a SIM_DataFactory for a SIM_Data subclass.

Definition at line 58 of file SIM_DataUtils.h.

#define DECLARE_STANDARD_GETCASTTOTYPE ( )
Value:
protected: \
virtual void *getCastToType(const char *totype) const \
{ \
if( strcmp(classname(), totype) == 0 ) \
return (void *)this; \
return BaseClass::getCastToType(totype); \
} \
if(rank==1) return rank

This function implements a standard version of getDistanceToType(). Only if your subclass uses multiple inheritance will it be necessary to write a customized version of this function. Be sure to add this declaration to your class definition or the DECLARE_DATAFACTORY() macro will not compile properly.

Definition at line 45 of file SIM_DataUtils.h.

#define IMPLEMENT_DATAFACTORY (   DataClass)
Value:
static SIM_DataFactoryCreator \
DataClass##Creator(DataClass::createDataFactory);

Add this macro to the initialization function for your library. It uses the declaration above to register your data type.

Examples:
SIM/SIM_ElectricalProperties.C, SIM/SIM_ForceOrbit.C, SIM/SIM_GasAdd.C, SIM/SIM_RadialEmit.C, SIM/SIM_SolverHair.C, and SIM/SNOW_Solver.C.

Definition at line 97 of file SIM_DataUtils.h.