00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPATOM_DOMAIN_H
00009 #define IMPATOM_DOMAIN_H
00010
00011 #include "atom_config.h"
00012 #include "Hierarchy.h"
00013 #include <IMP/Decorator.h>
00014
00015 IMPATOM_BEGIN_NAMESPACE
00016
00017
00018
00019
00020
00021 class IMPATOMEXPORT Domain: public Hierarchy
00022 {
00023 struct Data {
00024 Data(): begin("domain_begin"),
00025 end("domain_end"){}
00026 IntKey begin, end;
00027 };
00028 static const Data &get_data();
00029 public:
00030
00031 static Domain setup_particle(Particle *p, Int b, Int e) {
00032 p->add_attribute(get_data().begin, b);
00033 p->add_attribute(get_data().end, e);
00034 if (!Hierarchy::particle_is_instance(p)) {
00035 Hierarchy::setup_particle(p);
00036 }
00037 return Domain(p);
00038 }
00039
00040
00041 static Domain setup_particle(Particle *p, Domain o) {
00042 p->add_attribute(get_data().begin, o.get_begin_index());
00043 p->add_attribute(get_data().end, o.get_end_index());
00044 if (!Hierarchy::particle_is_instance(p)) {
00045 Hierarchy::setup_particle(p);
00046 }
00047 return Domain(p);
00048 }
00049
00050 virtual ~Domain();
00051
00052 static bool particle_is_instance(Particle *p) {
00053 return p->has_attribute(get_data().begin)
00054 && p->has_attribute(get_data().end)
00055 && Hierarchy::particle_is_instance(p);
00056 }
00057
00058
00059 Int get_begin_index() const {
00060 return get_particle()->get_value(get_data().begin);
00061 }
00062
00063
00064 Int get_end_index() const {
00065 return get_particle()->get_value(get_data().end);
00066 }
00067
00068 IMP_DECORATOR(Domain, Hierarchy);
00069 };
00070
00071 IMP_DECORATORS(Domain, Hierarchies);
00072
00073
00074
00075
00076
00077 IMP_OUTPUT_OPERATOR(Domain);
00078
00079 IMPATOM_END_NAMESPACE
00080
00081 #endif