System.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_System_hxx
00024 #define __ccxx_System_hxx
00025
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/Mutex.h++>
00028 #include <commonc++/String.h++>
00029 #include <commonc++/SystemException.h++>
00030
00031 #include <time.h>
00032 #include <memory>
00033
00034 namespace ccxx {
00035
00041 class COMMONCPP_API System
00042 {
00043 public:
00044
00046 static time_s_t currentTime() throw();
00047
00049 static time_ms_t currentTimeMillis() throw();
00050
00057 static void setSystemTime(const time_ms_t &time) throw(SystemException);
00058
00065 static String getEnvVariable(const String &name);
00066
00073 static bool setEnvVariable(const String &name, const String &value)
00074 throw();
00075
00081 static bool delEnvVariable(const String &name) throw();
00082
00084 static String getUserName();
00085
00087 static String getOSName();
00088
00090 static String getOSVersion();
00091
00093 static String getArchitecture();
00094
00096 static String getHostName();
00097
00099 static String getHomeDir();
00100
00102 static String getTempDir();
00103
00106 static inline void lockGlobalMutex() throw()
00107 { _globalLock.lock(); }
00108
00109 static inline void unlockGlobalMutex() throw()
00110 { _globalLock.unlock(); }
00111
00119 static String getErrorString(const String &text = String::null);
00120
00122 static size_t getPageSize() throw();
00123
00125 static void roundToPageSize(size_t& size) throw();
00126
00128 static void printStackTrace(uint_t maxFrames = 20);
00129
00131 static bool isPOSIX() throw();
00132
00134 static bool isMacOSX() throw();
00135
00137 static bool isWindows() throw();
00138
00139 private:
00140
00141 static void _getSystemInfo() throw();
00142 static Mutex _globalLock;
00143
00144 static String _username;
00145 static String _osname;
00146 static String _osver;
00147 static String _arch;
00148 static String _hostname;
00149 static String _homedir;
00150 static String _tempdir;
00151 static bool _inited;
00152
00153 CCXX_COPY_DECLS(System);
00154 };
00155
00156 };
00157
00158 #endif // __ccxx_System_hxx
00159
00160