Index: kernel/include/IMP/decorators/HierarchyDecorator.h =================================================================== --- kernel/include/IMP/decorators/HierarchyDecorator.h (revision 514) +++ kernel/include/IMP/decorators/HierarchyDecorator.h (working copy) @@ -50,9 +50,9 @@ class IMPDLLEXPORT HierarchyDecorator: public DecoratorBase { IMP_DECORATOR(HierarchyDecorator, DecoratorBase, return true || p, ++p); - IMP_DECORATOR_ARRAY_DECL(child, Int) + IMP_DECORATOR_ARRAY_DECL(child, Particle, Particle*, NULL) protected: - static IntKey parent_key_; + static ParticleKey parent_key_; static IntKey parent_index_key_; public: @@ -62,14 +62,14 @@ if it has no parent. */ This get_parent() const { - IMP_DECORATOR_GET(parent_key_, Int, - return cast(get_model()-> - get_particle(ParticleIndex(VALUE))), + IMP_DECORATOR_GET(parent_key_, Particle*, + return VALUE, return This()); } //! Get the number of children. unsigned int get_number_of_children() const { + // defined by the array macro return internal_get_number_of_child(); } @@ -78,8 +78,8 @@ does not have this child */ This get_child(unsigned int i) const { - return cast(get_model()-> - get_particle(ParticleIndex(internal_get_child(i)))); + // defined by the array macro + return cast(internal_get_child(i)); } Index: kernel/src/decorators/HierarchyDecorator.cpp =================================================================== --- kernel/src/decorators/HierarchyDecorator.cpp (revision 514) +++ kernel/src/decorators/HierarchyDecorator.cpp (working copy) @@ -14,8 +14,8 @@ namespace IMP { -IMP_DECORATOR_ARRAY_DEF(Hierarchy, child, Int); -IntKey HierarchyDecorator::parent_key_; +IMP_DECORATOR_ARRAY_DEF(Hierarchy, child, Particle, Particle*); +ParticleKey HierarchyDecorator::parent_key_; IntKey HierarchyDecorator::parent_index_key_; @@ -101,12 +101,10 @@ //std::cerr << "changing " << std::endl; //std::cerr << "before\n"; //show_hierarchy(*this, std::cerr); - int pi= get_particle()->get_index().get_index(); - int ci= hd.get_particle()->get_index().get_index(); - int nc= internal_add_child(ci); + int nc= internal_add_child(hd.get_particle()); hd.get_particle()->add_attribute(parent_index_key_, nc); - hd.get_particle()->add_attribute(parent_key_, pi); + hd.get_particle()->add_attribute(parent_key_, get_particle()); //std::cerr << "after\n"; //show_hierarchy(*this, std::cerr); return nc; @@ -115,10 +113,10 @@ IMP_DECORATOR_INITIALIZE(HierarchyDecorator, DecoratorBase, { - parent_key_ = IntKey("hierarchy_parent"); + parent_key_ = ParticleKey("hierarchy_parent"); parent_index_key_ = IntKey("hiearchy_parent_index"); IMP_DECORATOR_ARRAY_INIT(HierarchyDecorator, - child, Int); + child, Particle, Particle*); })