Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ModelDescription.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_MODELDESCRIPTION_H
36 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_MODELDESCRIPTION_H
37 
40 #include <OpenMS/CONCEPT/Factory.h>
41 
42 #include <sstream>
43 
44 namespace OpenMS
45 {
53  template <UInt D>
55  {
56 public:
57 
60  name_(),
61  parameters_()
62  {
63  }
64 
67  name_(source.name_),
68  parameters_(source.parameters_)
69  {
70  }
71 
73  ModelDescription(const BaseModel<D> * model) :
74  name_(model->getName()),
75  parameters_(model->getParameters())
76  {
77  }
78 
81  {
82  }
83 
85  virtual ModelDescription & operator=(const ModelDescription & source)
86  {
87  if (&source == this) return *this;
88 
89  name_ = source.name_;
90  parameters_ = source.parameters_;
91 
92  return *this;
93  }
94 
98  {
99  if (name_ == "") return 0;
100 
101  BaseModel<D> * model = Factory<BaseModel<D> >::create(name_);
102  model->setParameters(parameters_);
103  return model;
104  }
105 
108  const String & getName() const
110  {
111  return name_;
112  }
113 
116  {
117  return name_;
118  }
119 
121  void setName(const String & name)
122  {
123  name_ = name;
124  }
125 
127  const Param & getParam() const
128  {
129  return parameters_;
130  }
131 
134  {
135  return parameters_;
136  }
137 
139  void setParam(const Param & param)
140  {
141  parameters_ = param;
142  }
143 
146  virtual bool operator==(const ModelDescription & rhs) const
147  {
148  return (name_ == rhs.name_) && (parameters_ == rhs.parameters_);
149  }
150 
151  virtual bool operator!=(const ModelDescription & rhs) const
152  {
153  return !(operator==(rhs));
154  }
155 
157 
158 protected:
159 
162  };
163 }
164 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_MODELDESCRIPTION_H
const Param & getParam() const
Non-mutable access to model parameters.
Definition: ModelDescription.h:127
A more convenient string class.
Definition: String.h:57
ModelDescription()
Default constructor.
Definition: ModelDescription.h:59
Returns FactoryProduct* based on the name of the desired concrete FactoryProduct. ...
Definition: Factory.h:61
Param & getParam()
Mutable access to the model parameters.
Definition: ModelDescription.h:133
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setParameters(const Param &param)
Sets the parameters.
virtual bool operator!=(const ModelDescription &rhs) const
Definition: ModelDescription.h:151
String name_
Definition: ModelDescription.h:160
Param parameters_
Definition: ModelDescription.h:161
BaseModel< D > * createModel()
Definition: ModelDescription.h:97
virtual bool operator==(const ModelDescription &rhs) const
Definition: ModelDescription.h:146
String & getName()
Mutable access to the model name.
Definition: ModelDescription.h:115
const String & getName() const
Non-mutable access to model name.
Definition: ModelDescription.h:109
void setName(const String &name)
Set the model name.
Definition: ModelDescription.h:121
ModelDescription(const ModelDescription &source)
copy constructor
Definition: ModelDescription.h:66
Management and storage of parameters / INI files.
Definition: Param.h:75
Stores the name and parameters of a model.
Definition: ModelDescription.h:54
virtual ~ModelDescription()
destructor
Definition: ModelDescription.h:80
Abstract base class for all D-dimensional models.
Definition: BaseModel.h:51
virtual ModelDescription & operator=(const ModelDescription &source)
assignment operator
Definition: ModelDescription.h:85
ModelDescription(const BaseModel< D > *model)
constructor provided for convenience
Definition: ModelDescription.h:73
void setParam(const Param &param)
Set the model parameters.
Definition: ModelDescription.h:139

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:02 using doxygen 1.8.13