A decorator for helping deal with a hierarchy.
See HierarchyTraits for an example of how to define a custom hierarchy and Hierarchy for a hierarchy for molecules.
Examples: custom hierarchy
Inheritance diagram for IMP::core::Hierarchy:Public Types | |
|
typedef IMP::internal::IndexingIterator < ChildAttrArrayAccessor > | ChildIterator |
| typedef HierarchyTraits | DecoratorTraits |
| typedef Decorator | DecoratorTraitsBase |
Public Member Functions | |
| Hierarchy (const HierarchyTraits &tr) | |
| Hierarchy (::IMP::Particle *p, const HierarchyTraits &tr=get_default_traits()) | |
| unsigned int | add_child (Hierarchy t) |
| void | add_child_at (Hierarchy t, unsigned int idx) |
| void | add_children (const GenericHierarchies &et) |
| ChildIterator | children_begin () const |
| ChildIterator | children_end () const |
| void | clear_children () |
| Hierarchy | get_child (unsigned int i) const |
| int | get_child_index (Hierarchy c) const |
| Get the index of a specific child in this particle. | |
| GenericHierarchies | get_children () const |
| const DecoratorTraits & | get_decorator_traits () const |
| unsigned int | get_number_of_children () const |
| Hierarchy | get_parent () const |
| int | get_parent_index () const |
| Get the index of this particle in the list of children. | |
| const HierarchyTraits & | get_traits () const |
| void | remove_child (Hierarchy t) |
Static Public Member Functions | |
| static Hierarchy | decorate_particle (::IMP::Particle *p, const HierarchyTraits &tr=get_default_traits()) |
| static const DecoratorTraits & | get_default_decorator_traits () |
| static const HierarchyTraits & | get_default_traits () |
| Get the default hierarchy traits. | |
| static bool | particle_is_instance (Particle *p, HierarchyTraits traits=Hierarchy::get_default_traits()) |
| static Hierarchy | setup_particle (Particle *p, HierarchyTraits traits=Hierarchy::get_default_traits()) |
| Add the needed attributes to a particle. | |
| static Hierarchy | setup_particle (Particle *p, const Particles &children, HierarchyTraits traits=Hierarchy::get_default_traits()) |
| Add the needed attributes to a particle and add the particles as children. | |
Related Functions | |
| (Note that these are not member functions.) | |
| template<class HD , class F > | |
| HD | find_breadth_first (HD h, F f) |
| Find the first node which matches some criteria. | |
| template<class Out , class F > | |
| Out | gather (Hierarchy h, F f, Out out) |
| Gather all the particles in the hierarchy which meet some criteria. | |
| template<class Out , class K , class V > | |
| Out | gather_by_attribute (Hierarchy h, K k, V v, Out out) |
| Gather all the particles in the hierarchy which match on an attribute. | |
| template<class Out , class K0 , class V0 , class K1 , class V1 > | |
| Out | gather_by_attributes (Hierarchy h, K0 k0, V0 v0, K1 k1, V1 v1, Out out) |
| Gather all the particles in the hierarchy which match on two attributes. | |
| template<class Out , class F > | |
| Out | gather_slice (Hierarchy h, F f, Out out) |
| Gather all the particles in the hierarchy which meet some criteria. | |
| GenericHierarchiesTemp | get_all_descendants (Hierarchy mhd) |
| Get all the particles in the subtree. | |
| GenericHierarchiesTemp | get_internal (Hierarchy mhd) |
| Get all the non-leaves of the bit of hierarchy. | |
| GenericHierarchiesTemp | get_leaves (Hierarchy mhd) |
| Get all the leaves of the bit of hierarchy. | |
| Hierarchy | get_root (Hierarchy h) |
| Return the root of the hierarchy. | |
| template<class ND > | |
| std::ostream & | show (Hierarchy h, std::ostream &out=std::cout) |
| Print the hierarchy using a given decorator as to display each node. | |
| template<class HD , class F > | |
| F | visit_breadth_first (HD d, F f) |
| Apply the visitor to each particle, breadth first. | |
| template<class HD , class F > | |
| F | visit_breadth_first_with_data (HD d, F f, typename F::result_type i) |
| Apply functor F to each particle, traversing the hierarchy breadth first. | |
| template<class HD , class F > | |
| F | visit_depth_first (HD d, F f) |
| Apply functor F to each particle, traversing the hierarchy depth first. | |
| template<class HD , class F > | |
| F | visit_depth_first_with_data (HD d, F f, typename F::result_type i) |
| Apply functor F to each particle, traversing the hierarchy depth first. | |
| int IMP::core::Hierarchy::get_child_index | ( | Hierarchy | c | ) | const |
Get the index of a specific child in this particle.
This takes linear time.
| Hierarchy IMP::core::Hierarchy::get_parent | ( | ) | const |
Reimplemented in IMP::atom::Hierarchy.
| int IMP::core::Hierarchy::get_parent_index | ( | ) | const |
Get the index of this particle in the list of children.
| static bool IMP::core::Hierarchy::particle_is_instance | ( | Particle * | p, |
| HierarchyTraits | traits = Hierarchy::get_default_traits() |
||
| ) | [static] |
Check if the particle has the needed attributes for a cast to succeed
| static Hierarchy IMP::core::Hierarchy::setup_particle | ( | Particle * | p, |
| const Particles & | children, | ||
| HierarchyTraits | traits = Hierarchy::get_default_traits() |
||
| ) | [static] |
Add the needed attributes to a particle and add the particles as children.
The particles can be, but don't have to be Hierarchy particles already.
| GenericHierarchiesTemp get_leaves | ( | Hierarchy | mhd | ) | [related] |
Get all the leaves of the bit of hierarchy.
The leaves are returned in the obvious order (first child before second child).