nuclear@3: /************************************************************************************ nuclear@3: nuclear@3: PublicHeader: OVR nuclear@3: Filename : OVR_System.h nuclear@3: Content : General kernel initialization/cleanup, including that nuclear@3: of the memory allocator. nuclear@3: Created : September 19, 2012 nuclear@3: Notes : nuclear@3: nuclear@3: Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. nuclear@3: nuclear@3: Use of this software is subject to the terms of the Oculus license nuclear@3: agreement provided at the time of installation or download, or which nuclear@3: otherwise accompanies this software in either electronic or hard copy form. nuclear@3: nuclear@3: ************************************************************************************/ nuclear@3: nuclear@3: #ifndef OVR_System_h nuclear@3: #define OVR_System_h nuclear@3: nuclear@3: #include "OVR_Allocator.h" nuclear@3: #include "OVR_Log.h" nuclear@3: nuclear@3: namespace OVR { nuclear@3: nuclear@3: // ***** System Core Initialization class nuclear@3: nuclear@3: // System initialization must take place before any other OVR_Kernel objects are used; nuclear@3: // this is done my calling System::Init(). Among other things, this is necessary to nuclear@3: // initialize the memory allocator. Similarly, System::Destroy must be nuclear@3: // called before program exist for proper cleanup. Both of these tasks can be achieved by nuclear@3: // simply creating System object first, allowing its constructor/destructor do the work. nuclear@3: nuclear@3: // TBD: Require additional System class for Oculus Rift API? nuclear@3: nuclear@3: class System nuclear@3: { nuclear@3: public: nuclear@3: nuclear@3: // System constructor expects allocator to be specified, if it is being substituted. nuclear@3: System(Log* log = Log::ConfigureDefaultLog(LogMask_Debug), nuclear@3: Allocator* palloc = DefaultAllocator::InitSystemSingleton()) nuclear@3: { nuclear@3: Init(log, palloc); nuclear@3: } nuclear@3: nuclear@3: ~System() nuclear@3: { nuclear@3: Destroy(); nuclear@3: } nuclear@3: nuclear@3: // Returns 'true' if system was properly initialized. nuclear@3: static bool OVR_CDECL IsInitialized(); nuclear@3: nuclear@3: // Initializes System core. Users can override memory implementation by passing nuclear@3: // a different Allocator here. nuclear@3: static void OVR_CDECL Init(Log* log = Log::ConfigureDefaultLog(LogMask_Debug), nuclear@3: Allocator *palloc = DefaultAllocator::InitSystemSingleton()); nuclear@3: nuclear@3: // De-initializes System more, finalizing the threading system and destroying nuclear@3: // the global memory allocator. nuclear@3: static void OVR_CDECL Destroy(); nuclear@3: }; nuclear@3: nuclear@3: } // OVR nuclear@3: nuclear@3: #endif