IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
object_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/base/object_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_OBJECT_MACROS_H
10
#define IMPBASE_OBJECT_MACROS_H
11
#include <IMP/base/base_config.h>
12
#include "
doxygen_macros.h
"
13
#include "
ref_counted_macros.h
"
14
#include "
Vector.h
"
15
#include "
Pointer.h
"
16
#include "
WeakPointer.h
"
17
#include "
SetLogState.h
"
18
19
20
//! Define the basic things needed by any Object
21
/** This defines
22
- IMP::base::Object::get_version_info()
23
- a private destructor
24
and declares
25
- IMP::base::Object::do_show()
26
*/
27
#define IMP_OBJECT_INLINE(Name, show, destructor) \
28
public: \
29
IMP_IMPLEMENT_INLINE( virtual ::IMP::base::VersionInfo \
30
get_version_info() const, \
31
return ::IMP::base::VersionInfo(get_module_name(), \
32
get_module_version())); \
33
IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, \
34
try { \
35
IMP::base::Object::_on_destruction(); \
36
destructor; \
37
} catch (const std::exception &e) { \
38
IMP_LOG_VARIABLE(e); \
39
IMP_WARN("Caught exception " \
40
<< e.what() \
41
<< " in destructor."); \
42
})
43
44
45
//! Use IMP_OBJECT_METHODS()
46
#define IMP_OBJECT(Name) \
47
public: \
48
IMP_IMPLEMENT_INLINE( virtual ::IMP::base::VersionInfo \
49
get_version_info() const, \
50
return ::IMP::base::VersionInfo(get_module_name(), \
51
get_module_version())); \
52
virtual void do_show(std::ostream &out) const; \
53
IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, IMP::base::Object::_on_destruction();)
54
55
//! Define the basic things needed by any Object
56
/** This defines
57
- IMP::base::Object::get_version_info()
58
- IMP::base::Object::get_type_name()
59
- a private destructor
60
*/
61
#define IMP_OBJECT_METHODS(Name) \
62
public: \
63
IMP_IMPLEMENT_INLINE( virtual ::IMP::base::VersionInfo \
64
get_version_info() const, \
65
return ::IMP::base::VersionInfo(get_module_name(), \
66
get_module_version())); \
67
IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, IMP::base::Object::_on_destruction();)
68
69
#if IMP_HAS_DEPRECATED
70
//! for backwards compat
71
#define IMP_OBJECT_2(Name) IMP_OBJECT_METHODS(Name)
72
#endif
73
74
//! Define the types for storing sets of objects
75
/** The macro defines the types PluralName and PluralNameTemp.
76
PluralName should be Names unless the English spelling is
77
different.
78
*/
79
#define IMP_OBJECTS(Name, PluralName) \
80
/** Store a set of objects.*/
\
81
typedef IMP::base::Vector<IMP::base::Pointer<Name> > \
82
PluralName; \
83
/** Pass a set of objects.
84
\relates Name */
\
85
typedef IMP::base::Vector<IMP::base::WeakPointer<Name> > \
86
PluralName##Temp;
87
88
#define IMP_GENERIC_OBJECT(Name, lcname, targument, carguments, cparguments) \
89
typedef Generic##Name<targument> Name; \
90
template <class targument> \
91
Generic##Name<targument>* create_##lcname carguments { \
92
return new Generic##Name<targument>cparguments; \
93
}
94
95
//! Declare a ref counted pointer to a new object
96
/** \param[in] Typename The namespace qualified type being declared
97
\param[in] varname The name for the ref counted pointer
98
\param[in] args The arguments to the constructor, or ()
99
if there are none.
100
Please read the documentation for IMP::Pointer before using.
101
*/
102
#define IMP_NEW(Typename, varname, args) \
103
IMP::base::Pointer<Typename> varname(new Typename args)
104
105
#endif
/* IMPBASE_OBJECT_MACROS_H */