Skyscraper 2.0
vm.h
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 - Nanokernel
3 Copyright (C)2004-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#ifndef VM_H
24#define VM_H
25
26#include <thread>
27#include <vector>
28
29//DLL Exporting
30#ifdef _WIN32
31 #if defined(_MSC_VER)
32 #define __VISUALC__ _MSC_VER
33 #endif
34 #if defined(__VISUALC__) || defined(__GNUC__)
35 #if defined(VM_EXPORTS)
36 #define VMIMPEXP __declspec(dllexport)
37 #define VMIMPEXP_DATA(type) __declspec(dllexport) type
38 #else
39 #define VMIMPEXP __declspec(dllimport)
40 #define VMIMPEXP_DATA(type) __declspec(dllimport) type
41 #endif
42 #else
43 #define VMIMPEXP
44 #define VMIMPEXP_DATA(type) type
45 #endif
46#endif
47
48#ifndef VMIMPEXP
49 #define VMIMPEXP
50 #define VMIMPEXP_DATA(type)
51#endif
52
53namespace SBS {
54
55 class SBS;
56}
57
58class wxWindow;
59
60namespace Skyscraper {
61
62class EngineContext;
63class ScriptProcessor;
64class HAL;
65class SkySystem;
66class GUI;
67class VMConsole;
68
69//Virtual Manager system
71{
72 friend class VMConsole;
73
74public:
75 VM();
76 ~VM();
77 void SetParent(wxWindow *parent);
78 HAL* GetHAL();
79 SkySystem* GetSkySystem();
80 GUI* GetGUI();
81 EngineContext* GetActiveEngine() { return active_engine; }
82 EngineContext* GetEngine(int number);
83 EngineContext* CreateEngine(EngineContext *parent = 0, const Vector3 &position = Vector3::ZERO, Real rotation = 0.0, const Vector3 &area_min = Vector3::ZERO, const Vector3 &area_max = Vector3::ZERO);
84 bool DeleteEngine(EngineContext *engine);
85 void DeleteEngines();
86 int GetEngineCount(bool loading_only = false);
87 int GetEngineListSize() { return (int)engines.size(); }
88 EngineContext* FindActiveEngine();
89 void SetActiveEngine(int number, bool switch_engines = false, bool force = false);
90 bool IsEngineLoading();
91 bool IsValidEngine(EngineContext *engine);
92 bool IsValidSystem(::SBS::SBS *sbs);
93 int RegisterEngine(EngineContext *engine);
94 EngineContext* GetFirstValidEngine();
95 int GetFreeInstanceNumber();
96 int Run(std::vector<EngineContext*> &newengine);
97 bool StartEngine(EngineContext* engine, std::vector<Ogre::Camera*> &cameras);
98 ::SBS::SBS* GetActiveSystem();
99 ScriptProcessor* GetActiveScriptProcessor();
100 bool Load(bool clear, const std::string &filename, EngineContext *parent = 0, const Vector3 &position = Vector3::ZERO, Real rotation = 0.0, const Vector3 &area_min = Vector3::ZERO, const Vector3 &area_max = Vector3::ZERO);
101 void ShowPlatform();
102 wxWindow* GetParent();
103 bool UpdateProgress();
104 bool ReportMissingFiles(std::vector<std::string> &missing_files);
105 void StartConsole();
106 void ProcessConsole();
107 VMConsole* GetConsole();
108 EngineContext* Initialize(bool clear, EngineContext *parent = 0, const Vector3 &position = Vector3::ZERO, Real rotation = 0.0, const Vector3 &area_min = Vector3::ZERO, const Vector3 &area_max = Vector3::ZERO);
109 void SetRenderOnStartup(bool value);
110 bool GetRenderOnStartup();
111 unsigned long Uptime();
112 unsigned long GetElapsedTime(int instance);
113 void ListPlayingSounds();
114
116 bool ConcurrentLoads; //set to true for buildings to be loaded while another sim is active and rendering
117 bool CheckScript; //if set to true, checks building scripts instead of fully loading them
118 bool Pause; //pause simulator
119 bool CutLandscape, CutBuildings, CutExternal, CutFloors;
120 bool Verbose; //verbose mode
122 bool loadstart; //true if starting an engine load
124 unsigned long time_stat, current_time; //frame timing
125
126 std::string version;
127 std::string version_rev;
128 std::string version_state;
129 std::string version_frontend;
130
131 std::string Bits;
132 std::string Platform;
133 std::string Architecture;
134 int macos_major; //macos major version
135 int macos_minor; //macos minor version
136
137 //additional path for user data
138 std::string data_path;
139
140private:
141
142 bool RunEngines(std::vector<EngineContext*> &newengines);
143 void CheckCamera();
144 void HandleEngineShutdown();
145 void HandleReload();
146 void SwitchEngines();
147 void Report(const std::string &message);
148 bool ReportError(const std::string &message);
149 bool ReportFatalError(const std::string &message);
150
152 std::vector<EngineContext*> engines;
153 HAL *hal; //hardware abstraction layer
155 GUI *gui; //GUI subsystem
156 VMConsole *vmconsole; //VM console system
157
158 wxWindow *parent;
159
161 bool RenderOnStartup; //override SBS engine setting with same name
162};
163
164}
165
166#endif
std::string version
Definition vm.h:126
std::string version_rev
Definition vm.h:127
bool showconsole
Definition vm.h:121
int GetEngineListSize()
Definition vm.h:87
int macos_major
Definition vm.h:134
bool CutBuildings
Definition vm.h:119
bool Verbose
Definition vm.h:120
int macos_minor
Definition vm.h:135
GUI * gui
Definition vm.h:155
bool unloaded
Definition vm.h:123
bool Pause
Definition vm.h:118
HAL * hal
Definition vm.h:153
std::string version_frontend
Definition vm.h:129
SkySystem * skysystem
Definition vm.h:154
bool first_run
Definition vm.h:160
std::string data_path
Definition vm.h:138
bool Shutdown
Definition vm.h:115
EngineContext * active_engine
Definition vm.h:151
bool ConcurrentLoads
Definition vm.h:116
std::string version_state
Definition vm.h:128
std::string Bits
Definition vm.h:131
std::string Architecture
Definition vm.h:133
std::string Platform
Definition vm.h:132
unsigned long current_time
Definition vm.h:124
bool CheckScript
Definition vm.h:117
VMConsole * vmconsole
Definition vm.h:156
bool RenderOnStartup
Definition vm.h:161
EngineContext * GetActiveEngine()
Definition vm.h:81
bool loadstart
Definition vm.h:122
wxWindow * parent
Definition vm.h:158
std::vector< EngineContext * > engines
Definition vm.h:152
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
#define VMIMPEXP
Definition vm.h:49