bpp-phyl3  3.0.0
NNITopologySearch.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_LEGACY_TREE_NNITOPOLOGYSEARCH_H
6 #define BPP_PHYL_LEGACY_TREE_NNITOPOLOGYSEARCH_H
7 
8 
9 #include "../../Tree/NNISearchable.h"
10 #include "../../Tree/TopologySearch.h"
11 
12 namespace bpp
13 {
27  public virtual TopologySearch
28 {
29 public:
30  const static std::string FAST;
31  const static std::string BETTER;
32  const static std::string PHYML;
33 
34 private:
35  std::shared_ptr<NNISearchable> searchableTree_;
36  std::string algorithm_;
37  unsigned int verbose_;
38  std::vector<std::shared_ptr<TopologyListener>> topoListeners_;
39 
40 public:
42  std::shared_ptr<NNISearchable> tree,
43  const std::string& algorithm = FAST,
44  unsigned int verbose = 2) :
45  searchableTree_(tree), algorithm_(algorithm), verbose_(verbose), topoListeners_()
46  {}
47 
51  verbose_(ts.verbose_),
53  {
54  // Hard-copy all listeners:
55  for (unsigned int i = 0; i < topoListeners_.size(); i++)
56  {
57  topoListeners_[i].reset(ts.topoListeners_[i]->clone());
58  }
59  }
60 
62  {
65  verbose_ = ts.verbose_;
67  // Hard-copy all listeners:
68  for (unsigned int i = 0; i < topoListeners_.size(); i++)
69  {
70  topoListeners_[i].reset(ts.topoListeners_[i]->clone());
71  }
72  return *this;
73  }
74 
75 
77  {}
78 
79 public:
80  void search();
81 
90  void addTopologyListener(std::shared_ptr<TopologyListener> listener)
91  {
92  if (listener)
93  topoListeners_.push_back(listener);
94  }
95 
96 public:
102  const Tree& topology() const { return searchableTree_->topology(); }
103 
107  std::shared_ptr<NNISearchable> getSearchableObject() { return searchableTree_; }
108 
112  std::shared_ptr<const NNISearchable> getSearchableObject() const { return searchableTree_; }
113 
114 protected:
115  void searchFast();
116  void searchBetter();
117  void searchPhyML();
118 
122  void notifyAllPerformed(const TopologyChangeEvent& event);
126  void notifyAllTested(const TopologyChangeEvent& event);
130  void notifyAllSuccessful(const TopologyChangeEvent& event);
131 };
132 } // end of namespace bpp.
133 #endif // BPP_PHYL_LEGACY_TREE_NNITOPOLOGYSEARCH_H
NNI topology search method.
std::shared_ptr< const NNISearchable > getSearchableObject() const
NNITopologySearch(const NNITopologySearch &ts)
static const std::string PHYML
NNITopologySearch & operator=(const NNITopologySearch &ts)
std::vector< std::shared_ptr< TopologyListener > > topoListeners_
std::shared_ptr< NNISearchable > searchableTree_
void notifyAllTested(const TopologyChangeEvent &event)
Process a TopologyChangeEvent to all listeners.
void notifyAllPerformed(const TopologyChangeEvent &event)
Process a TopologyChangeEvent to all listeners.
static const std::string FAST
std::shared_ptr< NNISearchable > getSearchableObject()
static const std::string BETTER
const Tree & topology() const
Retrieve the tree.
void search()
Performs the search.
NNITopologySearch(std::shared_ptr< NNISearchable > tree, const std::string &algorithm=FAST, unsigned int verbose=2)
void notifyAllSuccessful(const TopologyChangeEvent &event)
Process a TopologyChangeEvent to all listeners.
void addTopologyListener(std::shared_ptr< TopologyListener > listener)
Add a listener to the list.
Class for notifying new toplogy change events.
Interface for topology search methods.
Interface for phylogenetic tree objects.
Definition: Tree.h:115
Defines the basic types of data flow nodes.