#include <genesis/tree/tree/node_data.hpp>
Inherited by CommonNodeData.
Base class for storing data on Nodes of a Tree.
This class provides the start point for the class hierarchy of node data classes. In order to correctly achieve polymorphic behaviour, and with its use case in a Tree in mind, this class and its derived classes are supposed to be used via unique pointers to their instances. Although this yields automatic memory management, it unfortunately disallows covariant return types.
The class thus provides a static create() function instead of a default constructor. This needs to be reimplemented in derived classes in order to allow creation of objects of the exact derived type. For similar reasons, instead of a copy constructor, it provides a clone() function.
Furthermore, the class provides a virtual recreate() function that default-constructs an object of the same derived type as it was called on. This is allows to create new data instances for a Tree without the need to know the exact derived type. For example, this can be used when adding new Nodes to a Tree, in order to fill them with default-constructed data of the same type of some other Nodes of the Tree.
It is recommended that derived classes follow the same access rules for its constructors. See CommonNodeData for an example.
This class does not contain any data itself. See BaseEdgeData for its "partner" class.
Definition at line 66 of file node_data.hpp.
Public Member Functions | |
BaseNodeData (BaseNodeData &&)=delete | |
Deleted move constructor. More... | |
virtual | ~BaseNodeData ()=default |
Virtual destructor. Needed for polymorphism. More... | |
virtual std::unique_ptr< BaseNodeData > | clone () const |
Polymorphically copy an instance of this class. Use instead of copy constructor. More... | |
BaseNodeData & | operator= (BaseNodeData &&)=delete |
Deleted move assignment. More... | |
virtual std::unique_ptr< BaseNodeData > | recreate () const |
Polymorphically create a default-constructed instance of this class with the same derived type as it was called on. More... | |
Static Public Member Functions | |
static std::unique_ptr< BaseNodeData > | create () |
Create a new instance of this class. Use instead of default constructor. More... | |
Protected Member Functions | |
BaseNodeData ()=default | |
Protected default constructor. Called from the create() function. More... | |
BaseNodeData (BaseNodeData const &)=default | |
Protected copy constructor. Called from the clone() function. More... | |
BaseNodeData & | operator= (BaseNodeData const &)=default |
Protected copy assignment. Not used right now. More... | |
|
virtualdefault |
Virtual destructor. Needed for polymorphism.
|
delete |
Deleted move constructor.
Not viable with polymorphism. Also, we don't need it. The data is held by pointer (in order to allow polymorphism in the first place), so we can simply move the pointer instead.
|
protecteddefault |
Protected default constructor. Called from the create() function.
|
protecteddefault |
Protected copy constructor. Called from the clone() function.
|
inlinevirtual |
Polymorphically copy an instance of this class. Use instead of copy constructor.
Reimplemented in SimpleNewickNodeData, MassTreeNodeData, AttributeTreeNodeData, PlacementNodeData, LayoutNodeData, and CommonNodeData.
Definition at line 134 of file node_data.hpp.
|
inlinestatic |
Create a new instance of this class. Use instead of default constructor.
Definition at line 117 of file node_data.hpp.
|
delete |
Deleted move assignment.
Not viable with polymorphism. Also, we don't need it. The data is held by pointer (in order to allow polymorphism in the first place), so we can simply move the pointer instead.
|
protecteddefault |
Protected copy assignment. Not used right now.
|
inlinevirtual |
Polymorphically create a default-constructed instance of this class with the same derived type as it was called on.
Reimplemented in SimpleNewickNodeData, MassTreeNodeData, AttributeTreeNodeData, PlacementNodeData, LayoutNodeData, and CommonNodeData.
Definition at line 126 of file node_data.hpp.