/usr/include/BALL/COMMON/create.h is in libball1.4-dev 1.4.1+20111206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_COMMON_CREATE_H
#define BALL_COMMON_CREATE_H
//@{
/** Virtual construction macro.
This macro is used to define the virtual <b>create</b> method.
On inclusion of this macro in the public interface of a class,
the virtual creation method becomes available. The create method's signature is as follows:
<tt>virtual void* <b>create</b>(bool deep = true, bool empty = false) const</tt> \par
The create method either creates an empty default object of the class (<tt>empty == <b>true</b></tt>)
or a copy of the object. The copy is either deep (<tt>deep == <b>true</b></tt>) or shallow (<tt>deep == <b>false</b></tt>).
By default, the create methods returns a pointer to a deep copy of the object.
The use of the create method requires a (public) default constructor (when creating an empty copy)
or a copy constructor. \par
The macro also implements a static method <tt>createDefault</tt> that returns a void pointer to
a new instance of <tt>name</tt>.
@param name the class name
\ingroup Common
*/
#define BALL_CREATE_DEEP(name)\
\
virtual void* create(bool deep = true, bool empty = false) const\
{\
void* ptr;\
if (empty == true)\
{\
ptr = (void*)new name;\
}\
else\
{\
ptr = (void*)new name(*this, deep);\
}\
\
return ptr;\
}\
\
static void* createDefault()\
{\
return static_cast<void*>(new name);\
}
/** Virtual construction macro.
This macro is used to define the virtual <b>create</b> method for classes that do
not define a copy constructor taking a second argument (boolean, deep or shallow copy).
On inclusion of this macro in the public interface of a class,
the virtual creation method becomes available. The create method's signature is as follows:
<tt>virtual void* <b>create</b>(bool deep = true, bool empty = false) const</tt> \par
The create method either creates an empty default object of the class (<tt>empty == <b>true</b></tt>)
or a copy of the object.
The use of the create method requires a (public) default constructor (when creating an empty copy)
and a copy constructor taking a reference to an object.
The macro also implements a static method <tt>createDefault</tt> that returns a void pointer to
a new instance of <tt>name</tt>.
@param name the class name
*/
#define BALL_CREATE(name)\
\
virtual void* create(bool /* deep */ = true, bool empty = false) const\
{\
void* ptr;\
if (empty == true)\
{\
ptr = (void*)new name;\
}\
else\
{\
ptr = (void*)new name(*this);\
}\
\
return ptr;\
}\
\
static void* createDefault()\
{\
return static_cast<void*>(new name);\
}
/** Virtual cloning method definition macro.
If the create method has to be implemented by the user, this macro just defines
the create method and the createDefault method.
The function signatures are:
\verbatim
virtual void* create(bool deep = true, bool empty = false) const;
static void* createDefault();
\endverbatim
*/
#define BALL_DEFINE_CREATE(name)\
\
virtual void* create(bool deep = true, bool empty = false) const;\
static void* createDefault();
//@}
#endif // BALL_COMMON_CREATE_H
|