|
VR-Vantage
|
|
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
13#ifndef virtualConstructor_H__
14#define virtualConstructor_H__
16#include <vlutil/vlExceptions.h>
33#define DT_VIRTUAL_CTR( CLASS_NAME , ARG_TYPES_LIST ) \
34 typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
35 static CLASS_NAME* create ARG_TYPES_LIST;\
36 static creatorFunction theCreator;\
37 static void setCreator(creatorFunction);\
40 explicit CLASS_NAME ARG_TYPES_LIST;\
61#define DT_VIRTUAL_COPY_ASSIGN( CLASS_NAME ) \
62 typedef CLASS_NAME* (*copierFunction)(const CLASS_NAME &);\
63 typedef CLASS_NAME& (*assignerFunction)(CLASS_NAME&,const CLASS_NAME &);\
64 static CLASS_NAME* copy (const CLASS_NAME &);\
65 static CLASS_NAME& assign(CLASS_NAME&,const CLASS_NAME &);\
66 static copierFunction theCopier;\
67 static assignerFunction theAssigner;\
68 static void setCopier (copierFunction);\
69 static void setAssigner(assignerFunction);\
71 explicit CLASS_NAME (const CLASS_NAME &);\
72 CLASS_NAME& operator=(const CLASS_NAME &);\
86#define DT_VIRTUAL_BASE_CTR( BASE_NAME , ARG_TYPES_LIST ) \
87 static BASE_NAME* createBase ARG_TYPES_LIST;\
88 static void overrideCreator();
106#define DT_PURE_VIRTUAL_CTR( CLASS_NAME , ARG_TYPES_LIST )\
107 static CLASS_NAME* create ARG_TYPES_LIST;\
110 typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
111 static creatorFunction theCreator;\
112 static void setCreator(creatorFunction);\
114 explicit CLASS_NAME ARG_TYPES_LIST;\
144#define DT_VIRTUAL_CTR_DEFINE(CLASS_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
145 CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
146 void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
148 theCreator = aCreatorFunc;\
150 CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
153 return theCreator ARG_NAMES_LIST;\
155 return new CLASS_NAME ARG_NAMES_LIST;\
182#define DT_VIRTUAL_COPY_ASSIGN_DEFINE(CLASS_NAME)\
183 CLASS_NAME::copierFunction CLASS_NAME::theCopier = 0;\
184 CLASS_NAME::assignerFunction CLASS_NAME::theAssigner = 0;\
185 void CLASS_NAME::setCopier(CLASS_NAME::copierFunction aCopierFunc)\
187 theCopier = aCopierFunc;\
189 void CLASS_NAME::setAssigner(CLASS_NAME::assignerFunction anAssignerFunc)\
191 theAssigner = anAssignerFunc;\
193 CLASS_NAME* CLASS_NAME::copy ( const CLASS_NAME & orig ) \
196 return theCopier (orig);\
198 return new CLASS_NAME (orig);\
200 CLASS_NAME& CLASS_NAME::assign(CLASS_NAME& toAssign,const CLASS_NAME& orig)\
203 return theAssigner(toAssign,orig);\
205 return toAssign = orig;\
210#define DT_VIRTUAL_BASE_CTR_DEFINE(CLASS_NAME,BASE_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
211 BASE_NAME* CLASS_NAME::createBase ARG_TYPES_AND_NAMES_LIST \
213 if(CLASS_NAME::theCreator && (void*)&CLASS_NAME::theCreator != (void*)&BASE_NAME::theCreator)\
214 return CLASS_NAME::theCreator ARG_NAMES_LIST;\
216 return new CLASS_NAME ARG_NAMES_LIST;\
218 void CLASS_NAME::overrideCreator() \
220 BASE_NAME::setCreator(&CLASS_NAME::createBase);\
254#define DT_PURE_VIRTUAL_CTR_DEFINE(CLASS_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
255 CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
256 void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
258 theCreator = aCreatorFunc;\
260 CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
262 if(theCreator && theCreator != CLASS_NAME::create)\
263 return theCreator ARG_NAMES_LIST;\
265 throw DtCorruptedState("Class " #CLASS_NAME " has not be defined\n");\