OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
Snapshot.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenModelica.
3  *
4  * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5  * c/o Linköpings universitet, Department of Computer and Information Science,
6  * SE-58183 Linköping, Sweden.
7  *
8  * All rights reserved.
9  *
10  * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11  * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12  * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13  * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14  * ACCORDING TO RECIPIENTS CHOICE.
15  *
16  * The OpenModelica software and the Open Source Modelica
17  * Consortium (OSMC) Public License (OSMC-PL) are obtained
18  * from OSMC, either from the above address,
19  * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20  * http://www.openmodelica.org, and in the OpenModelica distribution.
21  * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22  *
23  * This program is distributed WITHOUT ANY WARRANTY; without
24  * even the implied warranty of MERCHANTABILITY or FITNESS
25  * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26  * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27  *
28  * See the full OSMC Public License conditions for more details.
29  *
30  */
31 
32 #ifndef _OMS_SNAPSHOT_H_
33 #define _OMS_SNAPSHOT_H_
34 
35 #include "ComRef.h"
36 #include "OMSFileSystem.h"
37 #include "ssd/Tags.h"
38 #include "OMSimulator/Types.h"
39 
40 #include <pugixml.hpp>
41 #include <string>
42 #include <vector>
43 
44 namespace oms
45 {
46  class Snapshot
47  {
48  public:
49  Snapshot(bool partial=false);
50  ~Snapshot();
51 
52  oms_status_enu_t import(const char* snapshot);
53  oms_status_enu_t importResourceFile(const filesystem::path& filename, const filesystem::path& root);
54  oms_status_enu_t importResourceMemory(const filesystem::path& filename, const char* contents);
55  oms_status_enu_t importResourceNode(const filesystem::path& filename, const pugi::xml_node& node);
56 
57  bool isPartialSnapshot() const;
58 
59  pugi::xml_node newResourceNode(const filesystem::path& filename);
60  pugi::xml_node operator[](const filesystem::path& filename);
61 
62  void getResources(std::vector<std::string>& resources) const;
63  pugi::xml_node getResourceNode(const filesystem::path& filename) const;
64 
65  pugi::xml_node getTemplateResourceNodeSSD(const filesystem::path& filename, const ComRef& cref);
66  pugi::xml_node getTemplateResourceNodeSSV(const filesystem::path& filename, const std::string& cref);
67  pugi::xml_node getTemplateResourceNodeSSM(const filesystem::path& filename);
68  pugi::xml_node getTemplateResourceNodeSignalFilter(const filesystem::path& filename);
69  pugi::xml_node getTemplateResourceNodeSSDVariants();
70  oms_status_enu_t exportPartialSnapshot(const ComRef& cref, Snapshot& partialSnapshot);
71  oms_status_enu_t importPartialSnapshot(const char* fullsnapshot);
72 
73  void debugPrintNode(const filesystem::path& filename) const;
74  void debugPrintAll() const;
75  oms::ComRef getRootCref() const;
78 
79  oms_status_enu_t deleteResourceNode(const filesystem::path& filename);
80 
81  oms_status_enu_t writeDocument(char** contents);
82  oms_status_enu_t writeResourceNode(const filesystem::path& filename, const filesystem::path& path) const;
83 
84  private:
85  oms_status_enu_t importPartialResourceNode(const filesystem::path& filename, const filesystem::path& nodename, const pugi::xml_node& node);
86 
87  private:
88  // stop the compiler generating methods copying the object
89  Snapshot(Snapshot const& copy);
90  Snapshot& operator=(Snapshot const& copy);
91 
92  private:
93  pugi::xml_document doc; // snapshot document
94  };
95 }
96 
97 #endif
oms::Snapshot::debugPrintNode
void debugPrintNode(const filesystem::path &filename) const
Definition: Snapshot.cpp:169
oms
Definition: AlgLoop.h:44
oms::ssp::Draft20180219::ssd::system_structure_description
const char * system_structure_description
Definition: Tags.cpp:58
ComRef.h
oms::Snapshot::writeResourceNode
oms_status_enu_t writeResourceNode(const filesystem::path &filename, const filesystem::path &path) const
Definition: Snapshot.cpp:439
oms::Snapshot::getSSDFilename
oms::ComRef getSSDFilename() const
Definition: Snapshot.cpp:240
oms::Snapshot::operator[]
pugi::xml_node operator[](const filesystem::path &filename)
Definition: Snapshot.cpp:158
oms::ssp::Draft20180219::ssd::system
const char * system
Definition: Tags.cpp:57
oms::Snapshot::writeDocument
oms_status_enu_t writeDocument(char **contents)
Definition: Snapshot.cpp:412
oms::Snapshot::getTemplateResourceNodeSSD
pugi::xml_node getTemplateResourceNodeSSD(const filesystem::path &filename, const ComRef &cref)
Definition: Snapshot.cpp:182
oms::ComRef
ComRef - component reference.
Definition: ComRef.h:46
oms::Snapshot::getRootCref
oms::ComRef getRootCref() const
Definition: Snapshot.cpp:260
oms::ssp::Draft20180219::ssd::component
const char * component
Definition: Tags.cpp:45
oms::ssp::Version1_0::oms_file
const char * oms_file
Definition: Tags.cpp:72
oms::Snapshot::getTemplateResourceNodeSignalFilter
pugi::xml_node getTemplateResourceNodeSignalFilter(const filesystem::path &filename)
Definition: Snapshot.cpp:222
Snapshot.h
oms::ssp::Version1_0::ssv::parameters
const char * parameters
Definition: Tags.cpp:80
Tags.h
oms::Snapshot::getTemplateResourceNodeSSV
pugi::xml_node getTemplateResourceNodeSSV(const filesystem::path &filename, const std::string &cref)
Definition: Snapshot.cpp:198
oms::Snapshot::operator=
Snapshot & operator=(Snapshot const &copy)
not implemented
oms::ssp::Version1_0::snap_shot
const char * snap_shot
Definition: Tags.cpp:71
oms::Snapshot::getSignalFilterFilename
oms::ComRef getSignalFilterFilename() const
Definition: Snapshot.cpp:250
oms::ssp::Draft20180219::ssd::elements
const char * elements
Definition: Tags.cpp:54
oms::Snapshot::debugPrintAll
void debugPrintAll() const
Definition: Snapshot.cpp:177
oms::Snapshot::importPartialResourceNode
oms_status_enu_t importPartialResourceNode(const filesystem::path &filename, const filesystem::path &nodename, const pugi::xml_node &node)
Definition: Snapshot.cpp:115
oms::ssp::Version1_0::oms_signalFilter
const char * oms_signalFilter
Definition: Tags.cpp:68
oms::Snapshot::exportPartialSnapshot
oms_status_enu_t exportPartialSnapshot(const ComRef &cref, Snapshot &partialSnapshot)
Definition: Snapshot.cpp:271
oms::ComRef::pop_suffix
std::string pop_suffix()
returns the suffix as string and removes it from the current object
Definition: ComRef.cpp:118
oms::Snapshot::deleteResourceNode
oms_status_enu_t deleteResourceNode(const filesystem::path &filename)
Definition: Snapshot.cpp:145
oms::Snapshot::importResourceNode
oms_status_enu_t importResourceNode(const filesystem::path &filename, const pugi::xml_node &node)
Definition: Snapshot.cpp:105
oms::Snapshot::getResources
void getResources(std::vector< std::string > &resources) const
Definition: Snapshot.cpp:126
oms::Snapshot::getResourceNode
pugi::xml_node getResourceNode(const filesystem::path &filename) const
Definition: Snapshot.cpp:133
oms::ComRef::isEmpty
bool isEmpty() const
Definition: ComRef.cpp:99
oms::Snapshot
Definition: Snapshot.h:46
oms::Snapshot::~Snapshot
~Snapshot()
Definition: Snapshot.cpp:48
oms::Snapshot::getTemplateResourceNodeSSDVariants
pugi::xml_node getTemplateResourceNodeSSDVariants()
Definition: Snapshot.cpp:231
oms::Snapshot::importResourceFile
oms_status_enu_t importResourceFile(const filesystem::path &filename, const filesystem::path &root)
Definition: Snapshot.cpp:83
oms::Snapshot::newResourceNode
pugi::xml_node newResourceNode(const filesystem::path &filename)
Definition: Snapshot.cpp:52
oms::Snapshot::Snapshot
Snapshot(bool partial=false)
Definition: Snapshot.cpp:39
oms::Snapshot::import
oms_status_enu_t import(const char *snapshot)
Definition: Snapshot.cpp:68
oms::Snapshot::getTemplateResourceNodeSSM
pugi::xml_node getTemplateResourceNodeSSM(const filesystem::path &filename)
Definition: Snapshot.cpp:211
oms::ComRef::c_str
const char * c_str() const
Definition: ComRef.h:75
oms::Snapshot::doc
pugi::xml_document doc
Definition: Snapshot.h:93
logError
#define logError(msg)
Definition: Logging.h:102
oms::ssp::Version1_0::ssv::parameter_set
const char * parameter_set
Definition: Tags.cpp:79
oms::Snapshot::importPartialSnapshot
oms_status_enu_t importPartialSnapshot(const char *fullsnapshot)
Definition: Snapshot.cpp:332
oms::Snapshot::importResourceMemory
oms_status_enu_t importResourceMemory(const filesystem::path &filename, const char *contents)
Definition: Snapshot.cpp:95
oms::ssp::Version1_0::ssm::parameter_mapping
const char * parameter_mapping
Definition: Tags.cpp:104
OMSString.h
oms::ComRef::pop_front
ComRef pop_front()
returns the first part of the ComRef and removed it from the current object
Definition: ComRef.cpp:184
Logging.h
OMSFileSystem.h
oms::mallocAndCopyString
char * mallocAndCopyString(const char *source)
Definition: OMSString.cpp:67
oms::Snapshot::isPartialSnapshot
bool isPartialSnapshot() const
Definition: Snapshot.cpp:77