bpp-phyl3  3.0.0
bpp::PhyloNode Class Reference

#include <Bpp/Phyl/Tree/PhyloNode.h>

+ Inheritance diagram for bpp::PhyloNode:
+ Collaboration diagram for bpp::PhyloNode:

Public Member Functions

 PhyloNode ()
 Build a new void Node object. More...
 
 PhyloNode (const std::string &name)
 Build a new Node with specified name. More...
 
 PhyloNode (const PhyloNode &node)
 Copy constructor. More...
 
PhyloNodeoperator= (const PhyloNode &node)
 Assignation operator. More...
 
PhyloNodeclone () const
 
virtual ~PhyloNode ()
 destructor. More...
 
Name:
std::string getName () const
 Get the name associated to this node, if there is one, otherwise throw a NodeException. More...
 
void setName (const std::string &name)
 Give a name or update the name associated to the node. More...
 
void deleteName ()
 Delete the name associated to this node (do nothing if there is no name). More...
 
bool hasName () const
 Tell is this node has a name. More...
 
Node properties:
void setProperty (const std::string &name, const Clonable &property)
 Set/add a node property. More...
 
ClonablegetProperty (const std::string &name)
 
const ClonablegetProperty (const std::string &name) const
 
ClonableremoveProperty (const std::string &name)
 
void deleteProperty (const std::string &name)
 
void removeProperties ()
 Remove all node properties. More...
 
void deleteProperties ()
 Delete all node properties. More...
 
bool hasProperty (const std::string &name) const
 
std::vector< std::string > getPropertyNames () const
 

Private Attributes

std::string name_
 
std::map< std::string, Clonable * > properties_
 

Detailed Description

Definition at line 58 of file PhyloNode.h.

Constructor & Destructor Documentation

◆ PhyloNode() [1/3]

bpp::PhyloNode::PhyloNode ( )
inline

Build a new void Node object.

Definition at line 71 of file PhyloNode.h.

Referenced by clone().

◆ PhyloNode() [2/3]

bpp::PhyloNode::PhyloNode ( const std::string &  name)
inline

Build a new Node with specified name.

Definition at line 81 of file PhyloNode.h.

◆ PhyloNode() [3/3]

PhyloNode::PhyloNode ( const PhyloNode node)

Copy constructor.

Parameters
nodeThe node to copy.

Copy constructor:

Definition at line 17 of file PhyloNode.cpp.

References properties_.

◆ ~PhyloNode()

virtual bpp::PhyloNode::~PhyloNode ( )
inlinevirtual

destructor.

Definition at line 108 of file PhyloNode.h.

References deleteProperties().

Member Function Documentation

◆ clone()

PhyloNode* bpp::PhyloNode::clone ( ) const
inline

Definition at line 102 of file PhyloNode.h.

References PhyloNode().

◆ deleteName()

void bpp::PhyloNode::deleteName ( )
inline

Delete the name associated to this node (do nothing if there is no name).

Definition at line 145 of file PhyloNode.h.

References name_.

◆ deleteProperties()

void bpp::PhyloNode::deleteProperties ( )
inline

Delete all node properties.

Definition at line 234 of file PhyloNode.h.

References properties_.

Referenced by ~PhyloNode().

◆ deleteProperty()

void bpp::PhyloNode::deleteProperty ( const std::string &  name)
inline

Definition at line 210 of file PhyloNode.h.

References hasProperty(), and properties_.

◆ getName()

std::string bpp::PhyloNode::getName ( ) const
inline

Get the name associated to this node, if there is one, otherwise throw a NodeException.

Returns
The name associated to this node.

Definition at line 126 of file PhyloNode.h.

References hasName(), and name_.

◆ getProperty() [1/2]

Clonable* bpp::PhyloNode::getProperty ( const std::string &  name)
inline

◆ getProperty() [2/2]

const Clonable* bpp::PhyloNode::getProperty ( const std::string &  name) const
inline

Definition at line 190 of file PhyloNode.h.

References hasProperty(), and properties_.

◆ getPropertyNames()

std::vector<std::string> bpp::PhyloNode::getPropertyNames ( ) const
inline

Definition at line 245 of file PhyloNode.h.

References bpp::MapTools::getKeys(), and properties_.

◆ hasName()

bool bpp::PhyloNode::hasName ( ) const
inline

Tell is this node has a name.

Returns
True if name != 0.

Definition at line 155 of file PhyloNode.h.

References name_.

Referenced by getName().

◆ hasProperty()

bool bpp::PhyloNode::hasProperty ( const std::string &  name) const
inline

Definition at line 243 of file PhyloNode.h.

References properties_.

Referenced by deleteProperty(), getProperty(), removeProperty(), and setProperty().

◆ operator=()

PhyloNode & PhyloNode::operator= ( const PhyloNode node)

Assignation operator.

Parameters
nodethe node to copy.
Returns
A reference toward this node.

Assignation operator:

Definition at line 29 of file PhyloNode.cpp.

References name_, and properties_.

◆ removeProperties()

void bpp::PhyloNode::removeProperties ( )
inline

Remove all node properties.

Attached objects will not be deleted.

Definition at line 226 of file PhyloNode.h.

References properties_.

◆ removeProperty()

Clonable* bpp::PhyloNode::removeProperty ( const std::string &  name)
inline

Definition at line 198 of file PhyloNode.h.

References hasProperty(), and properties_.

◆ setName()

void bpp::PhyloNode::setName ( const std::string &  name)
inline

Give a name or update the name associated to the node.

Parameters
nameThe name to give to the node.

Definition at line 137 of file PhyloNode.h.

References name_.

◆ setProperty()

void bpp::PhyloNode::setProperty ( const std::string &  name,
const Clonable property 
)
inline

Set/add a node property.

If no property with the same name is found, the new property will be added to the list. Conversely, the property will be deleted and replaced by the new one. If you want to keep a copy of the old property, consider using the removeProperty function before.

Parameters
nameThe name of the property to set.
propertyThe property object (will be cloned).

Definition at line 175 of file PhyloNode.h.

References hasProperty(), and properties_.

Referenced by bpp::StochasticMapping::setNodeState().

Member Data Documentation

◆ name_

std::string bpp::PhyloNode::name_
private

Definition at line 62 of file PhyloNode.h.

Referenced by deleteName(), getName(), hasName(), operator=(), and setName().

◆ properties_

std::map<std::string, Clonable*> bpp::PhyloNode::properties_
mutableprivate

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