bpp-core3  3.0.0
ParameterAliasable.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_NUMERIC_PARAMETERALIASABLE_H
6 #define BPP_NUMERIC_PARAMETERALIASABLE_H
7 
8 
9 #include "ParameterExceptions.h"
10 #include "ParameterList.h"
11 #include "Parametrizable.h"
12 
13 // From the STL:
14 #include <string>
15 #include <map>
16 
17 namespace bpp
18 {
49  public virtual Parametrizable
50 {
51 public:
53  virtual ~ParameterAliasable() {}
54 
55 public:
62  virtual size_t getNumberOfIndependentParameters() const = 0;
63 
73  virtual void aliasParameters(const std::string& p1, const std::string& p2) = 0;
74 
85  virtual void aliasParameters(std::map<std::string, std::string>& unparsedParams, bool verbose) = 0;
86 
96  virtual void unaliasParameters(const std::string& p1, const std::string& p2) = 0;
97 
105  virtual const ParameterList& getIndependentParameters() const = 0;
106 
112  virtual std::vector<std::string> getAlias(const std::string& name) const = 0;
113 
119  virtual std::map<std::string, std::string> getAliases() const = 0;
120 };
121 
122 
129  public ParametrizableAdapter
130 {
131 public:
134 
135 public:
142  void aliasParameters(const std::string& p1, const std::string& p2) {}
143  void unaliasParameters(const std::string& p1, const std::string& p2) {}
144  unsigned int getNumberOfIndependentParameters() const { return 0; }
145  std::vector<std::string> getAlias(const std::string& name) const { return std::vector<std::string>(); }
146  std::map<std::string, std::string> getAliases() const { return std::map<std::string, std::string>(); }
148 };
149 } // end of namespace bpp.
150 #endif // BPP_NUMERIC_PARAMETERALIASABLE_H
virtual size_t getNumberOfIndependentParameters() const =0
Get the number of independent parameters.
Extend the Parametrizable interface with support for parameter aliases.
virtual std::map< std::string, std::string > getAliases() const =0
virtual std::vector< std::string > getAlias(const std::string &name) const =0
virtual const ParameterList & getParameters() const =0
Get all parameters available.
std::vector< std::string > getAlias(const std::string &name) const
std::map< std::string, std::string > getAliases() const
virtual void aliasParameters(const std::string &p1, const std::string &p2)=0
Set two parameters as &#39;aliased&#39;.
A low-level implementation of the Parametrizable interface with void functions.
This is the interface for all objects that imply parameters.
The parameter list object.
Definition: ParameterList.h:27
const ParameterList & getIndependentParameters() const
A low-level implementation of the ParameterAliasable interface with void functions.
virtual const ParameterList & getIndependentParameters() const =0
Get the minimal list of parameters to set the model.
unsigned int getNumberOfIndependentParameters() const
virtual void unaliasParameters(const std::string &p1, const std::string &p2)=0
Detach two parameters previously set as &#39;aliased&#39;.
void aliasParameters(const std::string &p1, const std::string &p2)
void unaliasParameters(const std::string &p1, const std::string &p2)