22 using boost::property_tree::ptree;
27 FileExploration::FileExploration(
const string& name,
const vector<pair<string, ptree>>& files,
const ptree& preferences)
28 : Exploration(name, preferences)
30 for (
const auto& pair : files) {
31 m_file_names.push_back(pair.first);
32 m_file_contents.push_back(pair.second);
36 FileExploration::FileExploration(
const ptree& pt)
43 :
Exploration(other), m_file_names(other.m_file_names), m_file_contents(other.m_file_contents)
52 m_file_names = other.m_file_names;
53 m_file_contents = other.m_file_contents;
72 return { m_file_names[index] };
77 return m_file_names.size();
92 auto index_of = [
this](
const string& elem){
93 return distance(m_file_names.begin(),
94 find(m_file_names.begin(), m_file_names.end(), elem));
97 for (
const string& name : m_file_names) {
99 file_pt.put(
"name", name);
100 file_pt.put_child(
"contents", m_file_contents[index_of(name)]);
101 pt.add_child(
"files.file", file_pt);
107 void FileExploration::ReadPtree(
const ptree& pt)
109 assert(pt.find(
"files") != pt.not_found() &&
"No files were found in this exploration.");
111 m_file_names.clear();
112 m_file_contents.clear();
114 for (
const auto& pair : pt.get_child(
"files")) {
115 m_file_names.push_back(pair.second.get<std::string>(
"name"));
116 m_file_contents.push_back(pair.second.get_child(
"contents"));
virtual boost::property_tree::ptree ToPtree() const
Convert the exploration to a ptree.
virtual FileExploration * Clone() const
Clone function.
Class describing a file-based exploration and its simulation tasks.
virtual std::vector< std::string > GetParameters() const
Returns all the parameters in the exploration.
virtual boost::property_tree::ptree ToPtree() const
Convert the exploration to a ptree.
FileExploration & operator=(const FileExploration &other)
Assignment operator.
virtual std::vector< std::string > GetValues(unsigned int index) const
Return the values of a certain task.
const std::string & GetName() const
Returns the name of the exploration.
virtual unsigned int GetNumberOfTasks() const
Returns the number of tasks the exploration currently contains.
FileExploration(const std::string &name, const std::vector< std::pair< std::string, boost::property_tree::ptree >> &files, const boost::property_tree::ptree &preferences)
Constructor.
const boost::property_tree::ptree & GetPreferences() const
Returns the preferences of the exploration.
Namespace for SimPT parameter explorer package.
Contains all information needed for a transmitable simulation task.
Class describing a generic exploration.
virtual SimTask * CreateTask(unsigned int index) const
Creates a task with the parameters on the given index.
Interface for FileExploration.