IMP
2.0.0
The Integrative Modeling Platform
|
Various general useful macros for IMP. More...
#include <IMP/kernel/kernel_config.h>
#include <IMP/base/check_macros.h>
#include <IMP/base/log_macros.h>
#include <IMP/base/showable_macros.h>
#include <IMP/base/warning_macros.h>
Go to the source code of this file.
Macros to aid with implementing decorators | |
These macros are here to aid in implementation of IMP::Decorator objects. The first two declare/define the expected methods. The remainder help implement basic functions. | |
#define | IMP_DECORATOR(Name, Parent) |
Define the basic things needed by a Decorator. More... | |
#define | IMP_DECORATOR_WITH_TRAITS(Name, Parent, TraitsType, traits_name, default_traits) |
Define the basic things needed by a Decorator which has a traits object. More... | |
#define | IMP_DECORATOR_GET(AttributeKey, Type, has_action, not_has_action) |
Perform actions dependent on whether a particle has an attribute. More... | |
#define | IMP_DECORATOR_SET(AttributeKey, value) |
Set an attribute, creating it if it does not already exist. More... | |
#define | IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType) |
Define methods for getting and setting a particular simple field. More... | |
#define | IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type,ReturnType, default_value) |
Define methods for getting and setting an optional simple field. More... | |
#define | IMP_DECORATORS_DECL(Name, PluralName) |
#define | IMP_DECORATORS_DEF(Name, PluralName) |
#define | IMP_DECORATORS(Name, PluralName, Parent) |
Define the types for storing sets of decorators. More... | |
#define | IMP_DECORATORS_WITH_TRAITS(Name, PluralName, Parent) |
Define the types for storing sets of decorators. More... | |
#define | IMP_SUMMARY_DECORATOR_DECL(Name, Parent, Members) |
Create a decorator that computes some sort of summary info on a set. More... | |
#define | IMP_SUMMARY_DECORATOR_DEF(Name, Parent, Members, create_modifier) |
Copyright 2007-2013 IMP Inventors. All rights reserved.
Definition in file kernel/decorator_macros.h.
#define IMP_DECORATOR | ( | Name, | |
Parent | |||
) |
The macro defines the following methods
It also declares:
Finally, it expects methods corresponding to
You also implement static methods get_x_key()
to return each of the keys used. These static methods, which must be defined in the .cpp file, should declare the key itself as a
static
member variable to avoid initializing the key if the decorator is not used.
See IMP::Decorator for a more detailed description of decorators.
[in] | Name | is the name of the decorator, such as XYZR |
[in] | Parent | The class name for the parent of this class, typically Decorator |
Definition at line 53 of file kernel/decorator_macros.h.
#define IMP_DECORATOR_GET | ( | AttributeKey, | |
Type, | |||
has_action, | |||
not_has_action | |||
) |
A common pattern is to check if a particle has a particular attribute, do one thing if it does and another if it does not. This macro implements that pattern. It requires that the method get_particle() return the particle being used.
[in] | AttributeKey | The key for the attribute |
[in] | Type | The type for the attribute ("Int", "Float", "String") |
[in] | has_action | The action to take if the Particle has the attribute. The attribute value is stored in the variable VALUE. |
[in] | not_has_action | The action to take if the Particle does not have the attribute. |
Definition at line 152 of file kernel/decorator_macros.h.
#define IMP_DECORATOR_GET_SET | ( | name, | |
AttributeKey, | |||
Type, | |||
ReturnType | |||
) |
This macro defines methods to get and set a particular attribute.
[in] | name | The lower case name of the attribute |
[in] | AttributeKey | The AttributeKey object controlling the attribute. |
[in] | Type | The type of the attribute (upper case). |
[in] | ReturnType | The type to return from the get. |
Definition at line 198 of file kernel/decorator_macros.h.
#define IMP_DECORATOR_GET_SET_OPT | ( | name, | |
AttributeKey, | |||
Type, | |||
ReturnType, | |||
default_value | |||
) |
See IMP_DECORATOR_GET_SET(). The difference is that here you can provide a default value to use if the decorator does not have the attribute.
[in] | name | The lower case name of the attribute |
[in] | AttributeKey | The expression to get the required attribute key. |
[in] | Type | The type of the attribute (upper case). |
[in] | ReturnType | The type to return from the get. |
[in] | default_value | The value returned if the attribute is missing. |
Definition at line 220 of file kernel/decorator_macros.h.
#define IMP_DECORATOR_SET | ( | AttributeKey, | |
value | |||
) |
Another common pattern is to have an assumed value if the attribute is not there. Then, you sometimes need to set the value whether it is there or not.
Definition at line 172 of file kernel/decorator_macros.h.
#define IMP_DECORATOR_WITH_TRAITS | ( | Name, | |
Parent, | |||
TraitsType, | |||
traits_name, | |||
default_traits | |||
) |
This macro is the same as IMP_DECORATOR() except that an extra object of type TraitsType is passed after the particle to
Definition at line 92 of file kernel/decorator_macros.h.
#define IMP_DECORATORS | ( | Name, | |
PluralName, | |||
Parent | |||
) |
The macro defines the types PluralName and PluralNameTemp.
Definition at line 241 of file kernel/decorator_macros.h.
#define IMP_DECORATORS_WITH_TRAITS | ( | Name, | |
PluralName, | |||
Parent | |||
) |
The macro defines the types PluralName and PluralNameTemp.
Definition at line 266 of file kernel/decorator_macros.h.
#define IMP_SUMMARY_DECORATOR_DECL | ( | Name, | |
Parent, | |||
Members | |||
) |
Examples include a centroid or a cover for a set of particles.
[in] | Name | The name for the decorator |
[in] | Parent | the parent decorator type |
[in] | Members | the way to pass a set of particles in |
Definition at line 286 of file kernel/decorator_macros.h.
#define IMP_SUMMARY_DECORATOR_DEF | ( | Name, | |
Parent, | |||
Members, | |||
create_modifier | |||
) |
See IMP_SUMMARY_DECORATOR_DECL()
[in] | Name | The name for the decorator |
[in] | Parent | the parent decorator type |
[in] | Members | the way to pass a set of particles in |
[in] | create_modifier | the statements to create the modifier which computes the summary info. It should be called mod. |
Definition at line 317 of file kernel/decorator_macros.h.