OpenMS
ModelDescription.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 #include <OpenMS/CONCEPT/Factory.h>
14 
15 #include <sstream>
16 
17 namespace OpenMS
18 {
26  template <UInt D>
28  {
29 public:
30 
33  name_(),
34  parameters_()
35  {
36  }
37 
40  name_(source.name_),
41  parameters_(source.parameters_)
42  {
43  }
44 
46  ModelDescription(const BaseModel<D> * model) :
47  name_(model->getName()),
48  parameters_(model->getParameters())
49  {
50  }
51 
54  {
55  }
56 
58  virtual ModelDescription & operator=(const ModelDescription & source)
59  {
60  if (&source == this) return *this;
61 
62  name_ = source.name_;
63  parameters_ = source.parameters_;
64 
65  return *this;
66  }
67 
71  {
72  if (name_.empty()) return nullptr;
73 
74  BaseModel<D> * model = Factory<BaseModel<D> >::create(name_);
75  model->setParameters(parameters_);
76  return model;
77  }
78 
82  const String & getName() const
83  {
84  return name_;
85  }
86 
89  {
90  return name_;
91  }
92 
94  void setName(const String & name)
95  {
96  name_ = name;
97  }
98 
100  const Param & getParam() const
101  {
102  return parameters_;
103  }
104 
107  {
108  return parameters_;
109  }
110 
112  void setParam(const Param & param)
113  {
114  parameters_ = param;
115  }
116 
119  virtual bool operator==(const ModelDescription & rhs) const
120  {
121  return (name_ == rhs.name_) && (parameters_ == rhs.parameters_);
122  }
123 
124  virtual bool operator!=(const ModelDescription & rhs) const
125  {
126  return !(operator==(rhs));
127  }
128 
130 
131 protected:
132 
135  };
136 }
Abstract base class for all D-dimensional models.
Definition: BaseModel.h:25
void setParameters(const Param &param)
Sets the parameters.
Returns FactoryProduct* based on the name of the desired concrete FactoryProduct.
Definition: Factory.h:37
Stores the name and parameters of a model.
Definition: ModelDescription.h:28
void setParam(const Param &param)
Set the model parameters.
Definition: ModelDescription.h:112
Param & getParam()
Mutable access to the model parameters.
Definition: ModelDescription.h:106
BaseModel< D > * createModel()
Definition: ModelDescription.h:70
const Param & getParam() const
Non-mutable access to model parameters.
Definition: ModelDescription.h:100
String name_
Definition: ModelDescription.h:133
virtual bool operator==(const ModelDescription &rhs) const
Definition: ModelDescription.h:119
ModelDescription(const BaseModel< D > *model)
constructor provided for convenience
Definition: ModelDescription.h:46
void setName(const String &name)
Set the model name.
Definition: ModelDescription.h:94
virtual ~ModelDescription()
destructor
Definition: ModelDescription.h:53
virtual bool operator!=(const ModelDescription &rhs) const
Definition: ModelDescription.h:124
ModelDescription()
Default constructor.
Definition: ModelDescription.h:32
virtual ModelDescription & operator=(const ModelDescription &source)
assignment operator
Definition: ModelDescription.h:58
const String & getName() const
Non-mutable access to model name.
Definition: ModelDescription.h:82
Param parameters_
Definition: ModelDescription.h:134
ModelDescription(const ModelDescription &source)
copy constructor
Definition: ModelDescription.h:39
String & getName()
Mutable access to the model name.
Definition: ModelDescription.h:88
Management and storage of parameters / INI files.
Definition: Param.h:44
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22