IMP logo
IMP Reference Guide  2.6.0
The Integrative Modeling Platform
object_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/object_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_OBJECT_MACROS_H
10 #define IMPKERNEL_OBJECT_MACROS_H
11 #include <IMP/kernel_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 //! Define the basic things needed by any Object
20 /** This defines
21  - IMP::Object::get_version_info()
22  - IMP::Object::get_type_name()
23  - a protected destructor
24 */
25 #define IMP_OBJECT_METHODS(Name) \
26  public: \
27  virtual std::string get_type_name() const IMP_OVERRIDE { return #Name; } \
28  virtual ::IMP::VersionInfo get_version_info() const IMP_OVERRIDE { \
29  return ::IMP::VersionInfo(get_module_name(), get_module_version()); \
30  } \
31  \
32  protected: \
33  virtual ~Name() { IMP::Object::_on_destruction(); } \
34  \
35  public:
36 
37 //! Define the types for storing sets of objects
38 /** The macro defines the types PluralName and PluralNameTemp.
39  PluralName should be Names unless the English spelling is
40  different.
41  */
42 #define IMP_OBJECTS(Name, PluralName) \
43  /** Store a set of objects.*/ \
44  typedef IMP::Vector<IMP::Pointer<Name> > PluralName; \
45  /** Pass a set of objects. \see Name */ \
46  typedef IMP::Vector<IMP::WeakPointer<Name> > PluralName##Temp;
47 
48 #define IMP_GENERIC_OBJECT(Name, lcname, targument, carguments, cparguments) \
49  typedef Generic##Name<targument> Name; \
50  template <class targument> \
51  Generic##Name<targument> *create_##lcname carguments { \
52  return new Generic##Name<targument> cparguments; \
53  }
54 
55 //! Declare a ref counted pointer to a new object
56 /** \param[in] Typename The namespace qualified type being declared
57  \param[in] varname The name for the ref counted pointer
58  \param[in] args The arguments to the constructor, or ()
59  if there are none.
60  Please read the documentation for IMP::Pointer before using.
61 */
62 #define IMP_NEW(Typename, varname, args) \
63  IMP::Pointer<Typename> varname(new Typename args)
64 
65 #endif /* IMPKERNEL_OBJECT_MACROS_H */
Various general useful macros for IMP.
A class to change and restore log state.
Various general useful macros for IMP.
A nullptr-initialized pointer to an Object.
A class for storing lists of IMP items.
A nullptr-initialized pointer to an IMP Object.