IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
object_macros.h File Reference

Helper macros for implementing IMP Objects. More...

#include <IMP/kernel_config.h>
#include "doxygen_macros.h"
#include "ref_counted_macros.h"
#include "Vector.h"
#include "Pointer.h"
#include "WeakPointer.h"
#include "SetLogState.h"
+ Include dependency graph for object_macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMP_GENERIC_OBJECT(Name, lcname, targument, carguments, cparguments)
 Typedefs a default instantiation for a generic (templated) object. More...
 
#define IMP_NEW(Typename, varname, args)   IMP::Pointer<Typename> varname(new Typename args)
 Declare a ref counted pointer to a new object. More...
 
#define IMP_OBJECT_METHODS(Name)
 Define the basic things needed by any Object. More...
 
#define IMP_OBJECT_SERIALIZE_DECL(Name)
 Declare methods needed for serialization of Object pointers. More...
 
#define IMP_OBJECT_SERIALIZE_IMPL(Name)
 Add machinery needed for serialization of Object pointers. More...
 
#define IMP_OBJECTS(Name, PluralName)
 Define the types for storing lists of object pointers. More...
 

Detailed Description

Helper macros for implementing IMP Objects.

Copyright 2007-2022 IMP Inventors. All rights reserved.

Definition in file object_macros.h.

Macro Definition Documentation

#define IMP_GENERIC_OBJECT (   Name,
  lcname,
  targument,
  carguments,
  cparguments 
)

Typedefs a default instantiation for a generic (templated) object.

Define type [Name] to be an instantiation of Generic[Name] with template targument, and a function create_[lcname]() that generates a newly allocated object of type [Name], taking parameters [carguments] and internally paassing [cparguments] to the constructor.

Note
doxygen documentation prior to this macro will be applied to the type definition

Definition at line 60 of file object_macros.h.

#define IMP_NEW (   Typename,
  varname,
  args 
)    IMP::Pointer<Typename> varname(new Typename args)

Declare a ref counted pointer to a new object.

Parameters
[in]TypenameThe namespace qualified type being declared
[in]varnameThe name for the ref counted pointer
[in]argsThe arguments to the constructor, or () if there are none. Please read the documentation for IMP::Pointer before using.
Examples:
core/simple.cpp.

Definition at line 74 of file object_macros.h.

#define IMP_OBJECT_METHODS (   Name)

Define the basic things needed by any Object.

This defines

Definition at line 25 of file object_macros.h.

#define IMP_OBJECT_SERIALIZE_DECL (   Name)

Declare methods needed for serialization of Object pointers.

When an Object subclass is serialized via an IMP::Pointer, the serialization subsystem needs to know the most derived type so that the full information is saved/loaded. This macro ensures that the necessary machinery is added, and should be placed in the header file inside the declaration of the Object subclass. It is similar to cereal's CEREAL_REGISTER_TYPE macro, but stores the type information in precisely one place (the IMP::Object class) rather than relying on the linker to keep this information unique, as cereal attempts to do.

This macro needs to be paired with IMP_OBJECT_SERIALIZE_IMPL, which is usually placed in the corresponding .cpp file for the class.

See Also
IMP_OBJECT_SERIALIZE_IMPL
Parameters
[in]NameThe name of the class.

Definition at line 95 of file object_macros.h.

#define IMP_OBJECT_SERIALIZE_IMPL (   Name)
Value:
bool Name::dummy_serialize_init_ = Object::register_serialize( \
typeid(Name), #Name, Name::save_cereal, Name::load_cereal);

Add machinery needed for serialization of Object pointers.

See Also
IMP_OBJECT_SERIALIZE_DECL
Parameters
[in]NameThe fully-qualified name of the class.

Definition at line 114 of file object_macros.h.

#define IMP_OBJECTS (   Name,
  PluralName 
)

Define the types for storing lists of object pointers.

The macro defines the types PluralName and PluralNameTemp, which are vectors of either reference-counting or non reference-counting pointers to Name objects, respectively. PluralName should be Names unless the English spelling is different.

Definition at line 44 of file object_macros.h.