IMP  2.3.1
The Integrative Modeling Platform
State.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/State.h \brief A decorator for States.
3  *
4  * Copyright 2007-2014 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_STATE_H
9 #define IMPATOM_STATE_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "atom_macros.h"
13 #include "Hierarchy.h"
14 
15 #include <IMP/base_types.h>
16 #include <IMP/kernel/Particle.h>
17 #include <IMP/kernel/Model.h>
18 #include <IMP/Decorator.h>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! Associate an integer "state" index with a hierarchy node.
23 /**
24  * \note Only one State node is allowed in any path up the tree as nesting
25  * them does not have a clear meaning.
26  */
27 class IMPATOMEXPORT State : public Hierarchy {
28  static IntKey get_index_key();
29 
30  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
31  unsigned int state);
32 
33  void validate();
34 
35  public:
36  IMP_DECORATOR_SETUP_1(State, unsigned int, index);
38 
40  return m->get_has_attribute(get_index_key(), pi);
41  }
42 
43  unsigned int get_state_index() const {
44  return get_model()->get_attribute(get_index_key(), get_particle_index());
45  }
46 };
47 
48 IMP_DECORATORS(State, States, Hierarchies);
49 
50 //! Walk up the hierarchy to find the current state.
51 /** \return the state index, or -1 if there is none. */
52 IMPATOMEXPORT int get_state_index(Hierarchy h);
53 
54 IMPATOM_END_NAMESPACE
55 
56 #endif /* IMPATOM_STATE_H */
Import IMP/kernel/Decorator.h in the namespace.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
A base class for Keys.
Definition: kernel/Key.h:46
Import IMP/kernel/base_types.h in the namespace.
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
int get_state_index(Hierarchy h)
Walk up the hierarchy to find the current state.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
Various important macros for implementing decorators.
Associate an integer "state" index with a hierarchy node.
Definition: State.h:27
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73