#include <BALL/CONCEPT/composite.h>
Composite Class. 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.
typedef ConstForwardIterator<Composite, Composite, Composite*, AncestorIteratorTraits> BALL::Composite::AncestorConstIterator |
typedef ForwardIterator<Composite, Composite, Composite*, AncestorIteratorTraits> BALL::Composite::AncestorIterator |
typedef ConstBidirectionalIterator<Composite, Composite, Composite *, ChildCompositeIteratorTraits> BALL::Composite::ChildCompositeConstIterator |
typedef std::reverse_iterator<ChildCompositeConstIterator> BALL::Composite::ChildCompositeConstReverseIterator |
typedef BidirectionalIterator<Composite, Composite, Composite *, ChildCompositeIteratorTraits> BALL::Composite::ChildCompositeIterator |
typedef std::reverse_iterator<ChildCompositeIterator> BALL::Composite::ChildCompositeReverseIterator |
typedef ConstBidirectionalIterator<Composite, Composite, Composite*, CompositeIteratorTraits> BALL::Composite::CompositeConstIterator |
typedef std::reverse_iterator<CompositeConstIterator> BALL::Composite::CompositeConstReverseIterator |
typedef BidirectionalIterator<Composite, Composite, Composite*, CompositeIteratorTraits> BALL::Composite::CompositeIterator |
typedef std::reverse_iterator<CompositeIterator> BALL::Composite::CompositeReverseIterator |
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.
BALL::Composite::Composite | ( | ) |
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.
composite | the composite to be cloned (the root of the tree in the case of a deep copy) | |
deep | make a deep copy (true) or shallow copy (false) |
virtual BALL::Composite::~Composite | ( | ) | [virtual] |
Destructor. The destructor calls destroy to remove the composite from potential tree structures. It also recursively destructs all children of the composite.
void BALL::Composite::appendChild | ( | Composite & | 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 composite
is taken, if there is such a tree.
composite | the composite to be inserted |
BALL_INLINE bool BALL::Composite::apply | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
Apply a processor to the node and its subtree. applyPreorder is used.
Referenced by BALL::VIEW::DemoTutorialDialog::nextStepDemo_().
bool BALL::Composite::applyAncestor | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
Apply a processor to all ancestors of this node.
References BALL::Processor::BREAK.
bool BALL::Composite::applyChild | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
Apply a processor to all children of this node.
bool BALL::Composite::applyChildNostart_ | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline, private] |
References BALL::Processor::BREAK, and BALL::Processor::CONTINUE.
bool BALL::Composite::applyDescendant | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
Apply a processor to all descendents of this node. The node itself is not processed. applyDescendantPreorder is used.
bool BALL::Composite::applyDescendantPostorder | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
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.
bool BALL::Composite::applyDescendantPostorderNostart_ | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline, private] |
References BALL::Processor::BREAK.
bool BALL::Composite::applyDescendantPreorder | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
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.
bool BALL::Composite::applyDescendantPreorderNostart_ | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline, private] |
References BALL::Processor::BREAK.
bool BALL::Composite::applyLevel | ( | UnaryProcessor< T > & | processor, | |
long | level | |||
) | throw (Exception::GeneralException) [inline] |
Apply a processor to the node and its siblings.
bool BALL::Composite::applyLevelNostart_ | ( | UnaryProcessor< T > & | processor, | |
long | level | |||
) | throw (Exception::GeneralException) [inline, private] |
References BALL::Processor::BREAK.
bool BALL::Composite::applyPostorder | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
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.
References BALL::Processor::BREAK.
bool BALL::Composite::applyPreorder | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline] |
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.
bool BALL::Composite::applyPreorderNostart_ | ( | UnaryProcessor< T > & | processor | ) | throw (Exception::GeneralException) [inline, private] |
References BALL::Processor::BREAK.
AncestorConstIterator BALL::Composite::beginAncestor | ( | ) | const [inline] |
AncestorIterator BALL::Composite::beginAncestor | ( | ) | [inline] |
ChildCompositeConstIterator BALL::Composite::beginChildComposite | ( | ) | const [inline] |
ChildCompositeIterator BALL::Composite::beginChildComposite | ( | ) | [inline] |
CompositeConstIterator BALL::Composite::beginComposite | ( | ) | const [inline] |
CompositeIterator BALL::Composite::beginComposite | ( | ) | [inline] |
Referenced by getNext(), BALL::CompositeIteratorTraits::isBegin(), and BALL::CompositeIteratorTraits::toBegin().
virtual void BALL::Composite::clear | ( | ) | [virtual] |
Clear the composite properties. This method removes the composite's children and destructs them if they are auto-deletable.
this
. Reimplemented from BALL::Selectable.
Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, and BALL::SecondaryStructure.
void* BALL::Composite::clone | ( | Composite & | root | ) | const |
Clone with a predicate. This method copies the attributes of this
composite to root (shallow copy) and then adds recursively each of its children.
root | the cloning target root is destroy ed prior to any copying |
&root
) bool BALL::Composite::containsSelection | ( | ) | const |
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.
Size BALL::Composite::count | ( | const KernelPredicateType & | predicate | ) | const |
Count the number of nodes fulfilling a predicate in this subtree.
predicate | the predicate |
Size BALL::Composite::countDescendants | ( | ) | const |
Count the number of descendants.
Size BALL::Composite::countDescendants_ | ( | ) | const [private] |
void BALL::Composite::deleteChildrenList_ | ( | std::list< Composite * > & | composites | ) |
virtual void BALL::Composite::deselect | ( | ) | [virtual] |
Deselect a composite. This method deselects the composite and all the composites therein.
Reimplemented from BALL::Selectable.
void BALL::Composite::deselect_ | ( | bool | update_parent = true |
) | [private] |
void BALL::Composite::destroy | ( | bool | virtual_destroy | ) |
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.
this
. virtual_destroy | call the virtual clear method (true) or Composite::clear() (false) |
virtual void BALL::Composite::destroy | ( | ) | [virtual] |
Destroy the composite. This method removes the composite from potential parental structures and then calls clear to destruct all children.
this
. Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, and BALL::SecondaryStructure.
void BALL::Composite::determineSelection_ | ( | ) | [private] |
virtual void BALL::Composite::dump | ( | std::ostream & | s = std::cout , |
|
Size | depth = 0 | |||
) | const [virtual] |
Dump the constent of this instance to an ostream.
s | the stream to which we will dump | |
depth | the indentation depth of the output |
Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::Chain, BALL::Fragment, BALL::Molecule, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, and BALL::SecondaryStructure.
AncestorConstIterator BALL::Composite::endAncestor | ( | ) | const [inline] |
AncestorIterator BALL::Composite::endAncestor | ( | ) | [inline] |
ChildCompositeConstIterator BALL::Composite::endChildComposite | ( | ) | const [inline] |
ChildCompositeIterator BALL::Composite::endChildComposite | ( | ) | [inline] |
CompositeConstIterator BALL::Composite::endComposite | ( | ) | const [inline] |
CompositeIterator BALL::Composite::endComposite | ( | ) | [inline] |
Assignment of a tree to another. Create a deep (deep
= true) or shallow copy of a composite and assign it to composite
. composite
is destroyed first.
composite | the composite to assign the copy to | |
deep | true for a deep copy |
BALL_INLINE const T * BALL::Composite::getAncestor | ( | const T & | ) | const [inline] |
Find the first ancestor of type T (const method). This method operates also on constant trees.
References parent_.
BALL_INLINE T * BALL::Composite::getAncestor | ( | const T & | ) | [inline] |
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 T
. This method is useful to identify special container classes.
References parent_.
Referenced by BALL::VIEW::MoleculeColorProcessor::getAncestor_(), BALL::VIEW::ChainColorProcessor::getAncestor_(), and hasAncestor().
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.
index | the index of the child to return |
Return the index th child of this composite. If no such child exists, 0 is returned. The index of the first child is 0.
index | the index of the child to return |
Size BALL::Composite::getDegree | ( | ) | const |
Return the degree of the node. This method returns the number of children of a composite object.
Size BALL::Composite::getDepth | ( | ) | const |
Get the depth of this item in its tree. The depth of a root item is 0.
const Composite* BALL::Composite::getFirstChild | ( | ) | const |
Return a const pointer to the first child.
Composite* BALL::Composite::getFirstChild | ( | ) |
Return a pointer to the first child.
Size BALL::Composite::getHeight | ( | ) | const |
Get the height of this item in its tree. The hight of a leaf is 0.
const Composite* BALL::Composite::getLastChild | ( | ) | const |
Return a const pointer to the last child.
Composite* BALL::Composite::getLastChild | ( | ) |
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.
const PreciseTime& BALL::Composite::getModificationTime | ( | ) | const |
Return the time of last modification
BALL_INLINE const T * BALL::Composite::getNext | ( | const T & | dummy | ) | const [inline] |
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 T
.
References getNext().
BALL_INLINE T * BALL::Composite::getNext | ( | const T & | ) | [inline] |
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 T
.
References beginComposite(), getRoot(), BALL::BaseIterator< Container, DataType, Position, Traits >::getTraits(), BALL::BaseIterator< Container, DataType, Position, Traits >::isValid(), and BALL::Composite::CompositeIteratorTraits::setPosition().
Referenced by getNext().
const Composite* BALL::Composite::getParent | ( | ) | const |
Return the composite's parent (const method).
Composite* BALL::Composite::getParent | ( | ) |
Return the composite's parent.
Get the length of the path between two composite objects. If no path exists INVALID_SIZE
is returned.
composite | the second object |
BALL_INLINE const T * BALL::Composite::getPrevious | ( | const T & | dummy | ) | const [inline] |
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 T
.
References getPrevious().
BALL_INLINE T * BALL::Composite::getPrevious | ( | const T & | ) | [inline] |
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 T
.
References endComposite(), getRoot(), BALL::BaseIterator< Container, DataType, Position, Traits >::getTraits(), and BALL::Composite::CompositeIteratorTraits::setPosition().
Referenced by getPrevious().
const Composite& BALL::Composite::getRoot | ( | ) | const |
Get a const reference to the root of this item.
Composite& BALL::Composite::getRoot | ( | ) |
const PreciseTime& BALL::Composite::getSelectionTime | ( | ) | const |
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 index
positions to the right (for positive values of index
) or -index
positions to the left (for negative values of index
) is returned. For Index = 0 the this-pointer is returned.
index | the index of the sibling |
Return a pointer to the sibling index positions from this composite. A pointer to the sibling index
positions to the right (for positive values of index
) or -index
positions to the left (for negative values of index
) is returned. For Index = 0 the this-pointer is returned.
index | the index of the sibling |
BALL_INLINE bool BALL::Composite::hasAncestor | ( | const T & | dummy | ) | const [inline] |
Return true if the node has a ancestor of the same type as dummy.
References getAncestor().
bool BALL::Composite::hasChild | ( | ) | const |
Return true if the node has a child.
bool BALL::Composite::hasNextSibling | ( | ) | const |
Return true if the node has a previous sibling. (Its parent has a child after this.)
bool BALL::Composite::hasParent | ( | ) | const |
Return true if the node has a parent.
bool BALL::Composite::hasPreviousSibling | ( | ) | const |
Return true if the node has a previous sibling. (Its parent has a child before this.)
bool BALL::Composite::hasSibling | ( | ) | const |
Return true if the node has a sibling. (Its parent has other childs.)
void BALL::Composite::host | ( | Visitor< Composite > & | visitor | ) | throw (Exception::GeneralException) |
Visitor host method. Composites may be visited. For an example look into Composite_test.C
visitor | the visitor |
void BALL::Composite::insertAfter | ( | Composite & | composite | ) |
Insert a node after this node. This method inserts composite
after this
node, if this
node has a parent and is not a descendant of composite
. Self-insertion is recognized and ignored (nothing is done).
composite | the node to be inserted in the tree after of this |
void BALL::Composite::insertBefore | ( | Composite & | composite | ) |
Insert a node before this node. This method inserts composite
before this
node, if this
node has a parent and is not a descendant of composite
. Self-insertion is recognized and ignored (nothing is done).
composite | the node to be inserted in the tree before this |
static bool BALL::Composite::insertParent | ( | Composite & | parent, | |
Composite & | first, | |||
Composite & | last, | |||
bool | destroy_parent = true | |||
) | [static] |
Insert a new parent node. This method is used to combine a range of nodes into a single parent. First, the parent
composite is destroy
ed. Then, all nodes from first
through last
are inserted into parent
and parent
is inserted in the former position of first
. The method returns false, if { first} or last
have differing parents, if parent
is identical with either first
or last
, or if first
is already a descendant of parent
.
parent | the new parent of the nodes from first through last | |
first | the first of the nodes to be inserted into parent | |
last | the last of the nodes to be inserted into parent | |
destroy_parent | keeps the current contents of parent if set to true |
Return true if the node has composite as descendent.
Return true if the node has the parent composite
.
Return true if the node is a descendent of composite
.
bool BALL::Composite::isEmpty | ( | ) | const |
Return true if the node does not contain children.
number_of_children_ == 0
bool BALL::Composite::isFirstChild | ( | ) | const |
Return true if the node is the first child of its parent.
Return true if the node is the first child of composite
.
Return true if composite is homomorph to this node. (The subtrees of the two instances have to be of the same form.)
bool BALL::Composite::isInterior | ( | ) | const |
Return true if the node is not the root or a leaf.
bool BALL::Composite::isLastChild | ( | ) | const |
Return true if the node is the last child of its parent.
Return true if the node is the last child of composite
.
Return true if the node is a next sibling of composite
.
Return true if the node is the parent of composite
.
Return true if the node is a previous sibling of composite
.
Return true if the node has composite as ancestor or composite is ancestor of this node.
bool BALL::Composite::isRoot | ( | ) | const |
Return true if the node has no parent.
parent_ == 0
Return true if the node is root of composite.
Return true if the node is a sibling of composite
.
virtual bool BALL::Composite::isValid | ( | ) | const [virtual] |
Test if the subtree with this node as root is valid. (The structure of the subtree has to be valid.)
Reimplemented from BALL::Object.
Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::NucleicAcid, BALL::Nucleotide, BALL::Protein, BALL::Residue, and BALL::SecondaryStructure.
Inequality operator.
Assignment operator.
composite | the Composite tree to assign from |
Equality operator. Compares the handles of two Composite objects, therefore two Composite objects can never be equal.
composite | the composite against which equality will be tested |
virtual void BALL::Composite::persistentRead | ( | PersistenceManager & | pm | ) | throw (Exception::GeneralException) [virtual] |
Read a persistent object.
pm | the persistence manager |
Reimplemented from BALL::PersistentObject.
Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::Chain, BALL::Fragment, BALL::Molecule, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, BALL::SecondaryStructure, and BALL::System.
virtual void BALL::Composite::persistentWrite | ( | PersistenceManager & | pm, | |
const char * | name = 0 | |||
) | const throw (Exception::GeneralException) [virtual] |
Write a persistent copy of the object.
pm | the persistence manager | |
name | the object name |
Reimplemented from BALL::PersistentObject.
Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::Chain, BALL::Fragment, BALL::Molecule, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, BALL::SecondaryStructure, and BALL::System.
void BALL::Composite::prependChild | ( | Composite & | composite | ) |
Insert a composite as the first child of this composite. Updates the modification time stamp.
composite | the composite to be inserted |
ChildCompositeConstReverseIterator BALL::Composite::rbeginChildComposite | ( | ) | const [inline] |
ChildCompositeReverseIterator BALL::Composite::rbeginChildComposite | ( | ) | [inline] |
CompositeConstReverseIterator BALL::Composite::rbeginComposite | ( | ) | const [inline] |
CompositeReverseIterator BALL::Composite::rbeginComposite | ( | ) | [inline] |
Remove a child from its parent. child
is only removed, if it is a true child of this
.
this
. child | the child to remove |
Size BALL::Composite::removeSelected | ( | ) |
Remove selected subcomposites. This method iterates over all children of the current composite and removes all selected composites by delete
ing them. If the respective Composite are not AutoDeletable, they are just remove d from the hierarchy, but not deleted.
This method is useful in combination with the Selector class in order to remove unwanted partitions of kernel data structures.
Size BALL::Composite::removeUnselected | ( | ) |
Remove unselected subcomposites. This method iterates over all children of the current composite and removes all unselected composites by delete
ing them. If the respective Composite are not AutoDeletable, they are just remove d from the hierarchy, but not deleted.
This method is useful in combination with the Selector class in order to remove unwanted partitions of kernel data structures.
ChildCompositeConstReverseIterator BALL::Composite::rendChildComposite | ( | ) | const [inline] |
ChildCompositeReverseIterator BALL::Composite::rendChildComposite | ( | ) | [inline] |
CompositeConstReverseIterator BALL::Composite::rendComposite | ( | ) | const [inline] |
CompositeReverseIterator BALL::Composite::rendComposite | ( | ) | [inline] |
void BALL::Composite::replace | ( | Composite & | composite | ) |
This instance and its subtree is removed form its tree and replaced by composite
and its subtree.
this
and composite
. composite | the composite which will be inserted |
virtual void BALL::Composite::select | ( | ) | [virtual] |
Select a composite. This method selects the composite and all the composites therein.
Reimplemented from BALL::Selectable.
void BALL::Composite::select_ | ( | bool | update_parent = true |
) | [private] |
Assignment.
composite | the Composite tree to assign from | |
deep | a bool deciding whether the assignment will be deep or shallow. |
void BALL::Composite::splice | ( | Composite & | composite | ) |
Insert the children of composite into this composite. The children of composite
are inserted at the position of composite
if composite
is a child of this
. Otherwise the children are inserted using spliceBefore .
composite | the composite to be spliced |
void BALL::Composite::spliceAfter | ( | Composite & | composite | ) |
Append all children of composite
to the children of this composite. The method does nothing, if composite
is identical to this
or is a descendent of this
.
composite | the composite to be spliced |
void BALL::Composite::spliceBefore | ( | Composite & | composite | ) |
Prepend all children of composite
to the children of this composite. The method does nothing, if composite
is identical to this
or is a descendent of this
.
the | composite to be spliced |
void BALL::Composite::stamp | ( | StampType | stamp = BOTH |
) |
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.
stamp | the time stamp type |
void BALL::Composite::swap | ( | Composite & | composite | ) |
Swap the contents of two composites.
this
and composite
. composite | the composite with which the contents will be swapped |
void BALL::Composite::updateSelection_ | ( | ) | [private] |
friend class AncestorIteratorTraits [friend] |
friend class ChildCompositeIteratorTraits [friend] |
friend class CompositeIteratorTraits [friend] |
bool BALL::Composite::contains_selection_ [private] |
Composite* BALL::Composite::first_child_ [private] |
Referenced by BALL::Composite::CompositeIteratorTraits::findNextPosition().
Composite* BALL::Composite::last_child_ [private] |
Composite* BALL::Composite::next_ [private] |
Referenced by BALL::Composite::CompositeIteratorTraits::findNextPosition().
Size BALL::Composite::number_of_children_ [private] |
Composite* BALL::Composite::parent_ [private] |
Composite* BALL::Composite::previous_ [private] |
unsigned char BALL::Composite::properties_ [private] |
TimeStamp BALL::Composite::selection_stamp_ [private] |