VPTissue Reference Manual
ListSweep.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "ListSweep.h"
21 
22 #include <cmath>
23 
24 using boost::property_tree::ptree;
25 using namespace std;
26 
27 namespace SimPT_Parex {
28 
29 ListSweep::ListSweep(const vector<string>& values) : m_values(values) {}
30 
31 ListSweep::ListSweep(const boost::property_tree::ptree& pt)
32 {
33  ReadPtree(pt);
34 }
35 
36 string ListSweep::GetValue(unsigned int index) const
37 {
38  assert(index < m_values.size() && "The index doesn't exist.");
39  return m_values[index];
40 }
41 
42 unsigned int ListSweep::GetNumberOfValues() const
43 {
44  return m_values.size();
45 }
46 
47 ptree ListSweep::ToPtree() const
48 {
49  ptree pt;
50  for (const string &value : m_values) {
51  pt.add("list.value", value);
52  }
53  return pt;
54 }
55 
56 void ListSweep::ReadPtree(const ptree& pt)
57 {
58  m_values.clear();
59  for (const auto& entry : pt.get_child("list")) {
60  m_values.push_back(entry.second.data());
61  }
62 }
63 
64 } // namespace
STL namespace.
virtual std::string GetValue(unsigned int index) const
Returns the value on the given index.
Definition: ListSweep.cpp:36
ListSweep(const std::vector< std::string > &values)
Constructor.
Definition: ListSweep.cpp:29
virtual boost::property_tree::ptree ToPtree() const
Convert the list sweep to a ptree.
Definition: ListSweep.cpp:47
virtual unsigned int GetNumberOfValues() const
Returns the number of values in the sweep.
Definition: ListSweep.cpp:42
Interface for ListSweep.
Namespace for SimPT parameter explorer package.
Definition: Client.cpp:52