bpp-phyl3 3.0.0
IoTreeFactory.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#include "IoTreeFactory.h"
6#include "Newick.h"
7#include "NexusIoTree.h"
8#include "Nhx.h"
9
10using namespace bpp;
11
12const std::string IOTreeFactory::NEWICK_FORMAT = "Newick";
13const std::string IOTreeFactory::NEXUS_FORMAT = "Nexus";
14const std::string IOTreeFactory::NHX_FORMAT = "Nhx";
15
16std::unique_ptr<ITree> IOTreeFactory::createReader(const std::string& format)
17{
18 if (format == NEWICK_FORMAT)
19 return std::make_unique<Newick>();
20 else if (format == NEXUS_FORMAT)
21 return std::make_unique<NexusIOTree>();
22 else if (format == NHX_FORMAT)
23 return std::make_unique<Nhx>();
24 else
25 throw Exception("Format " + format + " is not supported for input.");
26}
27
28std::unique_ptr<OTree> IOTreeFactory::createWriter(const std::string& format)
29{
30 if (format == NEWICK_FORMAT)
31 return std::make_unique<Newick>();
32 else if (format == NEXUS_FORMAT)
33 return std::make_unique<NexusIOTree>();
34 else if (format == NHX_FORMAT)
35 return std::make_unique<Nhx>();
36 else
37 throw Exception("Format " + format + " is not supported for output.");
38}
virtual std::unique_ptr< OTree > createWriter(const std::string &format)
Get a new dynamically created OTree object.
static const std::string NEXUS_FORMAT
Definition: IoTreeFactory.h:23
static const std::string NHX_FORMAT
Definition: IoTreeFactory.h:24
static const std::string NEWICK_FORMAT
Definition: IoTreeFactory.h:22
Defines the basic types of data flow nodes.