A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseEdgeData Class Reference

#include <genesis/tree/tree/edge_data.hpp>

Inherited by DefaultEdgeData.

Detailed Description

Base class for storing data on Edges of a Tree.

This class provides the start point for the class hierarchy of edge 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 Edges to a Tree, in order to fill them with default-constructed data of the same type of some other Edges of the Tree.

It is recommended that derived classes follow the same access rules for its constructors. See DefaultEdgeData for an example.

This class does not contain any data itself. See BaseNodeData for its "partner" class.

Definition at line 66 of file edge_data.hpp.

Public Member Functions

 BaseEdgeData (BaseEdgeData &&)=delete
 Deleted move constructor. More...
 
virtual ~BaseEdgeData ()=default
 Virtual destructor. Needed for polymorphism. More...
 
virtual std::unique_ptr
< BaseEdgeData
clone () const
 Polymorphically copy an instance of this class. Use instead of copy constructor. More...
 
BaseEdgeDataoperator= (BaseEdgeData &&)=delete
 Deleted move assignment. More...
 
virtual std::unique_ptr
< BaseEdgeData
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
< BaseEdgeData
create ()
 Create a new instance of this class. Use instead of default constructor. More...
 

Protected Member Functions

 BaseEdgeData ()=default
 Protected default constructor. Called from the create() function. More...
 
 BaseEdgeData (BaseEdgeData const &)=default
 Protected copy constructor. Called from the clone() function. More...
 
BaseEdgeDataoperator= (BaseEdgeData const &)=default
 Protected copy assignment. Not used right now. More...
 

Constructor & Destructor Documentation

virtual ~BaseEdgeData ( )
virtualdefault

Virtual destructor. Needed for polymorphism.

BaseEdgeData ( BaseEdgeData &&  )
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.

BaseEdgeData ( )
protecteddefault

Protected default constructor. Called from the create() function.

BaseEdgeData ( BaseEdgeData const &  )
protecteddefault

Protected copy constructor. Called from the clone() function.

Member Function Documentation

virtual std::unique_ptr< BaseEdgeData > clone ( ) const
inlinevirtual

Polymorphically copy an instance of this class. Use instead of copy constructor.

Reimplemented in AttributeTreeEdgeData, MassTreeEdgeData, DefaultEdgeData, PlacementEdgeData, LayoutEdgeData, CircularEdgeData, and RectangularEdgeData.

Definition at line 134 of file edge_data.hpp.

static std::unique_ptr< BaseEdgeData > create ( )
inlinestatic

Create a new instance of this class. Use instead of default constructor.

Definition at line 117 of file edge_data.hpp.

BaseEdgeData& operator= ( BaseEdgeData &&  )
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.

BaseEdgeData& operator= ( BaseEdgeData const &  )
protecteddefault

Protected copy assignment. Not used right now.

virtual std::unique_ptr< BaseEdgeData > recreate ( ) const
inlinevirtual

Polymorphically create a default-constructed instance of this class with the same derived type as it was called on.

Reimplemented in AttributeTreeEdgeData, MassTreeEdgeData, DefaultEdgeData, PlacementEdgeData, LayoutEdgeData, CircularEdgeData, and RectangularEdgeData.

Definition at line 126 of file edge_data.hpp.


The documentation for this class was generated from the following file: