A library for working with phylogenetic and population genetic data.
v0.32.0
BaseEdgeData Class Reference

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

Inherited by CommonEdgeData.

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 CommonEdgeData 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< BaseEdgeDataclone () 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< BaseEdgeDatarecreate () 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< BaseEdgeDatacreate ()
 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

◆ ~BaseEdgeData()

virtual ~BaseEdgeData ( )
virtualdefault

Virtual destructor. Needed for polymorphism.

◆ BaseEdgeData() [1/3]

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() [2/3]

BaseEdgeData ( )
protecteddefault

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

◆ BaseEdgeData() [3/3]

BaseEdgeData ( BaseEdgeData const &  )
protecteddefault

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

Member Function Documentation

◆ clone()

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

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

Reimplemented in LayoutEdgeData, SimpleNewickEdgeData, AttributeTreeEdgeData, PlacementEdgeData, MassTreeEdgeData, and CommonEdgeData.

Definition at line 134 of file edge_data.hpp.

◆ create()

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.

◆ operator=() [1/2]

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.

◆ operator=() [2/2]

BaseEdgeData& operator= ( BaseEdgeData const &  )
protecteddefault

Protected copy assignment. Not used right now.

◆ recreate()

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 LayoutEdgeData, SimpleNewickEdgeData, AttributeTreeEdgeData, PlacementEdgeData, MassTreeEdgeData, and CommonEdgeData.

Definition at line 126 of file edge_data.hpp.


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