VR-Vantage API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
Tutorials
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
vrvUtil
virtualConstructor.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2007 MAK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: virtualConstructor.h,v $ $Revision: 1.6 $ $State: Exp $
7
******************************************************************************/
8
14
15
16
#ifndef virtualConstructor_H__
17
#define virtualConstructor_H__
18
19
#include <vlutil/vlExceptions.h>
20
36
#define DT_VIRTUAL_CTR( CLASS_NAME , ARG_TYPES_LIST ) \
37
typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
38
static CLASS_NAME* create ARG_TYPES_LIST;\
39
static creatorFunction theCreator;\
40
static void setCreator(creatorFunction);\
41
/*lint -e{1736}*/
\
42
protected:\
43
explicit CLASS_NAME ARG_TYPES_LIST;\
44
public:
45
64
#define DT_VIRTUAL_COPY_ASSIGN( CLASS_NAME ) \
65
typedef CLASS_NAME* (*copierFunction)(const CLASS_NAME &);\
66
typedef CLASS_NAME& (*assignerFunction)(CLASS_NAME&,const CLASS_NAME &);\
67
static CLASS_NAME* copy (const CLASS_NAME &);\
68
static CLASS_NAME& assign(CLASS_NAME&,const CLASS_NAME &);\
69
static copierFunction theCopier;\
70
static assignerFunction theAssigner;\
71
static void setCopier (copierFunction);\
72
static void setAssigner(assignerFunction);\
73
protected:\
74
explicit CLASS_NAME (const CLASS_NAME &);\
75
CLASS_NAME& operator=(const CLASS_NAME &);\
76
public:
77
89
#define DT_VIRTUAL_BASE_CTR( BASE_NAME , ARG_TYPES_LIST ) \
90
static BASE_NAME* createBase ARG_TYPES_LIST;\
91
static void overrideCreator();
92
93
109
#define DT_PURE_VIRTUAL_CTR( CLASS_NAME , ARG_TYPES_LIST )\
110
static CLASS_NAME* create ARG_TYPES_LIST;\
111
/*lint -e{1736}*/
\
112
public:\
113
typedef CLASS_NAME* (*creatorFunction)ARG_TYPES_LIST;\
114
static creatorFunction theCreator;\
115
static void setCreator(creatorFunction);\
116
protected:\
117
explicit CLASS_NAME ARG_TYPES_LIST;\
118
public:
119
147
#define DT_VIRTUAL_CTR_DEFINE(CLASS_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
148
CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
149
void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
150
{\
151
theCreator = aCreatorFunc;\
152
}\
153
CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
154
{\
155
if(theCreator)\
156
return theCreator ARG_NAMES_LIST;\
157
else\
158
return new CLASS_NAME ARG_NAMES_LIST;\
159
}
160
184
185
#define DT_VIRTUAL_COPY_ASSIGN_DEFINE(CLASS_NAME)\
186
CLASS_NAME::copierFunction CLASS_NAME::theCopier = 0;\
187
CLASS_NAME::assignerFunction CLASS_NAME::theAssigner = 0;\
188
void CLASS_NAME::setCopier(CLASS_NAME::copierFunction aCopierFunc)\
189
{\
190
theCopier = aCopierFunc;\
191
}\
192
void CLASS_NAME::setAssigner(CLASS_NAME::assignerFunction anAssignerFunc)\
193
{\
194
theAssigner = anAssignerFunc;\
195
}\
196
CLASS_NAME* CLASS_NAME::copy ( const CLASS_NAME & orig ) \
197
{\
198
if(theCopier)\
199
return theCopier (orig);\
200
else\
201
return new CLASS_NAME (orig);\
202
}\
203
CLASS_NAME& CLASS_NAME::assign(CLASS_NAME& toAssign,const CLASS_NAME& orig)\
204
{\
205
if(theAssigner)\
206
return theAssigner(toAssign,orig);\
207
else\
208
return toAssign = orig;\
209
}
210
211
212
213
#define DT_VIRTUAL_BASE_CTR_DEFINE(CLASS_NAME,BASE_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
214
BASE_NAME* CLASS_NAME::createBase ARG_TYPES_AND_NAMES_LIST \
215
{\
216
if(CLASS_NAME::theCreator && (void*)&CLASS_NAME::theCreator != (void*)&BASE_NAME::theCreator)\
217
return CLASS_NAME::theCreator ARG_NAMES_LIST;\
218
else\
219
return new CLASS_NAME ARG_NAMES_LIST;\
220
}\
221
void CLASS_NAME::overrideCreator() \
222
{\
223
BASE_NAME::setCreator(&CLASS_NAME::createBase);\
224
}
225
257
#define DT_PURE_VIRTUAL_CTR_DEFINE(CLASS_NAME,ARG_TYPES_AND_NAMES_LIST,ARG_NAMES_LIST)\
258
CLASS_NAME::creatorFunction CLASS_NAME::theCreator = 0;\
259
void CLASS_NAME::setCreator(CLASS_NAME::creatorFunction aCreatorFunc)\
260
{\
261
theCreator = aCreatorFunc;\
262
}\
263
CLASS_NAME* CLASS_NAME::create ARG_TYPES_AND_NAMES_LIST \
264
{\
265
if(theCreator && theCreator != CLASS_NAME::create)\
266
return theCreator ARG_NAMES_LIST;\
267
else\
268
throw DtCorruptedState("Class " #CLASS_NAME " has not be defined\n");\
269
}
270
271
#endif
272
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)