create.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: create.h,v 1.11 2004/02/18 23:24:02 oliver Exp $
00005 //
00006 
00007 #ifndef BALL_COMMON_CREATE_H
00008 #define BALL_COMMON_CREATE_H
00009 
00011 
00028 #define BALL_CREATE_DEEP(name)\
00029 \
00030   virtual void* create(bool deep = true, bool empty = false) const\
00031   {\
00032     void* ptr;\
00033     if (empty == true)\
00034     {\
00035       ptr = (void*)new name;\
00036     }\
00037     else\
00038     {\
00039       ptr = (void*)new name(*this, deep);\
00040     }\
00041     \
00042     return ptr;\
00043   }\
00044   \
00045   static void* createDefault()\
00046   {\
00047     return static_cast<void*>(new name);\
00048   }
00049 
00064 #define BALL_CREATE(name)\
00065 \
00066   virtual void* create(bool /* deep */ = true, bool empty = false) const\
00067   {\
00068     void* ptr;\
00069     if (empty == true)\
00070     {\
00071       ptr = (void*)new name;\
00072     }\
00073     else\
00074     {\
00075       ptr = (void*)new name(*this);\
00076     }\
00077     \
00078     return ptr;\
00079   }\
00080   \
00081   static void* createDefault()\
00082   {\
00083     return static_cast<void*>(new name);\
00084   }
00085 
00095 #define BALL_DEFINE_CREATE(name)\
00096 \
00097   virtual void* create(bool deep = true, bool empty = false) const;\
00098   static void* createDefault();
00099 
00101 
00102 #endif // BALL_COMMON_CREATE_H