IMP  2.0.1
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-2013 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 {
29  public:
30 
31  static IntKey get_copy_index_key();
32 
34 
35  /** Create a decorator for the numberth copy. */
36  static Copy setup_particle(Particle *p, int number) {
37  p->add_attribute(get_copy_index_key(),number);
39  return Copy(p);
40  }
41 
42  static bool particle_is_instance(Particle *p) {
43  return p->has_attribute(get_copy_index_key());
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 
54 IMPATOM_END_NAMESPACE
55 
56 
57 
58 #endif /* IMPATOM_COPY_H */