JNR
laEnvironment.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
30 #ifndef M_ENVIRONMENT_H
31 #define M_ENVIRONMENT_H
32 
34 
35 
37 //
39 
40 class laThread{
41 public:
43  virtual void run() = 0;
44 };
45 
47 //
49 
51 {
52 protected:
54  char _strOS[128];
55 
57  virtual void create()=0;
58 
60  void printWelcome();
61 
63  class laTimer* _pTimer;
64 
66  friend class laSystemIntegrator;
67 
68 public:
69  laEnvironment(char* strOS);
70  ~laEnvironment(void);
71 
72  // Control methods
73  // TODO: loop and discard should be protected
74  //
75  virtual int loop()=0;
76  virtual void discard()=0;
77 
79  virtual void terminate()=0;
80 
82  char* getOSName(){return _strOS; }
83 
85  laTimer* getTimer() { return _pTimer; }
86 
88 
89  virtual void thread( laThread *pThread ) =0;
90  virtual void wait(unsigned long nMSec)=0;
91 
92 
94 
95  virtual void getTitle(char* str)=0;
96  virtual void setTitle(char* str)=0;
98 
100 
101  virtual void message(M_BOOL bSilent, const char* strText, ...)=0;
102  virtual void mlog(char* location, const char* strText, ...)=0;
103 
104 };
106 #endif
laTimer * getTimer()
Get inegrated timer.
Definition: laEnvironment.h:85
virtual void thread(laThread *pThread)=0
Create new thread object.
virtual void terminate()=0
Terminate application.
virtual void message(M_BOOL bSilent, const char *strText,...)=0
Display message box.
virtual void create()=0
Create OS environment.
laEnvironment(char *strOS)
Constructor only sets OS name, and specific work is in children.
void printWelcome()
Print initial message to the log file.
virtual void mlog(char *location, const char *strText,...)=0
Print message to the log file.
class laTimer * _pTimer
Timer integrated in the OS message loop and used throughout the system.
Definition: laEnvironment.h:63
char _strOS[128]
Text identifier of the actual operating system.
Definition: laEnvironment.h:54
virtual void wait(unsigned long nMSec)=0
Suspend current thread.
char * getOSName()
Get OS name.
Definition: laEnvironment.h:82
Engine Sub-systems Integrator.
virtual void run()=0
Virtual execution function can be defined by children.
Engine abstract OS environment.
Definition: laEnvironment.h:50
Engine multi-threading class.
Definition: laEnvironment.h:40