OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment.
Loading...
Searching...
No Matches
Scope.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, 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 AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36#ifndef _OMS_SCOPE_H_
37#define _OMS_SCOPE_H_
38
39#include "ComRef.h"
40#include "Model.h"
41#include "OMSimulator/Types.h"
42
43#include <map>
44#include <string>
45#include <vector>
46
47namespace oms
48{
49 class Scope
50 {
51 private:
52 Scope();
53 ~Scope();
54
55 // stop the compiler generating methods copying the object
56 Scope(Scope const&);
58
59 public:
64 static Scope& GetInstance();
65
66 Model* newModel(const ComRef& cref);
67 oms_status_enu_t deleteModel(const ComRef& cref);
68 oms_status_enu_t renameModel(const ComRef& cref, const ComRef& newCref);
69 oms_status_enu_t exportModel(const ComRef& cref, const std::string& filename);
70 oms_status_enu_t importModel(const std::string& filename, char** cref);
71 oms_status_enu_t setTempDirectory(const std::string& newTempDir);
72 oms_status_enu_t setWorkingDirectory(const std::string& newWorkingDir);
73 oms_status_enu_t getElement(const ComRef& cref, oms::Element** element);
74 oms_status_enu_t getElements(const ComRef& cref, oms::Element*** elements);
75 Model* getModel(const ComRef& cref);
76
77 oms_status_enu_t loadSnapshot(const ComRef& cref, const char* snapshot, char** newCref);
78 oms_status_enu_t importSnapshot(const ComRef& cref, const char* snapshot, char** newCref);
79
80 const std::string& getTempDirectory() const {return GetInstance().tempDir;}
81 const std::string& getWorkingDirectory();
82
83 static oms_status_enu_t miniunz(const std::string& filename, const std::string& extractdir);
84
85 private:
86 std::vector<Model*> models;
87 std::map<ComRef, unsigned int> models_map;
88
89 std::string tempDir;
90 std::string workDir;
91 };
92}
93
94#endif
ComRef - component reference.
Definition ComRef.h:51
Element.
Definition Element.h:51
Definition Model.h:57
Definition Scope.h:50
const std::string & getWorkingDirectory()
Definition Scope.cpp:349
oms_status_enu_t setWorkingDirectory(const std::string &newWorkingDir)
Definition Scope.cpp:318
Scope(Scope const &)
not implemented
oms_status_enu_t getElement(const ComRef &cref, oms::Element **element)
Definition Scope.cpp:364
Scope()
Definition Scope.cpp:46
oms_status_enu_t exportModel(const ComRef &cref, const std::string &filename)
Definition Scope.cpp:139
Scope & operator=(Scope const &)
not implemented
~Scope()
Definition Scope.cpp:58
oms_status_enu_t deleteModel(const ComRef &cref)
Definition Scope.cpp:93
static oms_status_enu_t miniunz(const std::string &filename, const std::string &extractdir)
Definition Scope.cpp:148
static Scope & GetInstance()
Definition Scope.cpp:66
oms_status_enu_t importSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition Scope.cpp:456
std::string workDir
Definition Scope.h:90
Model * newModel(const ComRef &cref)
Definition Scope.cpp:73
oms_status_enu_t loadSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition Scope.cpp:422
oms_status_enu_t importModel(const std::string &filename, char **cref)
Definition Scope.cpp:186
std::vector< Model * > models
last element is always NULL
Definition Scope.h:86
oms_status_enu_t setTempDirectory(const std::string &newTempDir)
Definition Scope.cpp:283
std::map< ComRef, unsigned int > models_map
Definition Scope.h:87
std::string tempDir
Definition Scope.h:89
Model * getModel(const ComRef &cref)
Definition Scope.cpp:413
oms_status_enu_t getElements(const ComRef &cref, oms::Element ***elements)
Definition Scope.cpp:392
oms_status_enu_t renameModel(const ComRef &cref, const ComRef &newCref)
Definition Scope.cpp:112
const std::string & getTempDirectory() const
Definition Scope.h:80
Definition AlgLoop.h:49