IMP  2.4.0
The Integrative Modeling Platform
Copy.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Copy.h
3  * \brief A decorator for keeping track of copies of a molecule.
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_COPY_H
10 #define IMPATOM_COPY_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include "../macros.h"
14 
15 #include "Molecule.h"
16 #include <IMP/Decorator.h>
17 #include <vector>
18 #include <limits>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! A decorator for keeping track of copies of a molecule.
23 /** This decorator is for differentiating and keeping track
24  of identity when there are multiple copies of
25  molecule in the system. It should only be applied to
26  Molecule particles.
27  */
28 class IMPATOMEXPORT Copy : public Molecule {
29  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
30  int number) {
31  m->add_attribute(get_copy_index_key(), pi, number);
33  }
34 
35  public:
36  static IntKey get_copy_index_key();
37 
39  /** Create a decorator for the numberth copy. */
41 
42  static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi) {
43  return m->get_has_attribute(get_copy_index_key(), pi);
44  }
45 
46  int get_copy_index() const {
47  return get_particle()->get_value(get_copy_index_key());
48  }
49 };
50 
51 IMP_DECORATORS(Copy, Copies, kernel::ParticlesTemp);
52 
53 //! Walk up the hierarchy to find the current copy index.
54 /** \return the copy index, or -1 if there is none.
55  */
56 IMPATOMEXPORT int get_copy_index(Hierarchy h);
57 
58 IMPATOM_END_NAMESPACE
59 
60 #endif /* IMPATOM_COPY_H */
Import IMP/kernel/Decorator.h in the namespace.
A base class for Keys.
Definition: kernel/Key.h:46
Particle * get_particle() const
Returns the particle decorated by this decorator.
#define IMP_DECORATOR_METHODS(Name, Parent)
A decorator for Molecules.
A decorator for keeping track of copies of a molecule.
Definition: Copy.h:28
static Molecule setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: Molecule.h:37
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
int Int
Basic integer value.
Definition: types.h:35
int get_copy_index(Hierarchy h)
Walk up the hierarchy to find the current copy index.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
A decorator for a molecule.
Definition: Molecule.h:24
#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