VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros
virtualConstructor.h File Reference

Go to the source code of this file.

Macros

#define DT_VIRTUAL_CTR(CLASS_NAME, ARG_TYPES_LIST)
 
#define DT_VIRTUAL_COPY_ASSIGN(CLASS_NAME)
 
#define DT_VIRTUAL_BASE_CTR(BASE_NAME, ARG_TYPES_LIST)
 
#define DT_PURE_VIRTUAL_CTR(CLASS_NAME, ARG_TYPES_LIST)
 
#define DT_VIRTUAL_CTR_DEFINE(CLASS_NAME, ARG_TYPES_AND_NAMES_LIST, ARG_NAMES_LIST)
 
#define DT_VIRTUAL_COPY_ASSIGN_DEFINE(CLASS_NAME)
 
#define DT_VIRTUAL_BASE_CTR_DEFINE(CLASS_NAME, BASE_NAME, ARG_TYPES_AND_NAMES_LIST, ARG_NAMES_LIST)
 
#define DT_PURE_VIRTUAL_CTR_DEFINE(CLASS_NAME, ARG_TYPES_AND_NAMES_LIST, ARG_NAMES_LIST)
 

Detailed Description

Contains DT_VIRTUAL_CTR DT_VIRTUAL_COPY_ASSIGN DT_VIRTUAL_BASE_CTR DT_PURE_VIRTUAL_CTR DT_VIRTUAL_CTR_DEFINE DT_VIRTUAL_COPY_ASSIGN_DEFINE DT_VIRTUAL_BASE_CTR_DEFINE DT_PURE_VIRTUAL_CTR_DEFINE macros.

Macro Definition Documentation

#define DT_VIRTUAL_CTR (   CLASS_NAME,
  ARG_TYPES_LIST 
)
Value:
typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
static CLASS_NAME* create ARG_TYPES_LIST;\
static creatorFunction theCreator;\
static void setCreator(creatorFunction);\
/*lint -e{1736}*/\
protected:\
explicit CLASS_NAME ARG_TYPES_LIST;\
public:

Declare a Virtual Constructor Create using DT_VIRTUAL_CTR(CLASS_NAME,ARG_TYPES_LIST) Where CLASS_NAME = the name of the class being declared Where ARG_TYPES_LIST = a list (ie in side parentheses) of comma seperated types.

Example: DT_VIRTUAL_CTR( foo, (int,float,void*) )

The code generated is equivalent to this:

typedef foo* (creatorFunction)(int,float,void); static foo* create(int,float,void*); static void setCreator(creatorFunction); protected: foo(int,float,void*); public:

#define DT_VIRTUAL_COPY_ASSIGN (   CLASS_NAME)
Value:
typedef CLASS_NAME* (*copierFunction)(const CLASS_NAME &);\
typedef CLASS_NAME& (*assignerFunction)(CLASS_NAME&,const CLASS_NAME &);\
static CLASS_NAME* copy (const CLASS_NAME &);\
static CLASS_NAME& assign(CLASS_NAME&,const CLASS_NAME &);\
static copierFunction theCopier;\
static assignerFunction theAssigner;\
static void setCopier (copierFunction);\
static void setAssigner(assignerFunction);\
protected:\
explicit CLASS_NAME (const CLASS_NAME &);\
CLASS_NAME& operator=(const CLASS_NAME &);\
public:

Declare a Virtual Copy Constructor Create using DT_VIRTUAL_COPY_CTR(CLASS_NAME) Where CLASS_NAME = the name of the class being declared.

Example: DT_VIRTUAL_COPY_CTR( foo )

The code generated is equivalent to this:

typedef foo* (copierFunction)(const foo&); typedef foo& (*assignerFunction)(foo&,const foo&); static foo copy(const foo&); static foo& assign(foo&,const foo&); static void setCopier(copierFunction); static void setAssigner(assignerFunction); protected: foo(const foo&); foo& operator=(const foo&); public:

#define DT_VIRTUAL_BASE_CTR (   BASE_NAME,
  ARG_TYPES_LIST 
)
Value:
static BASE_NAME* createBase ARG_TYPES_LIST;\
static void overrideCreator();

Declare a Virtual Base Constructor Create using DT_VIRTUAL_CTR(CLASS_NAME,ARG_TYPES_LIST) Where BASE_NAME = the name of the base class being created Where ARG_TYPES_LIST = a list (ie in side parentheses) of comma seperated types.

Example: DT_VIRTUAL_BASE_CTR( bar, (int,float,void*) )

The code generated is equivalent to this:

static bar* createBase(int,float,void*); static void overrideCreator();

#define DT_PURE_VIRTUAL_CTR (   CLASS_NAME,
  ARG_TYPES_LIST 
)
Value:
static CLASS_NAME* create ARG_TYPES_LIST;\
/*lint -e{1736}*/\
public:\
typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
static creatorFunction theCreator;\
static void setCreator(creatorFunction);\
protected:\
explicit CLASS_NAME ARG_TYPES_LIST;\
public:

Declare a pure virtual constructor. Essentially the same as DT_VIRTUAL_CTR, but does not contain a constructor declaration. Declare DT_PURE_VIRTUAL_CTR(CLASS_NAME,ARG_TYPES_LIST) Where CLASS_NAME = the name of the class being declared Where ARG_TYPES_LIST = a list (ie in side parentheses) of comma seperated types.

Example: DT_PURE_VIRTUAL_CTR( foo, (int,float,void*) )

The code generated is equivalent to this:

typedef foo* (creatorFunction)(int,float,void); static foo* create(int,float,void*); static void setCreator(creatorFunction); public:

#define DT_VIRTUAL_CTR_DEFINE (   CLASS_NAME,
  ARG_TYPES_AND_NAMES_LIST,
  ARG_NAMES_LIST 
)
Value:
CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
{\
theCreator = aCreatorFunc;\
}\
CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
{\
if(theCreator)\
return theCreator ARG_NAMES_LIST;\
else\
return new CLASS_NAME ARG_NAMES_LIST;\
}

Define Virtual Constructor call using DT_VIRTUAL_CTR_DEFINE( CLASS_NAME , ARG_TYPES_AND_NAMES_LIST , ARG_NAMES_LIST) Where CLASS_NAME = the name of the class that is being defined Where ARG_TYPES_AND_NAMES_LIST = a list (ie in side parentheses) of comma separated type id pairs. Where ARG_NAMES_LIST = is the same comma seperated list but with only the names not the types.

Example: DT_VIRTUAL_CTR_DEFINE( foo, (int a,float b, void* c) , ( a , b, c ) )

The code generated is equivalent to this:

foo::creatorFunction foo::theCreator = 0;

void foo::setCreator(foo::creatorFunction aCreatorFunc) { theCreator = aCreatorFunc; }

foo* foo::create(int a,float b, void* c) { if(theCreator) return theCreator( a , b, c ); else return new foo( a , b, c ); }

#define DT_VIRTUAL_COPY_ASSIGN_DEFINE (   CLASS_NAME)
Value:
CLASS_NAME::copierFunction CLASS_NAME::theCopier = 0;\
CLASS_NAME::assignerFunction CLASS_NAME::theAssigner = 0;\
void CLASS_NAME::setCopier(CLASS_NAME::copierFunction aCopierFunc)\
{\
theCopier = aCopierFunc;\
}\
void CLASS_NAME::setAssigner(CLASS_NAME::assignerFunction anAssignerFunc)\
{\
theAssigner = anAssignerFunc;\
}\
CLASS_NAME* CLASS_NAME::copy ( const CLASS_NAME & orig ) \
{\
if(theCopier)\
return theCopier (orig);\
else\
return new CLASS_NAME (orig);\
}\
CLASS_NAME& CLASS_NAME::assign(CLASS_NAME& toAssign,const CLASS_NAME& orig)\
{\
if(theAssigner)\
return theAssigner(toAssign,orig);\
else\
return toAssign = orig;\
}

Define Virtual Copy Constructor call using DT_VIRTUAL_COPY_CTR_DEFINE( CLASS_NAME ) Where CLASS_NAME = the name of the class that is being defined.

Example: DT_VIRTUAL_COPY_CTR_DEFINE( foo )

The code generated is equivalent to this:

foo::copierFunction foo::theCopier = 0;

void foo::setCopier(foo::copierFunction aCopierFunc) { theCopier = aCopierFunc; }

foo* foo::copy( const foo & orig) { if(theCopier) return theCopier( orig ); else return new foo( orig ); }

#define DT_VIRTUAL_BASE_CTR_DEFINE (   CLASS_NAME,
  BASE_NAME,
  ARG_TYPES_AND_NAMES_LIST,
  ARG_NAMES_LIST 
)
Value:
BASE_NAME* CLASS_NAME::createBase ARG_TYPES_AND_NAMES_LIST \
{\
if(CLASS_NAME::theCreator && (void*)&CLASS_NAME::theCreator != (void*)&BASE_NAME::theCreator)\
return CLASS_NAME::theCreator ARG_NAMES_LIST;\
else\
return new CLASS_NAME ARG_NAMES_LIST;\
}\
void CLASS_NAME::overrideCreator() \
{\
BASE_NAME::setCreator(&CLASS_NAME::createBase);\
}
#define DT_PURE_VIRTUAL_CTR_DEFINE (   CLASS_NAME,
  ARG_TYPES_AND_NAMES_LIST,
  ARG_NAMES_LIST 
)
Value:
CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
{\
theCreator = aCreatorFunc;\
}\
CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
{\
if(theCreator && theCreator != CLASS_NAME::create)\
return theCreator ARG_NAMES_LIST;\
else\
throw DtCorruptedState("Class " #CLASS_NAME " has not be defined\n");\
}

Define Pure Virtual Constructor. Essentially the same as the DT_VIRTUAL_CTR_DEFINE, except instead of calling a constructor if the static constructor function is not defined it throws an exception DtAbstractInterfaceUndefined.

call using DT_PURE_VIRTUAL_CTR_DEFINE( CLASS_NAME , ARG_TYPES_AND_NAMES_LIST , ARG_NAMES_LIST) Where CLASS_NAME = the name of the class that is being defined Where ARG_TYPES_AND_NAMES_LIST = a list (ie in side parentheses) of comma separated type id pairs. Where ARG_NAMES_LIST = is the same comma seperated list but with only the names not the types

Example: DT_VIRTUAL_CTR_DEFINE( foo, (int a,float b, void* c) , ( a , b, c ) )

The code generated is equivalent to this:

foo::creatorFunction foo::theCreator = 0;

void foo::setCreator(foo::creatorFunction aCreatorFunc) { theCreator = aCreatorFunc; }

foo* foo::create(int a,float b, void* c) { if(theCreator) return theCreator( a , b, c ); else throw DtCorruptedState("Class: foo has not be defined\n"); }


Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)