misystem.h

Go to the documentation of this file.
00001 /**
00002  * \file misystem.h <mi32/misystem.h>
00003  * \brief MISYSTEM class definition
00004  *
00005  * \if NODOC
00006  * $Id: misystem.h_v 1.16 2004/07/09 17:30:28 dwilliss Exp $
00007  *
00008  * $Log: misystem.h_v $
00009  * Revision 1.16  2004/07/09 17:30:28  dwilliss
00010  * Needed to forward declare FILEPATH
00011  *
00012  * Revision 1.15  2004/07/09 17:27:40  dwilliss
00013  * Added SetCurrentWorkingDirectory
00014  *
00015  * Revision 1.14  2004/04/13 17:23:34  mju
00016  * Change Win32_Old to Win32_PreNT.
00017  *
00018  * Revision 1.13  2004/04/13 16:49:41  dwilliss
00019  * Fixed platform enums so Win32_NT did not include the Win32_Old bit
00020  *
00021  * Revision 1.12  2003/12/22 21:01:06  dwilliss
00022  * Added static methods to get/set main app's HINSTANCE (Windows only)
00023  *
00024  * Revision 1.11  2003/10/09 13:37:20  mju
00025  * Add GetTimerValue.
00026  *
00027  * Revision 1.10  2003/10/08 14:53:17  mju
00028  * Add GetTicksPerSecond.
00029  *
00030  * Revision 1.9  2003/09/15 15:39:03  dwilliss
00031  * Mismatched #ifdef from doxygen cleanup
00032  *
00033  * Revision 1.8  2003/09/15 13:49:56  fileserver!dwilliss
00034  * Doxygen
00035  *
00036  * Revision 1.7  2003/07/09 13:59:56  mju
00037  * nc.
00038  *
00039  * Revision 1.6  2003/07/08 17:27:54  scowan
00040  * Undefine class lib export at the end of the module.
00041  *
00042  * Revision 1.5  2003/07/03 20:03:21  scowan
00043  * Moved get tick count to here.
00044  *
00045  * Revision 1.4  2003/07/03 16:36:12  scowan
00046  * Added translate system error method.
00047  *
00048  * Revision 1.3  2003/05/20 20:45:50  mju
00049  * Add methods to get total/available physical/virtual memory.
00050  *
00051  * Revision 1.2  2003/05/20 18:00:57  mju
00052  * Add PLATFORM enum and GetPlatform.
00053  * Add WindowsIsUnicode.
00054  * Add Supports64BitFileSystem.
00055  * Add Sleep.
00056  *
00057  * Revision 1.1  2003/05/19 15:38:11  mju
00058  * Initial revision
00059  * \endif
00060 **/
00061 
00062 #ifndef  INC_MI32_MISYSTEM_H
00063 #define  INC_MI32_MISYSTEM_H
00064 
00065 #ifndef  INC_MI32_STDDEFNS_H
00066 #include <mi32/stddefns.h>
00067 #endif
00068 
00069 #ifndef  INC_MI32_MISTRING_H
00070 #include <mi32/mistring.h>
00071 #endif
00072 
00073 #ifdef MISYSTEMDLL
00074    #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00075 #else
00076    #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00077 #endif
00078 
00079 class FILEPATH;
00080 
00081 //! Container for static methods to access various system and execution environment valuses.
00082 class CLASSLIBEXPORT MISYSTEM {
00083    public:
00084 
00085       enum PLATFORM {
00086          PLATFORM_Unknown =         0,
00087 
00088          PLATFORM_Win32_PreNT =     0x000100,
00089          PLATFORM_Win95 =           (PLATFORM_Win32_PreNT | 0x01),      //! Microsoft Windows 95
00090          PLATFORM_Win98 =           (PLATFORM_Win32_PreNT | 0x02),      //! Microsoft Windows 98
00091          PLATFORM_WinME =           (PLATFORM_Win32_PreNT | 0x03),      //! Microsoft Windows Me
00092 
00093          PLATFORM_Win32_NT =        0x001000,
00094          PLATFORM_WinNT =           (PLATFORM_Win32_NT | 0x01),      //! Microsoft Windows NT 4
00095          PLATFORM_Win2000 =         (PLATFORM_Win32_NT | 0x02),      //! Microsoft Windows 2000
00096          PLATFORM_WinXP =           (PLATFORM_Win32_NT | 0x03),      //! Microsoft Windows XP
00097 
00098          PLATFORM_Unix =            0x002000,
00099          PLATFORM_MacOSX =          (PLATFORM_Unix | 0x01),
00100          PLATFORM_LinuxX86 =        (PLATFORM_Unix | 0x02),
00101          PLATFORM_UnixSun =         (PLATFORM_Unix | 0x03),
00102          PLATFORM_UnixSGI =         (PLATFORM_Unix | 0x04),
00103          PLATFORM_UnixIBM =         (PLATFORM_Unix | 0x05),
00104          };
00105 
00106       //! Get current user name.
00107       //! @return MISTRING containing name, will be 'UnknownUser' if cannot determine name.
00108       static MISTRING GetCurrentUserName ();
00109 
00110       //! Get value of named environment variable.
00111       //! @return MISTRING containing value, will be empty if no matching environment variable.
00112       static MISTRING GetEnvironmentValue (
00113          const char *name                       //!< Environment variable name
00114          );
00115 
00116       //! Get amount of available physical memory.
00117       //! @return Number of bytes, -1 if unsupported, < -1 if error.
00118       static INT64 GetPhysicalMemoryAvailable ();
00119 
00120       //! Get amount of total physical memory.
00121       //! @return Number of bytes, -1 if unsupported, < -1 if error.
00122       static INT64 GetPhysicalMemoryTotal ();
00123 
00124       //! Get platform.
00125       static PLATFORM GetPlatform ();
00126       
00127       //! Returns a simple clock tick of unknown starting time. 
00128       static UINT32 GetTickCount ();
00129 
00130       //! Get number of clock ticks per second.
00131       static UINT32 GetTicksPerSecond ();
00132 
00133       //! Return 'timer' value.
00134       //! Precision of timer is system-dependent, ranging from 1ms and 100ns.
00135       //! @return Number of seconds from arbitrary starting time.
00136       static double GetTimerValue ();
00137 
00138       //! Get amount of available virtual memory.
00139       //! The return value may change if the OS supports dynamic page/swap file allocation.
00140       //! @return Number of bytes, -1 if unsupported, < -1 if error.
00141       static INT64 GetVirtualMemoryAvailable ();
00142 
00143       //! Get total amount of virtual memory.
00144       //! The return value may change if the OS supports dynamic page/swap file allocation.
00145       //! @return Number of bytes, -1 if unsupported, < -1 if error.
00146       static INT64 GetVirtualMemoryTotal ();
00147 
00148       //! Set the current working directory
00149       //! Note, to get the current working directory, construct a FILEPATH
00150       //! with FILEPATH::PATHTYPE_Current.
00151       static ERRVALUE SetCurrentWorkingDirectory (
00152          const FILEPATH& filepath
00153          );
00154 
00155       //! Delay for specified time.
00156       static void Sleep (
00157          double delay                           //!< Time to delay in seconds
00158          );
00159 
00160       //! Determine if system supports 64-bit filesystems.
00161       static bool Supports64BitFileSystem ();
00162 
00163       //! Translate OS error code to MicroImages error code
00164       //! Does NOT do a SetErrPosn() on the error code, that is up to the caller
00165       static ERRVALUE TranslateSystemError (
00166          ERRVALUE DftErrCode,             //!< Default error code to use if system error not specifically handled
00167          INT32& SystemError               //!< Operating sytem error RETURNED
00168          );
00169 
00170    #ifdef WIN32
00171       //! Determine if Windows supports Unicode (Windows only).
00172       //! This may be used to determine if the 'wide character' versions of APIs may be used.
00173       //! @return true if supported, false if not.
00174       static bool WindowsIsUnicode ();
00175 
00176 
00177       //! Get the HINSTANCE of the application (Windows only)
00178       //! Sorry, you'll have to cast the return value to an HINSTANCE.
00179       //! this include file does not define any Windows types, nor should it.
00180       static void* GetMainHINSTANCE();
00181 
00182       //! Set the HINSTANCE of the application (Windows only)
00183       static void SetMainHINSTANCE(void*);
00184    #endif
00185 
00186    private:
00187       #ifndef GENERATING_DOXYGEN_OUTPUT
00188       MISYSTEM ();            //! Unimplemented
00189       #endif //!< GENERATING_DOXYGEN_OUTPUT
00190    };
00191 
00192 #undef   CLASSLIBEXPORT
00193 
00194 #endif   //!< INC_MI32_MISYSTEM_H

Generated on Tue Dec 14 13:18:29 2004 for TNTsdk by  doxygen 1.3.8-20040913