IMP logo
IMP Reference Guide  2.5.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(Model *m, 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(Model *m, 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, 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 */
The base class for decorators.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
A decorator for Molecules.
static Molecule setup_particle(Model *m, ParticleIndex pi)
Definition: Molecule.h:37
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A decorator for keeping track of copies of a molecule.
Definition: Copy.h:28
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:169
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
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.
A decorator for a molecule.
Definition: Molecule.h:24