IMP  2.4.0
The Integrative Modeling Platform
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-2015 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 //! Define the basic things needed by any Object
20 /** This defines
21  - IMP::base::Object::get_version_info()
22  - IMP::base::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::base::VersionInfo get_version_info() const IMP_OVERRIDE { \
29  return ::IMP::base::VersionInfo(get_module_name(), get_module_version()); \
30  } \
31  \
32  protected: \
33  virtual ~Name() { IMP::base::Object::_on_destruction(); } \
34  \
35  public:
36 
37 //! Only to work around a gcc bug
38 #define IMP_OBJECT_NO_WARNING(Name) \
39  public: \
40  virtual std::string get_type_name() const IMP_OVERRIDE { return #Name; } \
41  virtual ::IMP::base::VersionInfo get_version_info() const IMP_OVERRIDE { \
42  return ::IMP::base::VersionInfo(get_module_name(), get_module_version()); \
43  } \
44  void do_show(std::ostream &out) const; \
45  IMP_REF_COUNTED_INLINE_DESTRUCTOR(Name, IMP::base::Object::_on_destruction();)
46 
47 //! Define the types for storing sets of objects
48 /** The macro defines the types PluralName and PluralNameTemp.
49  PluralName should be Names unless the English spelling is
50  different.
51  */
52 #define IMP_OBJECTS(Name, PluralName) \
53  /** Store a set of objects.*/ \
54  typedef IMP::base::Vector<IMP::base::Pointer<Name> > PluralName; \
55  /** Pass a set of objects. \see Name */ \
56  typedef IMP::base::Vector<IMP::base::WeakPointer<Name> > PluralName##Temp;
57 
58 #define IMP_GENERIC_OBJECT(Name, lcname, targument, carguments, cparguments) \
59  typedef Generic##Name<targument> Name; \
60  template <class targument> \
61  Generic##Name<targument> *create_##lcname carguments { \
62  return new Generic##Name<targument> cparguments; \
63  }
64 
65 //! Declare a ref counted pointer to a new object
66 /** \param[in] Typename The namespace qualified type being declared
67  \param[in] varname The name for the ref counted pointer
68  \param[in] args The arguments to the constructor, or ()
69  if there are none.
70  Please read the documentation for IMP::Pointer before using.
71 */
72 #define IMP_NEW(Typename, varname, args) \
73  IMP::base::Pointer<Typename> varname(new Typename args)
74 
75 #endif /* IMPBASE_OBJECT_MACROS_H */
Various general useful macros for IMP.
Logging and error reporting support.
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.