~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/main/Application.h

  • Committer: Package Import Robot
  • Author(s): Olek Wojnar, Stephen M. Webb, Olek Wojnar
  • Date: 2016-08-06 18:39:19 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20160806183919-4g72j3flj7xe2stj
Tags: 0.7.2+dfsg-1
[ Stephen M. Webb ]
* debian/control: updated build-depends to newer minimum versions
  (closes: #704786)
* debian/control: updated Standards-Version to 3.9.4 (updated VCS-* fields)
* debian/patches/0001-ember.in-test-expr.patch: removed (fixed upstream)
* debian/patches/0002-add-update_lua_bindings.patch: removed (fixed upstream)
* debian/patches/0003-add-atlas-pkg.patch: removed (fixed upstream)
* debian/patches/0004-domain-bindings-lua-makefile.patch: refreshed
* debian/patches/0005-ember.in-prefix.patch: removed (fixed upstream)
* debian/patches/0006-spellcheck-similiar.patch: removed (fixed upstream)
* debian/patches/0007-revert-libwfut-version.patch: refreshed
* debian/patches/0008-replace-fastdeletegate-with-sigc++.patch: removed
 (fixed upstream)
* debian/patches/0009-spelling-bach.patch: removed (fixed upstream)
* debian/patches/0010-fix-ember-script-args.patch: removed (fixed upstream)
* debian/patches/0011-qualify-template-functions.patch: removed (fixed
  upstream)
* debian/patches/0012-fix-osdir-headers.patch: removed (fixed upstream)
* debian/patches/0013-remove-invalid-linker-flags.patch: removed (fixed
  upstream)
* debian/patches/0014-add-missing-ogrelodstrategy.patch: new
* debian/control: fixed Vcs-Browser URL
* debian/patches/0015-verbose-configure-errors.patch: new
* debian/patches/0016-boost-1.53.patch: new
* debian/control: bump boost build dependeny to 1.53

[ Olek Wojnar ]
* New upstream release (Closes: #799748)
* Add myself as new uploader
  - Remove Stephen Webb per his request
  - Thanks for all the contributions, Stephen!
* d/patches/0007-revert-libwfut-version.patch: removed (unnecessary)
* d/control
  - Remove pre-dependency on dpkg
  - Update standards to 3.9.8 (no changes)
  - Update Vcs lines for secure URIs
* Import patch from the wfmath package to replace MersenneTwister.h
  -- Avoids problems from ambiguous copyright of the original file
* Update dependencies for version 0.7.2
* Enable all hardening options
* Add three lintian overrides
  -- Ignore install into usr/bin (binary)
  -- Ignore .rc files needed for WIN32 build (source)
  -- Ignore false positive of spelling error (binary)
* d/copyright: Update contributors and dates
* d/rules
  -- Do not remove "sounddefinitions" directory
  -- Enable parallel build
  -- Do not install into games directories
  -- Remove dh_builddeb override since xz is now the default
* d/watch: update file extensions
* Remove three patches, add eight patches, update remaining patches
  -- 0004-domain-bindings-lua-makefile.patch (implemented upstream)
  -- 0014-add-missing-ogrelodstrategy.patch (implemented upstream)
  -- 0016-boost-1.53.patch (patch target file removed upstream)
  -- 0018-enable-subdir-objects.patch (Fix automake 1.14 warnings)
  -- 0019-update-boost-m4.patch (Fix invalid boost_major_version)
  -- 0020-remove-obsolete-includes.patch (Fix obsolete includes)
  -- 0021-GraphicalChangeAdapter-fix-for-newer-compilers.patch (Added)
  -- 0022-fix-typos.patch (Fix typos identified by lintian)
  -- 0023-add-keywords-to-desktop-file.patch (Add Keywords to .desktop file)
  -- 0024-fix-icon-location (Make icon location Icon Theme Spec-compliant)
  -- 0025-fix-duplicate-script-install.patch (Was causing build failures)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#ifndef EMBER_APPLICATION_H
13
13
#define EMBER_APPLICATION_H
14
14
 
 
15
#include "services/EmberServices.h"
 
16
#include "framework/ConsoleObject.h"
 
17
#include "framework/ConsoleBackend.h"
 
18
#include "framework/MainLoopController.h"
 
19
 
 
20
#include <sigc++/signal.h>
 
21
#include <boost/date_time/posix_time/posix_time.hpp>
 
22
 
15
23
#include <list>
16
24
#include <string>
17
25
#include <fstream>
18
26
#include <map>
19
 
 
20
 
#include "services/EmberServices.h"
21
 
#include "framework/ConsoleObject.h"
22
 
#include "framework/ConsoleBackend.h"
23
 
 
24
 
 
25
 
#include <sigc++/signal.h>
26
 
 
 
27
#include <unordered_map>
 
28
#include <memory>
27
29
 
28
30
/**
29
31
 * @mainpage
30
32
 *
31
33
 * Ember is a client for the Worldforge virtual world system. It uses the 3d library <a href="http://www.ogre3d.org">OGRE</a> to show the world to the user, and the <a href="http://www.cegui.org.uk">CEGUI</a> library to present a user interface.
32
 
 * Two of the design tenants of Ember is to both be as modular as possible, and to reuse existing FOSS components as much as possible. The list of dependencies for the client is therefore quite hefty, but the advantage is the wealth of capabilities.
 
34
 * Two of the design tenets of Ember is to both be as modular as possible, and to reuse existing FOSS components as much as possible. The list of dependencies for the client is therefore quite hefty, but the advantage is the wealth of capabilities.
33
35
 *
34
36
 * @section SystemDesign System design
35
37
 *
41
43
 * - extensions
42
44
 *      Sometimes we need to extend the libraries used by Ember, such as Atlas or Eris. Any extension added should then be moved to the real library, but while it's either being developed it can be put in this layer.
43
45
 * - services
44
 
 *      Commonly used services are to be placed here. It might not always be clear what constitutes a service, but the most common characteristic of a service is an adapted API over an external component. A service should be light weight and not keep to much state.
 
46
 *      Commonly used services are to be placed here. It might not always be clear what constitutes a service, but the most common characteristic of a service is an adapted API over an external component. A service should be light weight and not keep to much state. The services should never depend on anything which is handled by the components (for example Ogre, CEGUI, Lua etc.).
45
47
 * - components
46
48
 *      The meat of the application is placed here. These are highly complex components which provide the main functionality of what is shown to the user.
47
49
 *      - carpenter
70
72
 
71
73
namespace Eris
72
74
{
73
 
        class View;
 
75
class View;
74
76
}
75
77
 
76
 
 
77
78
/**
78
79
 * @brief The main namespace for Ember.
79
80
 *
87
88
 */
88
89
namespace OgreView
89
90
{
90
 
        class EmberOgre;
 
91
class EmberOgre;
91
92
}
92
93
 
93
94
class EmberServices;
94
95
class LogObserver;
 
96
class IResourceProvider;
95
97
 
96
98
/**
97
99
 * @author Erik Hjortsberg <erik.hjortsberg@gmail.com>
107
109
 *
108
110
 * start();
109
111
 */
110
 
class Application : public ConsoleObject, public Singleton<Application>, public virtual sigc::trackable
 
112
class Application: public ConsoleObject, public Singleton<Application>, public virtual sigc::trackable
111
113
{
112
114
public:
113
 
        typedef std::map<std::string, std::map<std::string, std::string> > ConfigMap;
 
115
        typedef std::unordered_map<std::string, std::map<std::string, std::string>> ConfigMap;
114
116
 
115
117
        /**
116
118
         * @brief Ctor.
121
123
        Application(const std::string prefix, const std::string homeDir, const ConfigMap& configSettings);
122
124
 
123
125
        /**
124
 
        * @brief At destruction pretty much all game objects will be destroyed.
125
 
        */
 
126
         * @brief At destruction pretty much all game objects will be destroyed.
 
127
         */
126
128
        virtual ~Application();
127
129
 
128
130
        /**
129
 
        * @brief Performs one step of the main loop.
130
 
        * You only need to call this each "frame" if you're not using mainLoop().
131
 
        * @param minMillisecondsPerFrame If the fps is capped, this is the minimum milliseconds needed to spend on each frame.
132
 
        */
133
 
        void mainLoopStep(long minMillisecondsPerFrame);
 
131
         * @brief Performs one step of the main loop.
 
132
         * You only need to call this each "frame" if you're not using mainLoop().
 
133
         * @param minMicrosecondsPerFrame If the fps is capped, this is the minimum microseconds needed to spend on each frame.
 
134
         */
 
135
        void mainLoopStep(long minMicrosecondsPerFrame);
134
136
 
135
137
        /**
136
 
        * @brief Enters the main loop.
137
 
        * Will loop through the application until it exits. In most cases you want to call this for the main loop. However, if you want to handle all looping yourself you can call mainLoopStep() manually.
138
 
        */
 
138
         * @brief Enters the main loop.
 
139
         * Will loop through the application until it exits. In most cases you want to call this for the main loop. However, if you want to handle all looping yourself you can call mainLoopStep() manually.
 
140
         */
139
141
        void mainLoop();
140
142
 
141
143
        /**
142
 
        * @brief Return true if application has received an "exit" command else false.
143
 
        *
144
 
        * @return true if "shouldquit" else false
145
 
        */
146
 
        bool shouldQuit();
147
 
 
148
 
        /**
149
144
         * @brief Registers all components with the system.
150
145
         * Make sure to call this before calling prepareComponents(). This will allow all components to register themselves with the system, but won't do anything more.
151
146
         */
171
166
        void start();
172
167
 
173
168
        /**
174
 
        @brief Emitted when all services have been initialized.
175
 
        */
 
169
         @brief Emitted when all services have been initialized.
 
170
         */
176
171
        sigc::signal<void> EventServicesInitialized;
177
172
 
178
173
        /**
179
 
         * @brief Causes the application to quit.
180
 
         * This will instantly shut down the application, in contrast to requestQuit which will try to show a confirmation dialog to the user.
181
 
         */
182
 
        void quit();
183
 
 
184
 
        /**
185
174
         * @brief Callback for running Console Commands
186
175
         */
187
 
        void runCommand(const std::string& command,const std::string& args);
188
 
 
189
 
        /**
190
 
         * @brief Sets whether eris should be polled each frame. Defaults to true.
191
 
         * Normally Eris is polled each frame. A "poll" means that Eris is asked to send and receive any data from the server and act on it.
192
 
         * @param doPoll True if polling should occur each frame.
193
 
         */
194
 
        void setErisPolling(bool doPoll);
195
 
 
196
 
        /**
197
 
         * @brief Gets whether eris should be polled each frame.
198
 
         * @return True if polling occurs each frame.
199
 
         */
200
 
        bool getErisPolling() const;
201
 
 
202
 
        /**
203
 
         * @brief Emitted when the use wants to quit the game. Preferrebly the GUI should show some kind of confirmation window.
204
 
         */
205
 
        sigc::signal<void, bool&> EventRequestQuit;
206
 
 
207
 
        /**
208
 
         * @brief Emitted before the eris polling is started.
209
 
         * The parameter sent is the time slice since this event last was emitted.
210
 
         */
211
 
        sigc::signal<void, float> EventStartErisPoll;
212
 
 
213
 
        /**
214
 
         * @brief Emitted after the eris polling has finished.
215
 
         * The parameter sent is the time slice since this event last was emitted.
216
 
         */
217
 
        sigc::signal<void, float> EventEndErisPoll;
218
 
 
219
 
        /**
220
 
         * @brief Emitted before processing input. This event is emitted continously.
221
 
         * The parameter sent is the time slice since this event last was emitted.
222
 
         */
223
 
        sigc::signal<void, float> EventBeforeInputProcessing;
224
 
 
225
 
        /**
226
 
         * @brief Emitted after processing input. This event is emitted continously.
227
 
         * The parameter sent is the time slice since this event last was emitted.
228
 
         */
229
 
        sigc::signal<void, float> EventAfterInputProcessing;
230
 
 
231
 
        /**
232
 
         * @brief Call this to "soft quit" the app. This means that an signal will be emitted, which hopefully will be taken care of by some widget, which will show a confirmation window, asking the user if he/she wants to quit.
233
 
         * However, if there is no widget etc. handling the request, the application will instantly quit.
234
 
         */
235
 
        void requestQuit();
 
176
        void runCommand(const std::string& command, const std::string& args);
236
177
 
237
178
        /**
238
179
         * @brief Accessor for the main eris world view, if any.
241
182
 
242
183
private:
243
184
 
244
 
//      IGameView mGraphicalComponent;
245
185
        /**
246
186
         * @brief The main Ogre graphical view.
247
187
         */
254
194
        bool mShouldQuit;
255
195
 
256
196
        /**
 
197
         * @brief Controls whether eris should be polled at each frame update.
 
198
         */
 
199
        bool mPollEris;
 
200
 
 
201
        /**
 
202
         * @brief The main loop controller instance, which mainly controls whether the application should quit or not.
 
203
         */
 
204
        MainLoopController mMainLoopController;
 
205
 
 
206
        /**
257
207
         * @brief The file system prefix to where Ember has been installed.
258
208
         */
259
209
        const std::string mPrefix;
281
231
        Eris::View* mWorldView;
282
232
 
283
233
        /**
284
 
         * @brief Controls whether eris should be polled at each frame update.
285
 
         */
286
 
        bool mPollEris;
287
 
 
288
 
        /**
289
 
         * @brief Keeps track of the last time an Eris poll started.
290
 
         * Value is in milliseconds.
291
 
         */
292
 
        long long mLastTimeErisPollStart;
293
 
 
294
 
        /**
295
 
         * @brief Keeps track of the last time an Eris poll ended.
296
 
         * Value is in milliseconds.
297
 
         */
298
 
        long long mLastTimeErisPollEnd;
299
 
 
300
 
        /**
301
234
         * @brief Keeps track of the last time input processing started.
302
 
         * Value is in milliseconds.
303
235
         */
304
 
        long long mLastTimeInputProcessingStart;
 
236
        boost::posix_time::ptime mLastTimeInputProcessingStart;
305
237
 
306
238
        /**
307
239
         * @brief Keeps track of the last time input processing ended.
308
 
         * Value is in milliseconds.
309
240
         */
310
 
        long long mLastTimeInputProcessingEnd;
 
241
        boost::posix_time::ptime mLastTimeInputProcessingEnd;
311
242
 
312
243
        /**
313
244
         * @brief Keeps track of the last time the main loop step completed.
314
 
         * Value is in milliseconds.
315
 
         */
316
 
        long long mLastTimeMainLoopStepEnded;
317
 
 
318
 
        /**
319
 
         * @brief We listen to the GotView event to be able to store a reference to the View instance.
320
 
         * @see mWorldView
321
 
         * @param view The world view.
322
 
         */
323
 
        void Server_GotView(Eris::View* view);
324
 
 
325
 
        /**
326
 
         * @brief We listen to the DestroyedView event so that we can remove our View reference.
327
 
         */
328
 
        void Server_DestroyedView();
 
245
         */
 
246
        boost::posix_time::ptime mLastTimeMainLoopStepEnded;
329
247
 
330
248
        /**
331
249
         * @brief We hold a pointer to the stream to which all logging messages are written.
332
250
         */
333
 
        std::auto_ptr<std::ofstream> mLogOutStream;
 
251
        std::unique_ptr<std::ofstream> mLogOutStream;
334
252
 
335
253
        /**
336
254
         * @brief A transient copy of command line set config settings. The settings here will be injected into the ConfigService when the services are started.
341
259
        /**
342
260
         * @brief The main console backend instance.
343
261
         */
344
 
        std::auto_ptr<ConsoleBackend> mConsoleBackend;
 
262
        std::unique_ptr<ConsoleBackend> mConsoleBackend;
345
263
 
346
264
        /**
347
265
         * @brief The "quit" command will quit the application, bypassing any confirmation dialog.
352
270
         * @brief Toggles the polling of data from eris. Normally Eris is polled each frame, but this can be turned off (mainly for debug reasons).
353
271
         */
354
272
        const ConsoleCommandWrapper ToggleErisPolling;
 
273
 
 
274
        /**
 
275
         * @brief Provides resources to the scripting system.
 
276
         */
 
277
        IResourceProvider* mScriptingResourceProvider;
 
278
 
 
279
        /**
 
280
         * @brief We listen to the GotView event to be able to store a reference to the View instance.
 
281
         * @see mWorldView
 
282
         * @param view The world view.
 
283
         */
 
284
        void Server_GotView(Eris::View* view);
 
285
 
 
286
        /**
 
287
         * @brief We listen to the DestroyedView event so that we can remove our View reference.
 
288
         */
 
289
        void Server_DestroyedView();
 
290
 
 
291
        /**
 
292
         * @brief Starts the scripting system.
 
293
         */
 
294
        void startScripting();
 
295
 
355
296
};
356
297
}
357
298