home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.6.1
The Integrative Modeling Platform
IMP Manual
Reference Guide
Modules
Classes
Examples
include
IMP
utility_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/utility_macros.h
3
* \brief Various general useful macros for IMP.
4
*
5
* Copyright 2007-2016 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_UTILITY_MACROS_H
10
#define IMPKERNEL_UTILITY_MACROS_H
11
#include <IMP/kernel_config.h>
12
#include <
IMP/deprecation_macros.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 constructor 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
#define IMP_EXPAND_AND_STRINGIFY(x) IMP_STRINGIFY(x)
33
34
#ifdef IMP_DOXYGEN
35
//! Smart pointer to retain sole ownership of an object through a pointer
36
/** In C++11 mode, this is std::unique_ptr; otherwise, it is std::auto_ptr.
37
Note that these two classes do not have exactly the same interfaces, so
38
you must be careful to use IMP_UNIQUE_PTR only in cases where the two
39
classes behave in the same way (e.g. you cannot copy a unique_ptr, but
40
you can copy an auto_ptr; unique_ptr works with arrays and can
41
be stored in STL containers, unlike auto_ptr).
42
*/
43
#define IMP_UNIQUE_PTR
44
#else
45
#if IMP_COMPILER_HAS_UNIQUE_PTR
46
#define IMP_UNIQUE_PTR std::unique_ptr
47
#else
48
#define IMP_UNIQUE_PTR std::auto_ptr
49
#endif
50
#endif
51
52
#endif
/* IMPKERNEL_UTILITY_MACROS_H */
deprecation_macros.h
Control display of deprecation information.