IMP logo
IMP Reference Guide  2.6.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-2016 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 
14 #include <IMP/Decorator.h>
15 #include <IMP/algebra/Vector3D.h>
17 #include <vector>
18 #include <limits>
19 
20 IMPCORE_BEGIN_NAMESPACE
21 
22 // TODO: why this number? how can we tell it's unique
23 #define IMP_PARTICLE_TYPE_INDEX 34897493
24 
25 /** A ParticleType is an IMP::Key object for identifying types
26  of
27  particles by strings. The ParticleType key is used to type particles
28  within
29  the Typed decorator */
32 
33 //! A decorator for classifying particles in your system.
34 /** This decorator
35  */
36 class IMPCOREEXPORT Typed : public Decorator {
37  static void do_setup_particle(Model *m, ParticleIndex pi,
38  ParticleType t) {
39  m->add_attribute(get_type_key(), pi, t.get_index());
40  }
41 
42  public:
43  static IntKey get_type_key();
44 
47 
48  static bool get_is_setup(Model *m, ParticleIndex pi) {
49  return m->get_has_attribute(get_type_key(), pi);
50  }
51 
52  ParticleType get_type() const {
53  return ParticleType(
54  get_model()->get_attribute(get_type_key(), get_particle_index()));
55  }
56 };
57 
58 IMP_DECORATORS(Typed, Typeds, ParticlesTemp);
59 
60 IMPCORE_END_NAMESPACE
61 
62 #endif /* IMPCORE_TYPED_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Various general useful macros for IMP.
A base class for Keys.
Definition: Key.h:46
Simple 3D transformation class.
Key< 34897493, true > ParticleType
Definition: Typed.h:30
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:118
#define IMP_DECORATOR_METHODS(Name, Parent)
Simple 3D vector class.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
A decorator for classifying particles in your system.
Definition: Typed.h:36