libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The ISgfcTreeBuilder interface provides methods to manipulate the nodes of a game tree. More...
#include <ISgfcTreeBuilder.h>
Public Member Functions | |
ISgfcTreeBuilder () | |
Initializes a newly constructed ISgfcTreeBuilder object. | |
virtual | ~ISgfcTreeBuilder () |
Destroys and cleans up the ISgfcTreeBuilder object. | |
virtual std::weak_ptr< ISgfcGame > | GetGame () const =0 |
Returns the ISgfcGame object whose game tree the methods in the ISgfcTreeBuilder operate on. | |
virtual void | SetFirstChild (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > child) const =0 |
Sets the first child node of node to child, replacing everything below node with child (which may be nullptr). Use InsertChild() if you want to keep the existing nodes below node. | |
virtual void | AppendChild (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > child) const =0 |
Adds child as the last child to node. child may not be nullptr. | |
virtual void | InsertChild (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > child, std::shared_ptr< ISgfcNode > referenceChild) const =0 |
Inserts child as a child to node, before the reference child node referenceChild. child may not be nullptr. referenceChild may be nullptr, but if it's not then it must be a child of node. | |
virtual void | RemoveChild (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > child) const =0 |
Removes child from node. child may not be nullptr. child must be a child of the node. | |
virtual void | ReplaceChild (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > newChild, std::shared_ptr< ISgfcNode > oldChild) const =0 |
Replaces oldChild with newChild. oldChild and newChild may not be nullptr. oldChild must be a child of node. | |
virtual void | SetNextSibling (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > nextSibling) const =0 |
Sets the next sibling node of node to nextSibling, replacing the previous next sibling node, the siblings behind that, and the sub trees dangling from all of these siblings with nextSibling (which may be nullptr). Use InsertChild() if you want to keep the next sibling nodes. | |
virtual void | SetParent (std::shared_ptr< ISgfcNode > node, std::shared_ptr< ISgfcNode > parent) const =0 |
Sets the parent node of node to parent. parent may be nullptr. | |
The ISgfcTreeBuilder interface provides methods to manipulate the nodes of a game tree.
|
pure virtual |
Adds child as the last child to node. child may not be nullptr.
If child is already part of the game tree in some other location, it is moved, together with the entire sub tree dangling from it, from its current location to the new location.
This method exists for convenience. The operations it performs can also be achieved by invoking Insertchild() and specifying nullptr as the referenceChild argument.
std::invalid_argument | Is thrown if node is nullptr, if child is nullptr, if child is an ancestor of node, or if child is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Returns the ISgfcGame object whose game tree the methods in the ISgfcTreeBuilder operate on.
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Inserts child as a child to node, before the reference child node referenceChild. child may not be nullptr. referenceChild may be nullptr, but if it's not then it must be a child of node.
If referenceChild is nullptr then child is inserted as the last child of node. The result is the same as if AppendChild() had been invoked on node.
If child is already part of the game tree in some other location, it is moved, together with the entire sub tree dangling from it, from its current location to the new location.
std::invalid_argument | Is thrown if node is nullptr, if child is nullptr, if referenceChild is not nullptr but it's not a child of the node, if child is an ancestor of node, or if child is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Removes child from node. child may not be nullptr. child must be a child of the node.
The game tree is relinked to close the gap.
child and the entire sub tree dangling from it, is discarded once no one holds a reference to it anymore.
std::invalid_argument | Is thrown if node is nullptr, if child is nullptr, or if child is not a child of node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Replaces oldChild with newChild. oldChild and newChild may not be nullptr. oldChild must be a child of node.
If newChild is already part of the game tree in some other location, it is moved, together with the entire sub tree dangling from it, from its current location to the new location.
oldChild and the entire sub tree dangling from it, is discarded once no one holds a reference to it anymore.
std::invalid_argument | Is thrown if node is nullptr, if oldChild or newChild are nullptr, if oldChild is not a child of node, if newChild is an ancestor of node, or if newChild is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Sets the first child node of node to child, replacing everything below node with child (which may be nullptr). Use InsertChild() if you want to keep the existing nodes below node.
If child is already part of the game tree in some other location, it is moved, together with the entire sub tree dangling from it, from its current location to the new location.
The previous first child node, the siblings behind that, and the sub trees dangling from all of these nodes, are discarded once no one holds a reference to them anymore.
std::invalid_argument | Is thrown if node is nullptr, if child is an ancestor of node, or if child is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Sets the next sibling node of node to nextSibling, replacing the previous next sibling node, the siblings behind that, and the sub trees dangling from all of these siblings with nextSibling (which may be nullptr). Use InsertChild() if you want to keep the next sibling nodes.
node must not be the root node of a game tree because a root node by definition can't have siblings.
If nextSibling is already part of the game tree in some other location, it is moved, together with the entire sub tree dangling from it, from its current location to the new location.
The previous next sibling node, the siblings behind that, and the sub trees dangling from all of these siblings, are discarded once no one holds a reference to them anymore.
std::invalid_argument | Is thrown if node is nullptr, if node is the root node of a game tree, if nextSibling is not nullptr and an ancestor of node, or if nextSibling is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.
|
pure virtual |
Sets the parent node of node to parent. parent may be nullptr.
If parent is not nullptr and node is already a child of parent, then this method has no effect.
If parent is not nullptr and node is not yet a child of parent, then node is added as the last child of parent. The result is the same as if AppendChild() had been invoked on parent with node as the argument.
If parent is not nullptr and if node is already part of the game tree in some other location, node is moved, together with the entire sub tree dangling from it, from its current location to the new location.
If parent is nullptr then node and the entire sub tree dangling from it, is discarded once no one holds a reference to it anymore. The game tree is relinked to close the gap. The result is the same as if RemoveChild() had been invoked on the node's parent with node as the argument.
std::invalid_argument | Is thrown if node is nullptr, if parent is a descendant of node, or if parent is equal to node. |
Implemented in LibSgfcPlusPlus::SgfcTreeBuilder.