27 #include <boost/property_tree/ptree.hpp>
28 #include <boost/property_tree/xml_parser.hpp>
38 SimWrapper::SimWrapper()
39 : m_sim(make_shared<Sim>())
46 return { SUCCESS, string(), m_sim->GetState() };
48 catch (std::exception & e) {
49 return { FAILURE, e.what(),
SimState() };
52 return { FAILURE,
"Unknown exception",
SimState() };
60 write_xml(ss, m_sim->ToPtree(), XmlWriterSettings::GetTab());
61 return { SUCCESS, string(), ss.str() };
63 catch (std::exception & e) {
64 return { FAILURE, e.what(), string() };
67 return { FAILURE,
"Unknown exception", string() };
74 m_sim->Initialize(state);
75 return { SUCCESS, string() };
77 catch (std::exception & e) {
78 return { FAILURE, e.what() };
81 return { FAILURE,
"Unknown exception" };
89 PTreeFile::Read(path, pt);
90 m_sim->Initialize(pt);
91 return { SUCCESS, string() };
93 catch (std::exception & e) {
94 return { FAILURE, e.what() };
97 return { FAILURE,
"Unknown exception" };
105 return { SUCCESS, string() };
107 catch (std::exception & e) {
108 return { FAILURE, e.what() };
111 return { FAILURE,
"Unknown exception" };
Namespace for miscellaneous utilities.
Interface for SimWrapper.
Specialization of SimWrapperResult template for type void.
SimWrapperResult< std::string > GetXMLState() const
Provide sim state in XML format serialized to string.
Namespace for the core simulator.
SimWrapperResult< void > Initialize(SimState state)
Set sim state.
Sim, the actual simulator.
All exceptions must be dealt with internally, so each method returns an object of this type...
Contains the state of the whole Simulator at a given simulation step.
SimWrapperResult< void > TimeStep()
Let simulator take a time step.
SimWrapperResult< SimState > GetState() const
Provide sim state in format suitable for i/o.
Xml writer settings class.