IMP
2.1.1
The Integrative Modeling Platform
|
#include <IMP/kernel/Decorator.h>
Public Member Functions | |
ParticleIndex | get_particle_index () const |
Protected Member Functions | |
Decorator (kernel::Model *m, ParticleIndex pi) | |
Decorator (ParticleAdaptor p) | |
Methods provided by the Decorator class | |
The following methods are provided by the Decorator class. | |
Particle * | get_particle () const |
Model * | get_model () const |
Returns the Model containing the particle. | |
Methods that all decorators must have | |
All decorators must have the following methods. Decorators which are parameterized (for example IMP::core::XYZR) take an (optional) extra parameter after the Particle in setup_particle(), and get_is_setup().
| |
Decorator (Particle *p) | |
Decorator () | |
static bool | get_is_setup (Particle *p) |
Return true if the particle can be cast to the decorator. More... | |
Representation of the structure in IMP
is via a collection of Particle objects. However, since particles are general purpose, they provide a basic set of tools for managing the data (e.g. IMP::kernel::Model::add_attribute(), IMP::kernel::Model::get_value() etc). Decorators wrap (or “decorate”) particles to provide a much richer interface. For example, most particles have Cartesian coordinates. The class IMP::core::XYZ decorates such a particle to provide functions to get and set the Cartesian coordinates as well as compute distances between particles.
get_is_setup()
and setup_particle()
functions mentioned below can take any of either an IMP::kernel::Model* and IMP::kernel::ParticleIndex pair, an IMP::kernel::Paricle* or another decorator to identify the particle. We use various of those below.Dealing with decorators and particles has two main parts
To set up a particle to be used with the IMP::core::XYZ decorator we do
The method calls also decorates the particle and returns the decorator which can now be used to manipulate the particle. For example we can access the coordinates (0,2,3) by doing
We now say the particle is an XYZ particle. If that particle is encountered later when we do not have the existing decorator available, we can decorate it again (since it is already set up) by doing
If you do not know if p
has been set up for the XYZ decorator, you can ask with
More abstractly, decorators can be used to
To see a list of all available decorators and to see what functions all decorators have, look at the list of classes which inherit from IMP::Decorator, below.
See the IMP::example::ExampleDecorator example for how to implement a simple decorator.
if
statements.A decorator can be cast to a IMP::kernel::Particle* in C++. You have to use the Decorator::get_particle() function in Python.
See example::ExampleDecorator to see what a minimal decorator looks like.
Definition at line 114 of file kernel/Decorator.h.
IMP::kernel::Decorator::Decorator | ( | Particle * | p | ) |
Create an instance of the Decorator from the particle that has already been set up. The particle must have been set up already (eg get_is_setup(p) must be true), but this is not necessarily checked.
IMP::kernel::Decorator::Decorator | ( | ) |
The default constructor must be defined and create a nullptr decorator, analogous to a nullptr
pointer in C++ or a None
object in Python.
|
static |
That is, if get_is_setup() returns true
, then it is legal to construct an instance of the decorator with that particle. If not, setup_particle() must be called first.
Particle* IMP::kernel::Decorator::get_particle | ( | ) | const |
Returns the particle decorated by this decorator. Returns the particle decorated by this decorator.
Definition at line 172 of file kernel/Decorator.h.