IMP logo
IMP Reference Guide  develop.d247202c1c,2019/10/23
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-2019 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 lists of object pointers
38 /** The macro defines the types PluralName and PluralNameTemp,
39  which are vectors of either reference-counting or non reference-counting
40  pointers to Name objects, respectively.
41  PluralName should be Names unless the English spelling is
42  different.
43  */
44 #define IMP_OBJECTS(Name, PluralName) \
45  /** A vector of reference-counting object pointers.*/ \
46  typedef IMP::Vector<IMP::Pointer<Name> > PluralName; \
47  /** A vector of weak (non reference-counting) pointers to specified objects. \see Name */ \
48  typedef IMP::Vector<IMP::WeakPointer<Name> > PluralName##Temp;
49 
50 #define IMP_GENERIC_OBJECT(Name, lcname, targument, carguments, cparguments) \
51  typedef Generic##Name<targument> Name; \
52  template <class targument> \
53  Generic##Name<targument> *create_##lcname carguments { \
54  return new Generic##Name<targument> cparguments; \
55  }
56 
57 //! Declare a ref counted pointer to a new object
58 /** \param[in] Typename The namespace qualified type being declared
59  \param[in] varname The name for the ref counted pointer
60  \param[in] args The arguments to the constructor, or ()
61  if there are none.
62  Please read the documentation for IMP::Pointer before using.
63 */
64 #define IMP_NEW(Typename, varname, args) \
65  IMP::Pointer<Typename> varname(new Typename args)
66 
67 #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.