System.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 }; // namespace ccxx
00157 
00158 #endif // __ccxx_System_hxx
00159 
00160 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3