BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OptionContainer.cpp
Go to the documentation of this file.
1
// ************************************************************************************************
2
//
3
// BornAgain: simulate and fit reflection and scattering
4
//
5
//! @file Fit/Tools/OptionContainer.cpp
6
//! @brief Implements class OptionContainer.
7
//!
8
//! @homepage http://www.bornagainproject.org
9
//! @license GNU General Public License v3 or higher (see COPYING)
10
//! @copyright Forschungszentrum Jülich GmbH 2018
11
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12
//
13
// ************************************************************************************************
14
15
#include "
Fit/Tools/OptionContainer.h
"
16
#include <sstream>
17
18
//! Returns true if option with such name already exists.
19
OptionContainer::OptionContainer
(
const
OptionContainer
& other)
20
{
21
for
(
const
auto
&
option
: other.
m_options
)
22
m_options
.push_back(
option_t
(
new
MultiOption
(*
option
)));
23
}
24
25
OptionContainer
&
OptionContainer::operator=
(
const
OptionContainer
& other)
26
{
27
if
(
this
!= &other) {
28
OptionContainer
tmp(other);
29
tmp.
swapContent
(*
this
);
30
}
31
return
*
this
;
32
}
33
34
OptionContainer::option_t
OptionContainer::option
(
const
std::string& optionName)
35
{
36
for
(
const
auto
&
option
:
m_options
) {
37
if
(
option
->name() == optionName)
38
return
option
;
39
}
40
41
throw
std::runtime_error(
"Configurable::getOption() -> Error. No option with name '"
42
+ optionName +
"'."
);
43
}
44
45
const
OptionContainer::option_t
OptionContainer::option
(
const
std::string& optionName)
const
46
{
47
for
(
const
auto
&
option
:
m_options
) {
48
if
(
option
->name() == optionName)
49
return
option
;
50
}
51
52
throw
std::runtime_error(
"Configurable::getOption() -> Error. No option with name '"
53
+ optionName +
"'."
);
54
}
55
56
bool
OptionContainer::exists
(
const
std::string&
name
)
57
{
58
for
(
const
auto
&
option
:
m_options
) {
59
if
(
option
->name() ==
name
)
60
return
true
;
61
}
62
return
false
;
63
}
64
65
void
OptionContainer::swapContent
(
OptionContainer
& other)
66
{
67
std::swap
(
m_options
, other.
m_options
);
68
}
OptionContainer.h
Declares class OptionContainer.
swap
void swap(OutputDataIterator< TValue, TContainer > &left, OutputDataIterator< TValue, TContainer > &right)
make Swappable
Definition:
OutputDataIterator.h:95
MultiOption
Stores a single option for minimization algorithm.
Definition:
MultiOption.h:30
OptionContainer
Stores multi option (int,double,string) in a container.
Definition:
OptionContainer.h:32
OptionContainer::option_t
std::shared_ptr< MultiOption > option_t
Definition:
OptionContainer.h:34
OptionContainer::operator=
OptionContainer & operator=(const OptionContainer &other)
Definition:
OptionContainer.cpp:25
OptionContainer::m_options
container_t m_options
Definition:
OptionContainer.h:66
OptionContainer::option
option_t option(const std::string &optionName)
Definition:
OptionContainer.cpp:34
OptionContainer::OptionContainer
OptionContainer()
Definition:
OptionContainer.h:39
OptionContainer::swapContent
void swapContent(OptionContainer &other)
Definition:
OptionContainer.cpp:65
OptionContainer::exists
bool exists(const std::string &name)
Definition:
OptionContainer.cpp:56
RealSpace::Particles::name
QString const & name(EShape k)
Definition:
particles.cpp:21
Fit
Tools
OptionContainer.cpp
Generated by
1.9.1