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