00001 /** 00002 * \file Mass.h 00003 * \brief A decorator for particles with mass 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 */ 00007 00008 #ifndef IMPATOM_MASS_H 00009 #define IMPATOM_MASS_H 00010 00011 #include "atom_config.h" 00012 00013 #include <IMP/PairContainer.h> 00014 #include <IMP/SingletonContainer.h> 00015 #include <IMP/Decorator.h> 00016 00017 IMPATOM_BEGIN_NAMESPACE 00018 00019 //! Add mass to a particle 00020 /** The mass of the particle is assumed to be in Daltons. 00021 */ 00022 class IMPATOMEXPORT Mass: public Decorator 00023 { 00024 public: 00025 static Mass setup_particle(Particle *p, double mass) { 00026 p->add_attribute(get_mass_key(), mass); 00027 return Mass(p); 00028 } 00029 00030 static bool particle_is_instance(Particle *p) { 00031 return p->has_attribute(get_mass_key()); 00032 } 00033 00034 Float get_mass() const { 00035 return get_particle()->get_value(get_mass_key()); 00036 } 00037 00038 void set_mass(Float d) { 00039 get_particle()->set_value(get_mass_key(), d); 00040 } 00041 00042 IMP_DECORATOR(Mass, Decorator); 00043 00044 static FloatKey get_mass_key(); 00045 }; 00046 00047 00048 IMPATOM_END_NAMESPACE 00049 00050 #endif /* IMPATOM_MASS_H */