1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /*! \addtogroup osclinit OSCL Init 19 * 20 * @{ 21 */ 22 23 24 25 /** \file oscl_init.h 26 \brief Global oscl initialization 27 */ 28 29 30 #ifndef OSCL_INIT_H_INCLUDED 31 #define OSCL_INIT_H_INCLUDED 32 33 #ifndef OSCL_BASE_H_INCLUDED 34 #include "oscl_base.h" 35 #endif 36 37 //For logging memory leaks, this module relies directly on fprintf to FILE. 38 #include <stdio.h> 39 40 class Oscl_DefAlloc; 41 42 /** 43 * Oscl Module selection and Init/Cleanup options. 44 */ 45 class OsclSelect 46 { 47 public: OsclSelect()48 OsclSelect() 49 : iOsclBase(true) 50 , iOsclMemory(true) 51 , iOsclErrorTrap(true) 52 , iOsclLogger(true) 53 , iOsclScheduler(true) 54 , iErrAlloc(NULL) 55 , iSchedulerAlloc(NULL) 56 , iSchedulerName(NULL) 57 , iSchedulerReserve(10) 58 , iHeapCheck(false) 59 , iOutputFile(NULL) 60 {} 61 62 //this constructor is mainly for back-compatibility with the old OsclInit argument list. 63 OsclSelect(Oscl_DefAlloc* erralloc 64 , Oscl_DefAlloc* schedalloc 65 , const char*name 66 , int32 reserve = 10 67 , bool heapcheck = false 68 , FILE* output = NULL) iOsclBase(true)69 : iOsclBase(true) 70 , iOsclMemory(true) 71 , iOsclErrorTrap(true) 72 , iOsclLogger(true) 73 , iOsclScheduler(true) 74 , iErrAlloc(erralloc) 75 , iSchedulerAlloc(schedalloc) 76 , iSchedulerName(name) 77 , iSchedulerReserve(reserve) 78 , iHeapCheck(heapcheck) 79 , iOutputFile(output) 80 {} 81 82 bool iOsclBase; //Init/Cleanup OsclBase? 83 bool iOsclMemory; //Init/Cleanup OsclMemory? 84 bool iOsclErrorTrap; //Init/Cleanup OsclErrorTrap? 85 bool iOsclLogger; //Init/Cleanup PVLogger? 86 bool iOsclScheduler; //Init/Cleanup OsclScheduler? 87 88 Oscl_DefAlloc *iErrAlloc; //Allocator for OsclErrorTrap::Init 89 Oscl_DefAlloc *iSchedulerAlloc; //Allocator for OsclScheduler::Init 90 const char *iSchedulerName; //Name for OsclScheduler::Init 91 int32 iSchedulerReserve; //Queue reserve for OsclScheduler::Init 92 93 bool iHeapCheck; //Do Symbian heap checks? 94 95 FILE* iOutputFile; //Output file for memory leak report. 96 }; 97 98 /** 99 * Per-thread oscl initialization and cleanup. 100 */ 101 class OsclInit 102 { 103 public: 104 /** 105 * This routine initializes the Oscl modules in the calling thread. 106 * 107 * @param err: (output) error code of any leave that occurs in 108 * initialization. 109 * 110 * @param config: (input param) optional set of initialization parameters. 111 * If null, then full initialization with default parameters will be performed. 112 * 113 */ 114 OSCL_IMPORT_REF static void Init( 115 int32& aError 116 , const OsclSelect *aSelect = NULL 117 ); 118 119 /** 120 * This routine cleans up the Oscl modules in the calling thread. 121 * 122 * @param err: (output) error code of any leave that occurs in 123 * initialization. 124 * @param config: (input param) optional set of initialization parameters. 125 * If null, then full initialization with default parameters will be performed. 126 * For proper cleanup, the parameters should match the ones used during 127 * the Init call. 128 * 129 */ 130 OSCL_IMPORT_REF static void Cleanup( 131 int32& aError 132 , const OsclSelect *aSelect = NULL 133 ); 134 }; 135 136 137 #endif 138 139 140 /*! @} */ 141