IMP  2.1.1
The Integrative Modeling Platform
base/utility_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/utility_macros.h
3  * \brief Various general useful macros for IMP.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPBASE_UTILITY_MACROS_H
10 #define IMPBASE_UTILITY_MACROS_H
11 #include <IMP/base/base_config.h>
13 
14 //! Use a copy_from method to create a copy constructor and operator=
15 /** This macro is there to aid with classes which require a custom
16  copy constructor. It simply forwards \c operator= and the copy
17  constructor to a method \c copy_from() which should do the copying.
18 
19  You should think very hard before implementing a class which
20  requires a custom copy custructor as it is easy to get wrong
21  and you can easily wrap most resources with RAII objects
22  (\external{http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization,
23  wikipedia entry}).
24 */
25 #define IMP_COPY_CONSTRUCTOR(Name, Base) \
26  Name(const Name& o) : Base() { copy_from(o); } \
27  IMP_NO_SWIG(Name& operator=(const Name& o) { \
28  copy_from(o); \
29  return *this; \
30  }) IMP_REQUIRE_SEMICOLON_CLASS(copy)
31 
32 /** \deprecated_at{2.1} Don't use this */
33 #define IMP_PROTECTED_METHOD_DECL(protection, return_value, name, arguments, \
34  const_or_not, body) \
35  IMPBASE_DEPRECATED_MACRO(2.1, "Don't use this."); \
36  protection: \
37  return_value name arguments const_or_not body
38 
39 /** \deprecated_at{2.1} Don't use this */
40 #define IMP_PROTECTED_CONSTRUCTOR_DECL(protection, Name, arguments, body) \
41  protection: \
42  Name arguments body
43 
44 /** \deprecated_at{2.1} Don't use this */
45 #define IMP_PROTECTED_DESTRUCTOR_DECL(protection, Name, arguments, body) \
46  protection: \
47  virtual ~Name arguments body
48 
49 #if !defined(SWIG)
50 /** \deprecated_at{2.1} Don't use this */
51 #define IMP_PROTECTED_METHOD(return_value, name, arguments, const_or_not, \
52  body) \
53  IMPBASE_DEPRECATED_MACRO(2.1, "Don't use this"); \
54  IMP_PROTECTED_METHOD_DECL(protected, return_value, name, arguments, \
55  const_or_not, body)
56 
57 /** \deprecated_at{2.1} Don't use this */
58 #define IMP_PROTECTED_CONSTRUCTOR(Name, arguments, body) \
59  IMPBASE_DEPRECATED_MACRO(2.1, "Don't use this"); \
60  IMP_PROTECTED_CONSTRUCTOR_DECL(protected, Name, arguments, body)
61 
62 /** \deprecated_at{2.1} Don't use this */
63 #define IMP_PROTECTED_DESTRUCTOR(Name, arguments, body) \
64  IMPBASE_DEPRECATED_MACRO(2.1, "Don't use this"); \
65  IMP_PROTECTED_DESTRUCTOR_DECL(protected, Name, arguments, body)
66 
67 #ifndef IMP_DOXYGEN
68 /** \deprecated_at{2.1} Don't use this */
69 #define IMP_INTERNAL_METHOD(return_value, name, arguments, const_or_not, body) \
70  IMPBASE_DEPRECATED_MACRO(2.1, "Don't use this"); \
71  \
72  public: \
73  return_value name arguments const_or_not body
74 
75 #else
76 /** \deprecated_at{2.1} Don't use this */
77 #define IMP_INTERNAL_METHOD(return_value, name, arguments, const_or_not, body)
78 #endif
79 
80 #else
81 #define IMP_PROTECTED_METHOD(return_value, name, arguments, const_or_not, \
82  body) \
83  % rename(_##name) name; \
84  IMP_PROTECTED_METHOD_DECL(public, return_value, name, arguments, \
85  const_or_not, body)
86 
87 #define IMP_INTERNAL_METHOD(return_value, name, arguments, const_or_not, body)
88 
89 #define IMP_PROTECTED_CONSTRUCTOR(Name, arguments, body) \
90  IMP_PROTECTED_CONSTRUCTOR_DECL(public, Name, arguments, body)
91 
92 #define IMP_PROTECTED_DESTRUCTOR(Name, arguments, body) \
93  IMP_PROTECTED_DESTRUCTOR_DECL(public, Name, arguments, body)
94 
95 #endif
96 
97 #define IMP_EXPAND_AND_STRINGIFY(x) IMP_STRINGIFY(x)
98 
99 #endif /* IMPBASE_UTILITY_MACROS_H */
Control display of deprecation information.