PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/llsys.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 156 lines | 64 code | 29 blank | 63 comment | 0 complexity | d7e32751ed4d837106a07e7b7560eefc MD5 | raw file
  1/** 
  2 * @file llsys.h
  3 * @brief System information debugging classes.
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_SYS_H
 28#define LL_SYS_H
 29
 30//
 31// The LLOSInfo, LLCPUInfo, and LLMemoryInfo classes are essentially
 32// the same, but query different machine subsystems. Here's how you
 33// use an LLCPUInfo object:
 34//
 35//  LLCPUInfo info;
 36//  llinfos << info << llendl;
 37//
 38
 39#include "llsd.h"
 40#include <iosfwd>
 41#include <string>
 42
 43class LL_COMMON_API LLOSInfo
 44{
 45public:
 46	LLOSInfo();
 47	void stream(std::ostream& s) const;
 48
 49	const std::string& getOSString() const;
 50	const std::string& getOSStringSimple() const;
 51
 52	S32 mMajorVer;
 53	S32 mMinorVer;
 54	S32 mBuild;
 55
 56#ifndef LL_WINDOWS
 57	static S32 getMaxOpenFiles();
 58#endif
 59
 60	static U32 getProcessVirtualSizeKB();
 61	static U32 getProcessResidentSizeKB();
 62private:
 63	std::string mOSString;
 64	std::string mOSStringSimple;
 65};
 66
 67
 68class LL_COMMON_API LLCPUInfo
 69{
 70public:
 71	LLCPUInfo();	
 72	void stream(std::ostream& s) const;
 73
 74	std::string getCPUString() const;
 75
 76	bool hasAltivec() const;
 77	bool hasSSE() const;
 78	bool hasSSE2() const;
 79	F64 getMHz() const;
 80
 81	// Family is "AMD Duron" or "Intel Pentium Pro"
 82	const std::string& getFamily() const { return mFamily; }
 83
 84private:
 85	bool mHasSSE;
 86	bool mHasSSE2;
 87	bool mHasAltivec;
 88	F64 mCPUMHz;
 89	std::string mFamily;
 90	std::string mCPUString;
 91};
 92
 93//=============================================================================
 94//
 95//	CLASS		LLMemoryInfo
 96
 97class LL_COMMON_API LLMemoryInfo
 98
 99/*!	@brief		Class to query the memory subsystem
100
101	@details
102		Here's how you use an LLMemoryInfo:
103		
104		LLMemoryInfo info;
105<br>	llinfos << info << llendl;
106*/
107{
108public:
109	LLMemoryInfo(); ///< Default constructor
110	void stream(std::ostream& s) const;	///< output text info to s
111
112	U32 getPhysicalMemoryKB() const; ///< Memory size in KiloBytes
113	
114	/*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will
115	**  be returned.
116	*/
117	U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
118
119	//get the available memory infomation in KiloBytes.
120	static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb);
121
122	// Retrieve a map of memory statistics. The keys of the map are platform-
123	// dependent. The values are in kilobytes to try to avoid integer overflow.
124	LLSD getStatsMap() const;
125
126	// Re-fetch memory data (as reported by stream() and getStatsMap()) from the
127	// system. Normally this is fetched at construction time. Return (*this)
128	// to permit usage of the form:
129	// @code
130	// LLMemoryInfo info;
131	// ...
132	// info.refresh().getStatsMap();
133	// @endcode
134	LLMemoryInfo& refresh();
135
136private:
137	// set mStatsMap
138	static LLSD loadStatsMap();
139
140	// Memory stats for getStatsMap().
141	LLSD mStatsMap;
142};
143
144
145LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLOSInfo& info);
146LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLCPUInfo& info);
147LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info);
148
149// gunzip srcfile into dstfile.  Returns FALSE on error.
150BOOL LL_COMMON_API gunzip_file(const std::string& srcfile, const std::string& dstfile);
151// gzip srcfile into dstfile.  Returns FALSE on error.
152BOOL LL_COMMON_API gzip_file(const std::string& srcfile, const std::string& dstfile);
153
154extern LL_COMMON_API LLCPUInfo gSysCPU;
155
156#endif // LL_LLSYS_H