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
47 namespace 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&);
57 Scope& operator=(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.h
Model.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:51
oms::Element
Element.
Definition Element.h:51
oms::Model
Definition Model.h:57
oms::Scope
Definition Scope.h:50
oms::Scope::getWorkingDirectory
const std::string & getWorkingDirectory()
Definition Scope.cpp:349
oms::Scope::setWorkingDirectory
oms_status_enu_t setWorkingDirectory(const std::string &newWorkingDir)
Definition Scope.cpp:318
oms::Scope::Scope
Scope(Scope const &)
not implemented
oms::Scope::getElement
oms_status_enu_t getElement(const ComRef &cref, oms::Element **element)
Definition Scope.cpp:364
oms::Scope::Scope
Scope()
Definition Scope.cpp:46
oms::Scope::exportModel
oms_status_enu_t exportModel(const ComRef &cref, const std::string &filename)
Definition Scope.cpp:139
oms::Scope::operator=
Scope & operator=(Scope const &)
not implemented
oms::Scope::~Scope
~Scope()
Definition Scope.cpp:58
oms::Scope::deleteModel
oms_status_enu_t deleteModel(const ComRef &cref)
Definition Scope.cpp:93
oms::Scope::miniunz
static oms_status_enu_t miniunz(const std::string &filename, const std::string &extractdir)
Definition Scope.cpp:148
oms::Scope::GetInstance
static Scope & GetInstance()
Definition Scope.cpp:66
oms::Scope::importSnapshot
oms_status_enu_t importSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition Scope.cpp:456
oms::Scope::workDir
std::string workDir
Definition Scope.h:90
oms::Scope::newModel
Model * newModel(const ComRef &cref)
Definition Scope.cpp:73
oms::Scope::loadSnapshot
oms_status_enu_t loadSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition Scope.cpp:422
oms::Scope::importModel
oms_status_enu_t importModel(const std::string &filename, char **cref)
Definition Scope.cpp:186
oms::Scope::models
std::vector< Model * > models
last element is always NULL
Definition Scope.h:86
oms::Scope::setTempDirectory
oms_status_enu_t setTempDirectory(const std::string &newTempDir)
Definition Scope.cpp:283
oms::Scope::models_map
std::map< ComRef, unsigned int > models_map
Definition Scope.h:87
oms::Scope::tempDir
std::string tempDir
Definition Scope.h:89
oms::Scope::getModel
Model * getModel(const ComRef &cref)
Definition Scope.cpp:413
oms::Scope::getElements
oms_status_enu_t getElements(const ComRef &cref, oms::Element ***elements)
Definition Scope.cpp:392
oms::Scope::renameModel
oms_status_enu_t renameModel(const ComRef &cref, const ComRef &newCref)
Definition Scope.cpp:112
oms::Scope::getTempDirectory
const std::string & getTempDirectory() const
Definition Scope.h:80
oms
Definition AlgLoop.h:52