OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
Scope.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_SCOPE_H_
33 #define _OMS_SCOPE_H_
34 
35 #include "ComRef.h"
36 #include "Model.h"
37 #include "Types.h"
38 
39 #include <map>
40 #include <string>
41 #include <vector>
42 
43 namespace oms
44 {
45  class Scope
46  {
47  private:
48  Scope();
49  ~Scope();
50 
51  // stop the compiler generating methods copying the object
52  Scope(Scope const&);
53  Scope& operator=(Scope const&);
54 
55  public:
60  static Scope& GetInstance();
61 
62  Model* newModel(const ComRef& cref);
63  oms_status_enu_t deleteModel(const ComRef& cref);
64  oms_status_enu_t renameModel(const ComRef& cref, const ComRef& newCref);
65  oms_status_enu_t exportModel(const ComRef& cref, const std::string& filename);
66  oms_status_enu_t importModel(const std::string& filename, char** cref);
67  oms_status_enu_t setTempDirectory(const std::string& newTempDir);
68  oms_status_enu_t setWorkingDirectory(const std::string& newWorkingDir);
69  oms_status_enu_t getElement(const ComRef& cref, oms::Element** element);
71  Model* getModel(const ComRef& cref);
72 
73  oms_status_enu_t loadSnapshot(const ComRef& cref, const char* snapshot, char** newCref);
74  oms_status_enu_t importSnapshot(const ComRef& cref, const char* snapshot, char** newCref);
75 
76  const std::string& getTempDirectory() const {return GetInstance().tempDir;}
77  std::string getWorkingDirectory();
78 
79  protected:
80  static oms_status_enu_t miniunz(const std::string& filename, const std::string& extractdir);
81 
82  private:
83  std::vector<Model*> models;
84  std::map<ComRef, unsigned int> models_map;
85 
86  std::string tempDir;
87  };
88 }
89 
90 #endif
Model * newModel(const ComRef &cref)
Definition: Scope.cpp:69
std::map< ComRef, unsigned int > models_map
Definition: Scope.h:84
Definition: Model.h:56
oms_status_enu_t setWorkingDirectory(const std::string &newWorkingDir)
Definition: Scope.cpp:307
const std::string & getTempDirectory() const
Definition: Scope.h:76
oms_status_enu_t getElement(const ComRef &cref, oms::Element **element)
Definition: Scope.cpp:351
static oms_status_enu_t miniunz(const std::string &filename, const std::string &extractdir)
Definition: Scope.cpp:144
oms_status_enu_t
Definition: Types.h:43
oms_status_enu_t getElements(const ComRef &cref, oms::Element ***elements)
Definition: Scope.cpp:379
oms_status_enu_t loadSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition: Scope.cpp:409
oms_status_enu_t setTempDirectory(const std::string &newTempDir)
Definition: Scope.cpp:272
const char * elements
Definition: Tags.cpp:54
Model * getModel(const ComRef &cref)
Definition: Scope.cpp:400
ComRef - component reference.
Definition: ComRef.h:46
oms_status_enu_t importSnapshot(const ComRef &cref, const char *snapshot, char **newCref)
Definition: Scope.cpp:443
oms_status_enu_t renameModel(const ComRef &cref, const ComRef &newCref)
Definition: Scope.cpp:108
std::vector< Model * > models
last element is always NULL
Definition: Scope.h:83
oms_status_enu_t importModel(const std::string &filename, char **cref)
Definition: Scope.cpp:182
Definition: AlgLoop.h:44
~Scope()
Definition: Scope.cpp:54
Scope()
Definition: Scope.cpp:42
Scope & operator=(Scope const &)
not implemented
Definition: Scope.h:45
oms_status_enu_t exportModel(const ComRef &cref, const std::string &filename)
Definition: Scope.cpp:135
Element.
Definition: Element.h:49
oms_status_enu_t deleteModel(const ComRef &cref)
Definition: Scope.cpp:89
static Scope & GetInstance()
Definition: Scope.cpp:62
std::string getWorkingDirectory()
Definition: Scope.cpp:337
std::string tempDir
Definition: Scope.h:86