#include <composite.h>
Inheritance diagram for Composite:
Modifying and Accessing the Tree | |
void | set (const Composite &composite, bool deep=true) throw () |
Assignment. | |
Composite & | operator= (const Composite &composite) throw () |
Assignment operator. | |
void | get (Composite &composite, bool deep=true) const throw () |
Assignment of a tree to another. | |
Size | getDegree () const throw () |
Return the degree of the node. | |
Size | count (const KernelPredicateType &predicate) const throw () |
Count the number of nodes fulfilling a predicate in this subtree. | |
Size | countDescendants () const throw () |
Count the number of descendants. | |
Size | getPathLength (const Composite &composite) const throw () |
Get the length of the path between two composite objects. | |
Size | getDepth () const throw () |
Get the depth of this item in its tree. | |
Size | getHeight () const throw () |
Get the height of this item in its tree. | |
Composite & | getRoot () throw () |
Get the root of this item. | |
const Composite & | getRoot () const throw () |
Get a const reference to the root of this item. | |
Composite * | getLowestCommonAncestor (const Composite &composite) throw () |
Get the lowest common ancestor of this item with an other. | |
const Composite * | getLowestCommonAncestor (const Composite &composite) const throw () |
Get a const reference to the lowest common ancestor of this item with an other. | |
template<typename T> | |
T * | getAncestor (const T &) throw () |
Find the first ancestor of type T. | |
template<typename T> | |
const T * | getAncestor (const T &) const throw () |
Find the first ancestor of type T (const method). | |
template<typename T> | |
T * | getPrevious (const T &) throw () |
Find the nearest previous composite of type T. | |
template<typename T> | |
const T * | getPrevious (const T &dummy) const throw () |
Find the nearest previous composite of type T (const method). | |
template<typename T> | |
T * | getNext (const T &) throw () |
Find the next composite of type T. | |
template<typename T> | |
const T * | getNext (const T &dummy) const throw () |
Find the next composite of type T (const method). | |
Composite * | getParent () throw () |
Return the composite's parent. | |
const Composite * | getParent () const throw () |
Return the composite's parent (const method). | |
Composite * | getChild (Index index) throw () |
Return the index th child of this composite. | |
const Composite * | getChild (Index index) const throw () |
Return a const pointer to the index th child of this composite. | |
Composite * | getSibling (Index index) throw () |
Return a pointer to the sibling index positions from this composite. | |
const Composite * | getSibling (Index index) const throw () |
Return a const pointer to the sibling index positions from this composite. | |
Composite * | getFirstChild () throw () |
Return a pointer to the first child. | |
const Composite * | getFirstChild () const throw () |
Return a const pointer to the first child. | |
Composite * | getLastChild () throw () |
Return a pointer to the last child. | |
const Composite * | getLastChild () const throw () |
Return a const pointer to the last child. | |
const PreciseTime & | getModificationTime () const throw () |
Return the time of last modification. | |
const PreciseTime & | getSelectionTime () const throw () |
Return the time of last change of selection. | |
void | stamp (StampType stamp=BOTH) throw () |
Modify a time stamp. | |
void | prependChild (Composite &composite) throw () |
Insert a composite as the first child of this composite. | |
void | appendChild (Composite &composite) throw () |
Insert a composite as the last child of this composite. | |
void | insertBefore (Composite &composite) throw () |
Insert a node before this node. | |
void | insertAfter (Composite &composite) throw () |
Insert a node after this node. | |
void | spliceBefore (Composite &composite) throw () |
Prepend all children of composite to the children of this composite. | |
void | spliceAfter (Composite &composite) throw () |
Append all children of composite to the children of this composite. | |
void | splice (Composite &composite) throw () |
Insert the children of composite into this composite. | |
bool | removeChild (Composite &child) throw () |
Remove a child from its parent. | |
Size | removeSelected () throw () |
Remove selected subcomposites. | |
void | replace (Composite &composite) throw () |
This instance and its subtree is removed form its tree and replaced by composite and its subtree. | |
void | swap (Composite &composite) throw () |
Swap the contents of two composites. | |
virtual void | select () throw () |
Select a composite. | |
virtual void | deselect () throw () |
Deselect a composite. | |
bool | insertParent (Composite &parent, Composite &first, Composite &last, bool destroy_parent=true) throw () |
Insert a new parent node. | |
Public Types | |
typedef ForwardIterator< Composite, Composite, Composite *, AncestorIteratorTraits > | AncestorIterator |
typedef ConstForwardIterator< Composite, Composite, Composite *, AncestorIteratorTraits > | AncestorConstIterator |
typedef BidirectionalIterator< Composite, Composite, Composite *, ChildCompositeIteratorTraits > | ChildCompositeIterator |
typedef ConstBidirectionalIterator< Composite, Composite, Composite *, ChildCompositeIteratorTraits > | ChildCompositeConstIterator |
typedef std::reverse_iterator< ChildCompositeIterator > | ChildCompositeReverseIterator |
typedef std::reverse_iterator< ChildCompositeConstIterator > | ChildCompositeConstReverseIterator |
typedef BidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits > | CompositeIterator |
typedef ConstBidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits > | CompositeConstIterator |
typedef std::reverse_iterator< CompositeIterator > | CompositeReverseIterator |
typedef std::reverse_iterator< CompositeConstIterator > | CompositeConstReverseIterator |
Type Definitions and Enums | |
typedef UnaryPredicate< Composite > | KernelPredicateType |
Composite predicate type. | |
enum | StampType { MODIFICATION = 1, SELECTION = 2, BOTH = 3 } |
Time stamp type. More... | |
Public Member Functions | |
AncestorIterator | beginAncestor () throw () |
AncestorIterator | endAncestor () throw () |
AncestorConstIterator | beginAncestor () const throw () |
AncestorConstIterator | endAncestor () const throw () |
ChildCompositeIterator | beginChildComposite () throw () |
ChildCompositeIterator | endChildComposite () throw () |
ChildCompositeConstIterator | beginChildComposite () const throw () |
ChildCompositeConstIterator | endChildComposite () const throw () |
ChildCompositeReverseIterator | rbeginChildComposite () throw () |
ChildCompositeReverseIterator | rendChildComposite () throw () |
ChildCompositeConstReverseIterator | rbeginChildComposite () const throw () |
ChildCompositeConstReverseIterator | rendChildComposite () const throw () |
CompositeIterator | beginComposite () throw () |
CompositeIterator | endComposite () throw () |
CompositeConstIterator | beginComposite () const throw () |
CompositeConstIterator | endComposite () const throw () |
CompositeReverseIterator | rbeginComposite () throw () |
CompositeReverseIterator | rendComposite () throw () |
CompositeConstReverseIterator | rbeginComposite () const throw () |
CompositeConstReverseIterator | rendComposite () const throw () |
Construction and Destruction | |
Composite () throw () | |
Default constructor. | |
Composite (const Composite &composite, bool deep=true) throw () | |
Copy constructor. | |
virtual | ~Composite () throw () |
Destructor. | |
virtual void | clear () throw () |
Clear the composite properties. | |
virtual void | destroy () throw () |
Destroy the composite. | |
void | destroy (bool virtual_destroy) throw () |
Non-virtual destroy method. | |
void * | clone (Composite &root) const throw () |
Clone with a predicate. | |
Persistence | |
virtual void | persistentWrite (PersistenceManager &pm, const char *name=0) const throw (Exception::GeneralException) |
Write a persistent copy of the object. | |
virtual void | persistentRead (PersistenceManager &pm) throw (Exception::GeneralException) |
Read a persistent object. | |
Predicates | |
bool | operator== (const Composite &composite) const throw () |
Equality operator. | |
bool | operator!= (const Composite &composite) const throw () |
Inequality operator. | |
bool | isEmpty () const throw () |
Return true if the node does not contain children. | |
bool | isRoot () const throw () |
Return true if the node has no parent. | |
bool | isRootOf (const Composite &composite) const throw () |
Return true if the node is root of composite. | |
bool | isInterior () const throw () |
Return true if the node is not the root or a leaf. | |
bool | hasChild () const throw () |
Return true if the node has a child. | |
bool | isChildOf (const Composite &composite) const throw () |
Return true if the node has the parent composite . | |
bool | isFirstChild () const throw () |
Return true if the node is the first child of its parent. | |
bool | isFirstChildOf (const Composite &composite) const throw () |
Return true if the node is the first child of composite . | |
bool | isLastChild () const throw () |
Return true if the node is the last child of its parent. | |
bool | isLastChildOf (const Composite &composite) const throw () |
Return true if the node is the last child of composite . | |
bool | hasParent () const throw () |
Return true if the node has a parent. | |
bool | isParentOf (const Composite &composite) const throw () |
Return true if the node is the parent of composite . | |
bool | hasSibling () const throw () |
Return true if the node has a sibling. | |
bool | isSiblingOf (const Composite &composite) const throw () |
Return true if the node is a sibling of composite . | |
bool | hasPreviousSibling () const throw () |
Return true if the node has a previous sibling. | |
bool | isPreviousSiblingOf (const Composite &composite) const throw () |
Return true if the node is a previous sibling of composite . | |
bool | hasNextSibling () const throw () |
Return true if the node has a previous sibling. | |
bool | isNextSiblingOf (const Composite &composite) const throw () |
Return true if the node is a next sibling of composite . | |
bool | isDescendantOf (const Composite &composite) const throw () |
Return true if the node is a descendent of composite . | |
template<typename T> | |
bool | hasAncestor (const T &dummy) const throw () |
Return true if the node has a ancestor of the same type as dummy. | |
bool | isAncestorOf (const Composite &composite) const throw () |
Return true if the node has composite as descendent. | |
bool | isRelatedWith (const Composite &composite) const throw () |
Return true if the node has composite as ancestor or composite is ancestor of this node. | |
bool | isHomomorph (const Composite &composite) const throw () |
Return true if composite is homomorph to this node. | |
bool | containsSelection () const throw () |
Return true if any descendant is selected. | |
Debugging and Diagnostics | |
virtual bool | isValid () const throw () |
Test if the subtree with this node as root is valid. | |
virtual void | dump (std::ostream &s=std::cout, Size depth=0) const throw () |
Dump the constent of this instance to an ostream. | |
Application and Hosting | |
void | host (Visitor< Composite > &visitor) throw (Exception::GeneralException) |
Visitor host method. | |
template<typename T> | |
bool | applyAncestor (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to all ancestors of this node. | |
template<typename T> | |
bool | applyChild (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to all children of this node. | |
template<typename T> | |
bool | applyDescendantPreorder (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to all descendents of this node. | |
template<typename T> | |
bool | applyDescendantPostorder (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to all descendents of this node. | |
template<typename T> | |
bool | applyDescendant (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to all descendents of this node. | |
template<typename T> | |
bool | applyPreorder (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to the node and its subtree. | |
template<typename T> | |
bool | applyPostorder (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to the node and its subtree. | |
template<typename T> | |
bool | apply (UnaryProcessor< T > &processor) throw (Exception::GeneralException) |
Apply a processor to the node and its subtree. | |
template<typename T> | |
bool | applyLevel (UnaryProcessor< T > &processor, long level) throw (Exception::GeneralException) |
Apply a processor to the node and its siblings. | |
Static Public Attributes | |
UnaryProcessor< Composite > | DEFAULT_PROCESSOR |
KernelPredicateType | DEFAULT_UNARY_PREDICATE |
Friends | |
class | AncestorIteratorTraits |
class | ChildCompositeIteratorTraits |
class | CompositeIteratorTraits |
This class implements a variant of the composite design pattern. A Composite may contain an arbitrary number of other composites, thus forming a tree. All BALL kernel classes are derived from Composite. This provides a unique interface for all kernel classes.
|
Composite predicate type. This type declares a predicate operating on composites. As it is used as a predicate for all kernel classes, it is named KernelPredicateType. |
|
Time stamp type.
|
|
Default constructor. This constructor creates an empty composite object. |
|
Copy constructor. Creates a copy of a composite. Deep copies include the whole composite tree, shallow copies contain anly a single composite.
|
|
Destructor. The destructor calls destroy to remove the composite from potential tree structures. It also recursively destructs all children of the composite. |
|
Insert a composite as the last child of this composite.
Updates the modification time stamp. Note that this method alters the composite tree from which
|
|
Apply a processor to the node and its subtree. applyPreorder is used.
|
|
Apply a processor to all ancestors of this node.
|
|
Apply a processor to all children of this node.
|
|
Apply a processor to all descendents of this node. The node itself is not processed. applyDescendantPreorder is used.
|
|
Apply a processor to all descendents of this node. The node itself is not processed. The root of a subtree is accessed after the nodes in its left and right subtree.
|
|
Apply a processor to all descendents of this node. The node itself is not processed. The root of a subtree is accessed before the nodes in its left and right subtree.
|
|
Apply a processor to the node and its siblings.
|
|
Apply a processor to the node and its subtree. The root of a subtree is accessed after the nodes in its left and right subtree.
|
|
Apply a processor to the node and its subtree. The root of a subtree is accessed before the nodes in its left and right subtree.
|
|
Clear the composite properties. This method removes the composite's children and destructs them if they are auto-deletable.
Reimplemented from Selectable. Reimplemented in Atom, AtomContainer, Bond, NucleicAcid, Nucleotide, PDBAtom, Protein, Residue, and SecondaryStructure. |
|
Clone with a predicate.
This method copies the attributes of
|
|
Return true if any descendant is selected. This method does not check all nodes recursively. Instead, on each modification of the tree, internal flags are updated and the information is propagated upwards in the tree.
|
|
Count the number of nodes fulfilling a predicate in this subtree.
|
|
Count the number of descendants.
|
|
Deselect a composite. This method deselects the composite and all the composites therein.
Reimplemented from Selectable. |
|
Non-virtual destroy method. This method behaves exactly like destroy except for a small difference: when called with true, it calls the virtual clear function. If called with false it calls the original clear function of Composite. This is useful when implementing the behaviour of derived classes.
|
|
Destroy the composite. This method removes the composite from potential parental structures and then calls clear to destruct all children.
Reimplemented in Atom, AtomContainer, Bond, NucleicAcid, Nucleotide, PDBAtom, Protein, Residue, and SecondaryStructure. |
|
Dump the constent of this instance to an ostream.
Reimplemented in Atom, AtomContainer, Bond, Chain, Fragment, Molecule, NucleicAcid, Nucleotide, PDBAtom, Protein, Residue, and SecondaryStructure. |
|
Assignment of a tree to another.
Create a deep (
|
|
Find the first ancestor of type T (const method). This method operates also on constant trees.
|
|
Find the first ancestor of type T.
This method walks up the tree from parent to parent and checks whether the composite object is a kind of
|
|
Return a const pointer to the index th child of this composite. If no such child exists, 0 is returned. The index of the first child is 0.
|
|
Return the index th child of this composite. If no such child exists, 0 is returned. The index of the first child is 0.
|
|
Return the degree of the node. This method returns the number of children of a composite object.
|
|
Get the depth of this item in its tree. The depth of a root item is 0.
|
|
Return a const pointer to the first child.
|
|
Return a pointer to the first child.
|
|
Get the height of this item in its tree. The hight of a leaf is 0.
|
|
Return a const pointer to the last child.
|
|
Return a pointer to the last child.
|
|
Get a const reference to the lowest common ancestor of this item with an other. If no common ancestor exists, 0 is returned.
|
|
Get the lowest common ancestor of this item with an other. If no common ancestor exists 0 is returned.
|
|
Return the time of last modification.
|
|
Find the next composite of type T (const method).
This method walks backward in the tree from composite to composite and checks whether the composite object is a kind of
|
|
Find the next composite of type T.
This method walks backward in the tree from composite to composite and checks whether the composite object is a kind of
|
|
Return the composite's parent (const method).
|
|
Return the composite's parent.
|
|
Get the length of the path between two composite objects.
If no path exists
|
|
Find the nearest previous composite of type T (const method).
This method walks backward in the tree from composite to composite and checks whether the composite object is a kind of
|
|
Find the nearest previous composite of type T.
This method walks backward in the tree from composite to composite and checks whether the composite object is a kind of
|
|
Get a const reference to the root of this item.
|
|
Get the root of this item.
|
|
Return the time of last change of selection.
|
|
Return a const pointer to the sibling index positions from this composite.
A pointer to the sibling
|
|
Return a pointer to the sibling index positions from this composite.
A pointer to the sibling
|
|
Return true if the node has a ancestor of the same type as dummy.
|
|
Return true if the node has a child.
|
|
Return true if the node has a previous sibling. (Its parent has a child after this.) |
|
Return true if the node has a parent.
|
|
Return true if the node has a previous sibling. (Its parent has a child before this.) |
|
Return true if the node has a sibling. (Its parent has other childs.) |
|
Visitor host method. Composites may be visited. For an example look into Composite_test.C
|
|
Insert a node after this node.
This method inserts
|
|
Insert a node before this node.
This method inserts
|
|
Insert a new parent node.
This method is used to combine a range of nodes into a single parent. First, the
|
|
Return true if the node has composite as descendent.
|
|
Return true if the node has the parent
|
|
Return true if the node is a descendent of
|
|
Return true if the node does not contain children.
|
|
Return true if the node is the first child of its parent.
|
|
Return true if the node is the first child of
|
|
Return true if composite is homomorph to this node. (The subtrees of the two instances have to be of the same form.) |
|
Return true if the node is not the root or a leaf.
|
|
Return true if the node is the last child of its parent.
|
|
Return true if the node is the last child of
|
|
Return true if the node is a next sibling of
|
|
Return true if the node is the parent of
|
|
Return true if the node is a previous sibling of
|
|
Return true if the node has composite as ancestor or composite is ancestor of this node.
|
|
Return true if the node has no parent.
|
|
Return true if the node is root of composite.
|
|
Return true if the node is a sibling of
|
|
Test if the subtree with this node as root is valid. (The structure of the subtree has to be valid.) Reimplemented from Object. Reimplemented in Atom, AtomContainer, Bond, NucleicAcid, Nucleotide, Protein, Residue, and SecondaryStructure. |
|
Inequality operator.
|
|
Assignment operator.
|
|
Equality operator. Compares the handles of two Composite objects, therefore two Composite objects can never be equal.
|
|
Read a persistent object.
Reimplemented from PersistentObject. Reimplemented in Atom, AtomContainer, Bond, Chain, Fragment, Molecule, NucleicAcid, Nucleotide, PDBAtom, Protein, Residue, SecondaryStructure, and System. |
|
Write a persistent copy of the object.
Reimplemented from PersistentObject. Reimplemented in Atom, AtomContainer, Bond, Chain, Fragment, Molecule, NucleicAcid, Nucleotide, PDBAtom, Protein, Residue, SecondaryStructure, and System. |
|
Insert a composite as the first child of this composite. Updates the modification time stamp.
|
|
Remove a child from its parent.
|
|
Remove selected subcomposites.
This method iterates over all children of the current composite and removes all selected composites by This method is useful in combination with the class in order to remove unwanted partitions of kernel data structures.
|
|
This instance and its subtree is removed form its tree and replaced by
|
|
Select a composite. This method selects the composite and all the composites therein.
Reimplemented from Selectable. |
|
Assignment.
|
|
Insert the children of composite into this composite.
The children of
|
|
Append all children of
The method does nothing, if
|
|
Prepend all children of
The method does nothing, if
|
|
Modify a time stamp. Update one or both of the two time stamps with the current time. The time stamp is then propagated up to the root of the composite tree. Each composite contains two stamps. the modification stamp is updated each time the tree structure changes, while the selection stamp is updated each time the selection status changes.
|
|
Swap the contents of two composites.
|