~ubuntu-branches/debian/jessie/ugene/jessie

« back to all changes in this revision

Viewing changes to src/plugins_3rdparty/ball/src/include/BALL/COMMON/create.h

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-11-02 13:29:07 UTC
  • mfrom: (1.2.1) (3.1.11 natty)
  • Revision ID: package-import@ubuntu.com-20111102132907-o34gwnt0uj5g6hen
Tags: 1.9.8+repack-1
* First release to Debian
  - added README.Debian
  - increased policy version to 3.9.2
  - added URLs for version control system
* Added debug package.

Show diffs side-by-side

added added

removed removed

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