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 int GetGlobalStats(int &meshes, int &textures, int &actions, int &sounds, int &objects, int &walls, int &polygons);
115
117 bool ConcurrentLoads; //set to true for buildings to be loaded while another sim is active and rendering
118 bool CheckScript; //if set to true, checks building scripts instead of fully loading them
119 bool Pause; //pause simulator
120 bool CutLandscape, CutBuildings, CutExternal, CutFloors;
121 bool Verbose; //verbose mode
123 bool loadstart; //true if starting an engine load
125 unsigned long time_stat, current_time; //frame timing
126
127 std::string version;
128 std::string version_rev;
129 std::string version_state;
130 std::string version_full;
131
132 std::string Bits;
133 std::string Platform;
134 std::string Architecture;
135 int macos_major; //macos major version
136 int macos_minor; //macos minor version
137
138 //additional path for user data
139 std::string data_path;
140
141private:
142
143 bool RunEngines(std::vector<EngineContext*> &newengines);
144 void CheckCamera();
145 void HandleEngineShutdown();
146 void HandleReload();
147 void SwitchEngines();
148 void Report(const std::string &message);
149 bool ReportError(const std::string &message);
150 bool ReportFatalError(const std::string &message);
151
153 std::vector<EngineContext*> engines;
154 HAL *hal; //hardware abstraction layer
156 GUI *gui; //GUI subsystem
157 VMConsole *vmconsole; //VM console system
158
159 wxWindow *parent;
160
162 bool RenderOnStartup; //override SBS engine setting with same name
163};
164
165}
166
167#endif
std::string version
Definition vm.h:127
std::string version_rev
Definition vm.h:128
bool showconsole
Definition vm.h:122
int GetEngineListSize()
Definition vm.h:87
int macos_major
Definition vm.h:135
bool CutBuildings
Definition vm.h:120
bool Verbose
Definition vm.h:121
int macos_minor
Definition vm.h:136
GUI * gui
Definition vm.h:156
bool unloaded
Definition vm.h:124
bool Pause
Definition vm.h:119
HAL * hal
Definition vm.h:154
SkySystem * skysystem
Definition vm.h:155
bool first_run
Definition vm.h:161
std::string data_path
Definition vm.h:139
bool Shutdown
Definition vm.h:116
EngineContext * active_engine
Definition vm.h:152
bool ConcurrentLoads
Definition vm.h:117
std::string version_state
Definition vm.h:129
std::string Bits
Definition vm.h:132
std::string Architecture
Definition vm.h:134
std::string Platform
Definition vm.h:133
unsigned long current_time
Definition vm.h:125
bool CheckScript
Definition vm.h:118
VMConsole * vmconsole
Definition vm.h:157
bool RenderOnStartup
Definition vm.h:162
EngineContext * GetActiveEngine()
Definition vm.h:81
bool loadstart
Definition vm.h:123
wxWindow * parent
Definition vm.h:159
std::vector< EngineContext * > engines
Definition vm.h:153
std::string version_full
Definition vm.h:130
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
#define VMIMPEXP
Definition vm.h:49