IMP  2.1.0
The Integrative Modeling Platform
Typed.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/Typed.h \brief A particle with a user-defined type.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPCORE_TYPED_H
9 #define IMPCORE_TYPED_H
10 
11 #include <IMP/core/core_config.h>
12 #include <IMP/decorator_macros.h>
13 #include <IMP/key_macros.h>
14 
15 #include <IMP/Decorator.h>
16 #include <IMP/algebra/Vector3D.h>
18 #include <vector>
19 #include <limits>
20 
21 IMPCORE_BEGIN_NAMESPACE
22 
23 // TODO: why this number? how can we tell it's unique
24 #define IMP_PARTICLE_TYPE_INDEX 34897493
25 
26 /** A kernel::ParticleType is an IMP::kernel::Key object for identifying types
27  of
28  particles by strings. The kernel::ParticleType key is used to type particles
29  within
30  the Typed decorator */
31 typedef Key<IMP_PARTICLE_TYPE_INDEX, true> ParticleType;
33 
34 //! A decorator for classifying particles in your system.
35 /** This decorator
36  */
37 class IMPCOREEXPORT Typed : public Decorator {
38  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
39  ParticleType t) {
40  m->add_attribute(get_type_key(), pi, t.get_index());
41  }
42 
43  public:
44  static IntKey get_type_key();
45 
48 
50  return m->get_has_attribute(get_type_key(), pi);
51  }
52 
53  ParticleType get_type() const {
54  return ParticleType(
55  get_model()->get_attribute(get_type_key(), get_particle_index()));
56  }
57 };
58 
59 IMP_DECORATORS(Typed, Typeds, kernel::ParticlesTemp);
60 
61 IMPCORE_END_NAMESPACE
62 
63 #endif /* IMPCORE_TYPED_H */
Import IMP/kernel/key_macros.h in the namespace.
Import IMP/kernel/Decorator.h in the namespace.
A base class for Keys.
Definition: kernel/Key.h:46
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
static bool get_is_setup(Particle *p)
Return true if the particle can be cast to the decorator.
Import IMP/kernel/decorator_macros.h in the namespace.
Simple 3D transformation class.
Key< 34897493, true > ParticleType
Definition: Typed.h:31
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Simple 3D vector class.
A decorator for classifying particles in your system.
Definition: Typed.h:37
#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.