Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
ProcessID.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_ProcessID_h_ 00003 #define INCLUDED_ProcessID_h_ 00004 00005 #ifdef PLATFORM_APERIOS 00006 # include "Shared/StackTrace.h" 00007 #endif 00008 00009 //! holds information to identify currently running process 00010 /*! 00011 * Although the ProcessID_t enum specifies the maximum number of processes 00012 * in its NumProcesses value, this doesn't have to correspond to the actual 00013 * number of active processes. If you want an element of dynamicism to launch 00014 * and/or close processes at runtime, simply increase the NumProcesses to a 00015 * higher value so that space can be allocated for those processes in shared 00016 * memory regions for things like attachment pointers or other per-process 00017 * data. 00018 * 00019 * Not all processes need to have a *named* id, they just need a unique id. 00020 */ 00021 namespace ProcessID { 00022 //! Holds ID number for each process 00023 enum ProcessID_t { 00024 MainProcess, //!< MainObj process 00025 MotionProcess, //!< MotoObj process 00026 SoundProcess, //!< SoundPlay process 00027 #ifndef PLATFORM_APERIOS 00028 SimulatorProcess, //!< for interaction with OS and managing global environment 00029 #endif 00030 NumProcesses //!< maximum number of 'friendly' processes -- see class docs 00031 }; 00032 00033 ProcessID_t getID(); //!< returns process's ID number, subject to overriding via setIDHooks() 00034 void setID(ProcessID_t id); //!< sets the ID during init (be careful you know what you're doing if you call this), subject to overriding via setIDHooks() 00035 00036 #ifndef PLATFORM_APERIOS 00037 //! allows you to override the behavior of getID and setID -- pass NULL to use default behavior 00038 void setIDHooks(ProcessID_t (*customGetID)(), void (*customSetID)(ProcessID_t id)); 00039 00040 //! returns process's ID number from static global, the default behavior if setIDHooks was passed NULL 00041 ProcessID_t getUnhookedID(); 00042 00043 //! sets the ID into static global (be careful you know what you're doing if you call this), this is the default behavior if setIDHooks was passed NULL 00044 void setUnhookedID(ProcessID_t id); 00045 #endif 00046 00047 //! returns a string version of the name of the process 00048 inline const char* getIDStr() { 00049 switch(getID()) { 00050 case MainProcess: return "Main"; 00051 case MotionProcess: return "Motion"; 00052 case SoundProcess: return "Sound"; 00053 #ifndef PLATFORM_APERIOS 00054 case SimulatorProcess: return "Simulator"; 00055 #endif 00056 default: return "Invalid Process"; 00057 } 00058 } 00059 00060 #ifdef PLATFORM_APERIOS 00061 //! sets location of shared memory map from IDs to current entry point, this is required to be set up before any entry()'s 00062 /*! @param idmap array of StackFrame structures, one per #NumProcesses 00063 * the idea is to have idmap stored in a shared memory region, so functions can tell which one they belong to */ 00064 void setMap(stacktrace::StackFrame idmap[]); 00065 00066 //! returns the stack frame which should be set to the entry point of the current function 00067 /*! this is only valid if it is called before any shared object processing is done */ 00068 stacktrace::StackFrame* getMapFrame(); 00069 #endif 00070 } 00071 00072 /*! @file 00073 * @brief Defines ProcessID - simple little global for checking which process is currently running, kind of. (see ProcessID::getID() ) 00074 * @author ejt (Creator) 00075 * 00076 * $Author: ejt $ 00077 * $Name: tekkotsu-4_0 $ 00078 * $Revision: 1.8 $ 00079 * $State: Exp $ 00080 * $Date: 2007/11/09 19:01:18 $ 00081 */ 00082 00083 #endif |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4 |