IMP  2.4.0
The Integrative Modeling Platform
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-2015 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 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 #endif /* IMPBASE_UTILITY_MACROS_H */
Control display of deprecation information.