rev |
line source |
nuclear@1
|
1 /************************************************************************************
|
nuclear@1
|
2
|
nuclear@1
|
3 PublicHeader: OVR
|
nuclear@1
|
4 Filename : OVR_System.h
|
nuclear@1
|
5 Content : General kernel initialization/cleanup, including that
|
nuclear@1
|
6 of the memory allocator.
|
nuclear@1
|
7 Created : September 19, 2012
|
nuclear@1
|
8 Notes :
|
nuclear@1
|
9
|
nuclear@1
|
10 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
|
nuclear@1
|
11
|
nuclear@1
|
12 Use of this software is subject to the terms of the Oculus license
|
nuclear@1
|
13 agreement provided at the time of installation or download, or which
|
nuclear@1
|
14 otherwise accompanies this software in either electronic or hard copy form.
|
nuclear@1
|
15
|
nuclear@1
|
16 ************************************************************************************/
|
nuclear@1
|
17
|
nuclear@1
|
18 #ifndef OVR_System_h
|
nuclear@1
|
19 #define OVR_System_h
|
nuclear@1
|
20
|
nuclear@1
|
21 #include "OVR_Allocator.h"
|
nuclear@1
|
22 #include "OVR_Log.h"
|
nuclear@1
|
23
|
nuclear@1
|
24 namespace OVR {
|
nuclear@1
|
25
|
nuclear@1
|
26 // ***** System Core Initialization class
|
nuclear@1
|
27
|
nuclear@1
|
28 // System initialization must take place before any other OVR_Kernel objects are used;
|
nuclear@1
|
29 // this is done my calling System::Init(). Among other things, this is necessary to
|
nuclear@1
|
30 // initialize the memory allocator. Similarly, System::Destroy must be
|
nuclear@1
|
31 // called before program exist for proper cleanup. Both of these tasks can be achieved by
|
nuclear@1
|
32 // simply creating System object first, allowing its constructor/destructor do the work.
|
nuclear@1
|
33
|
nuclear@1
|
34 // TBD: Require additional System class for Oculus Rift API?
|
nuclear@1
|
35
|
nuclear@1
|
36 class System
|
nuclear@1
|
37 {
|
nuclear@1
|
38 public:
|
nuclear@1
|
39
|
nuclear@1
|
40 // System constructor expects allocator to be specified, if it is being substituted.
|
nuclear@1
|
41 System(Log* log = Log::ConfigureDefaultLog(LogMask_Debug),
|
nuclear@1
|
42 Allocator* palloc = DefaultAllocator::InitSystemSingleton())
|
nuclear@1
|
43 {
|
nuclear@1
|
44 Init(log, palloc);
|
nuclear@1
|
45 }
|
nuclear@1
|
46
|
nuclear@1
|
47 ~System()
|
nuclear@1
|
48 {
|
nuclear@1
|
49 Destroy();
|
nuclear@1
|
50 }
|
nuclear@1
|
51
|
nuclear@1
|
52 // Returns 'true' if system was properly initialized.
|
nuclear@1
|
53 static bool OVR_CDECL IsInitialized();
|
nuclear@1
|
54
|
nuclear@1
|
55 // Initializes System core. Users can override memory implementation by passing
|
nuclear@1
|
56 // a different Allocator here.
|
nuclear@1
|
57 static void OVR_CDECL Init(Log* log = Log::ConfigureDefaultLog(LogMask_Debug),
|
nuclear@1
|
58 Allocator *palloc = DefaultAllocator::InitSystemSingleton());
|
nuclear@1
|
59
|
nuclear@1
|
60 // De-initializes System more, finalizing the threading system and destroying
|
nuclear@1
|
61 // the global memory allocator.
|
nuclear@1
|
62 static void OVR_CDECL Destroy();
|
nuclear@1
|
63 };
|
nuclear@1
|
64
|
nuclear@1
|
65 } // OVR
|
nuclear@1
|
66
|
nuclear@1
|
67 #endif
|