bpp-phyl3 3.0.0
PhyloTreeExceptions.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_TREE_PHYLOTREEEXCEPTIONS_H
6#define BPP_PHYL_TREE_PHYLOTREEEXCEPTIONS_H
7
8#include <Bpp/Exceptions.h>
10
11
12// From the STL:
13#include <string>
14#include <memory>
15
16namespace bpp
17{
18class PhyloNode;
19class PhyloBranch;
20class PhyloTree;
21
26 public Exception
27{
28protected:
29 uint nodeId_;
30
31public:
37 PhyloNodeException(const std::string& text, uint nodeId) :
38 Exception("PhyloNodeException: " + text + "(id:" + TextTools::toString(nodeId) + ")"),
39 nodeId_(nodeId) {}
40
42
43public:
49 virtual uint getNodeId() const { return nodeId_; }
50};
51
52
58{
59private:
61
62public:
69 PhyloNodePException(const std::string& text, const PhyloTree& tree, const std::shared_ptr<PhyloNode> node);
70
76 PhyloNodePException(const std::string& text, const PhyloNode* node);
77
83 PhyloNodePException(const std::string& text, uint nodeId) :
84 PhyloNodeException(text, nodeId), node_(0) {}
85
88 node_(nex.node_)
89 {}
90
92 {
93 PhyloNodeException::operator=(nex);
94 node_ = nex.node_;
95 return *this;
96 }
97
99
100public:
106 virtual const PhyloNode* getNode() const { return node_; }
112 virtual uint getNodeId() const { return nodeId_; }
113};
114
120{
121private:
122 std::string propertyName_;
123
124public:
132 PhyloNodePropertyNotFoundException(const std::string& text, const std::string& propertyName, const PhyloTree& tree, const std::shared_ptr<PhyloNode> node) :
133 PhyloNodePException("Property not found: " + propertyName + ". " + text, tree, node),
134 propertyName_(propertyName) {}
135
142 PhyloNodePropertyNotFoundException(const std::string& text, const std::string& propertyName, const PhyloNode* node) :
143 PhyloNodePException("Property not found: " + propertyName + ". " + text, node),
144 propertyName_(propertyName) {}
145
153 PhyloNodePropertyNotFoundException(const std::string& text, const std::string& propertyName, uint nodeId) :
154 PhyloNodePException("Property not found: " + propertyName + ". " + text, nodeId),
155 propertyName_(propertyName) {}
156
158
159public:
165 virtual const std::string& getPropertyName() const { return propertyName_; }
166};
167
172 public Exception
173{
174private:
175 std::string id_;
176
177public:
184 PhyloNodeNotFoundException(const std::string& text, const std::string& id);
185
192 PhyloNodeNotFoundException(const std::string& text, uint id);
193
195
196public:
202 virtual std::string getId() const { return id_; }
203};
204
209 public Exception
210{
211protected:
213
214public:
220 PhyloBranchException(const std::string& text, uint branchId) :
221 Exception("PhyloBranchException: " + text + "(id:" + TextTools::toString(branchId) + ")"),
222 branchId_(branchId) {}
223
225
226public:
232 virtual uint getBranchId() const { return branchId_; }
233};
234
235
241{
242private:
244
245public:
252 PhyloBranchPException(const std::string& text, const PhyloTree& tree, const std::shared_ptr<PhyloBranch> branch);
253
259 PhyloBranchPException(const std::string& text, const PhyloBranch* branch);
260
266 PhyloBranchPException(const std::string& text, uint branchId) :
267 PhyloBranchException(text, branchId), branch_(0) {}
268
271 branch_(nex.branch_)
272 {}
273
275 {
276 PhyloBranchException::operator=(nex);
277 branch_ = nex.branch_;
278 return *this;
279 }
280
282
283public:
289 virtual const PhyloBranch* getBranch() const { return branch_; }
295 virtual uint getBranchId() const { return branchId_; }
296};
297
303{
304private:
305 std::string propertyName_;
306
307public:
316 PhyloBranchPropertyNotFoundException(const std::string& text, const std::string& propertyName, const PhyloTree& tree, const std::shared_ptr<PhyloBranch> branch) :
317 PhyloBranchPException("Property not found: " + propertyName + ". " + text, tree, branch),
318 propertyName_(propertyName) {}
319
327 PhyloBranchPropertyNotFoundException(const std::string& text, const std::string& propertyName, const PhyloBranch* branch) :
328 PhyloBranchPException("Property not found: " + propertyName + ". " + text, branch),
329 propertyName_(propertyName) {}
330
338 PhyloBranchPropertyNotFoundException(const std::string& text, const std::string& propertyName, uint branchId) :
339 PhyloBranchPException("Property not found: " + propertyName + ". " + text, branchId),
340 propertyName_(propertyName) {}
341
343
344public:
350 virtual const std::string& getPropertyName() const { return propertyName_; }
351};
352
357 public Exception
358{
359private:
360 std::string id_;
361
362public:
369 PhyloBranchNotFoundException(const std::string& text, const std::string& id);
370
377 PhyloBranchNotFoundException(const std::string& text, uint id);
378
380
381public:
387 virtual std::string getId() const { return id_; }
388};
389
394 public Exception
395{
396private:
398
399public:
406 PhyloTreeException(const std::string& text, const PhyloTree* tree = 0);
407
409 Exception(tex),
410 tree_(tex.tree_)
411 {}
412
414 {
415 Exception::operator=(tex);
416 tree_ = tex.tree_;
417 return *this;
418 }
419
421
422public:
428 virtual const PhyloTree* getTree() const { return tree_; }
429};
430
435 public PhyloTreeException
436{
437public:
444 UnrootedPhyloTreeException(const std::string& text, const PhyloTree* tree = 0);
445
447};
448} // end of namespace bpp.
449#endif // BPP_PHYL_TREE_PHYLOTREEEXCEPTIONS_H
General exception thrown when something is wrong with a particular branch.
virtual uint getBranchId() const
Get the id of branch that threw the exception.
PhyloBranchException(const std::string &text, uint branchId)
Build a new PhyloBranchPException.
Exception thrown when something is wrong with a particular branch.
PhyloBranchNotFoundException(const std::string &text, const std::string &id)
Build a new PhyloBranchNotFoundException.
virtual std::string getId() const
Get the branch id that threw the exception.
General exception thrown when something is wrong with a particular branch.
PhyloBranchPException & operator=(const PhyloBranchPException &nex)
PhyloBranchPException(const PhyloBranchPException &nex)
PhyloBranchPException(const std::string &text, const PhyloTree &tree, const std::shared_ptr< PhyloBranch > branch)
Build a new PhyloBranchPException.
virtual uint getBranchId() const
Get the id of branch that threw the exception.
virtual const PhyloBranch * getBranch() const
Get the branch that threw the exception.
PhyloBranchPException(const std::string &text, uint branchId)
Build a new PhyloBranchPException.
General exception thrown if a property could not be found.
PhyloBranchPropertyNotFoundException(const std::string &text, const std::string &propertyName, const PhyloTree &tree, const std::shared_ptr< PhyloBranch > branch)
Build a new PropertyNotFoundException (Branch).
PhyloBranchPropertyNotFoundException(const std::string &text, const std::string &propertyName, uint branchId)
Build a new PropertyNotFoundException.
virtual const std::string & getPropertyName() const
Get the name of the property that could not be found.
PhyloBranchPropertyNotFoundException(const std::string &text, const std::string &propertyName, const PhyloBranch *branch)
Build a new PropertyNotFoundException (Branch).
General exception thrown when something is wrong with a particular node.
virtual uint getNodeId() const
Get the id of node that threw the exception.
PhyloNodeException(const std::string &text, uint nodeId)
Build a new PhyloNodeException.
Exception thrown when something is wrong with a particular node.
PhyloNodeNotFoundException(const std::string &text, const std::string &id)
Build a new PhyloNodeNotFoundException.
virtual std::string getId() const
Get the node id that threw the exception.
General exception thrown when something is wrong with a particular node.
PhyloNodePException(const std::string &text, const PhyloTree &tree, const std::shared_ptr< PhyloNode > node)
Build a new PhyloNodePException.
virtual const PhyloNode * getNode() const
Get the node that threw the exception.
PhyloNodePException(const PhyloNodePException &nex)
PhyloNodePException(const std::string &text, uint nodeId)
Build a new PhyloNodePException.
virtual uint getNodeId() const
Get the id of node that threw the exception.
PhyloNodePException & operator=(const PhyloNodePException &nex)
General exception thrown if a property could not be found.
PhyloNodePropertyNotFoundException(const std::string &text, const std::string &propertyName, const PhyloNode *node)
Build a new PropertyNotFoundException (Node).
PhyloNodePropertyNotFoundException(const std::string &text, const std::string &propertyName, const PhyloTree &tree, const std::shared_ptr< PhyloNode > node)
Build a new PropertyNotFoundException (Node).
PhyloNodePropertyNotFoundException(const std::string &text, const std::string &propertyName, uint nodeId)
Build a new PropertyNotFoundException.
virtual const std::string & getPropertyName() const
Get the name of the property that could not be found.
General exception thrown when something wrong happened in a tree.
PhyloTreeException(const PhyloTreeException &tex)
PhyloTreeException & operator=(const PhyloTreeException &tex)
PhyloTreeException(const std::string &text, const PhyloTree *tree=0)
Build a new PhyloTreeException.
virtual const PhyloTree * getTree() const
Get the tree that threw the exception.
Exception thrown when a tree is expected to be rooted.
UnrootedPhyloTreeException(const std::string &text, const PhyloTree *tree=0)
Build a new UnrootedPhyloTreeException.
std::string toString(T t)
Defines the basic types of data flow nodes.