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