Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ProcessID.h

Go 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
00034   void setID(ProcessID_t id); //!< sets the ID during init (be careful you know what you're doing if you call this)
00035 
00036   //! returns a string version of the name of the process
00037   inline const char* getIDStr() {
00038     switch(getID()) {
00039       case MainProcess: return "Main";
00040       case MotionProcess: return "Motion";
00041       case SoundProcess: return "Sound";
00042 #ifndef PLATFORM_APERIOS
00043       case SimulatorProcess: return "Simulator";
00044 #endif
00045       default: return "Invalid Process";
00046     }
00047   }
00048   
00049 #ifdef PLATFORM_APERIOS
00050   //! sets location of shared memory map from IDs to current entry point, this is required to be set up before any entry()'s
00051   /*! @param idmap array of StackFrame structures, one per #NumProcesses
00052    *  the idea is to have idmap stored in a shared memory region, so functions can tell which one they belong to */
00053   void setMap(stacktrace::StackFrame idmap[]);
00054   
00055   //! returns the stack frame which should be set to the entry point of the current function
00056   /*! this is only valid if it is called before any shared object processing is done */
00057   stacktrace::StackFrame* getMapFrame();
00058 #endif
00059 }
00060 
00061 /*! @file
00062  * @brief Defines ProcessID - simple little global for checking which process is currently running, kind of. (see ProcessID::getID() )
00063  * @author ejt (Creator)
00064  *
00065  * $Author: ejt $
00066  * $Name: tekkotsu-3_0 $
00067  * $Revision: 1.6 $
00068  * $State: Exp $
00069  * $Date: 2006/08/22 22:23:03 $
00070  */
00071 
00072 #endif

Tekkotsu v3.0
Generated Wed Oct 4 00:03:45 2006 by Doxygen 1.4.7