PageRenderTime 19ms CodeModel.GetById 6ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfeaturemanager.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 163 lines | 93 code | 37 blank | 33 comment | 0 complexity | 70784b4f671d2ebb48c7bfae3ad11dd9 MD5 | raw file
  1/** 
  2 * @file llfeaturemanager.h
  3 * @brief The feature manager is responsible for determining what features are turned on/off in the app.
  4 *
  5 * $LicenseInfo:firstyear=2003&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_LLFEATUREMANAGER_H
 28#define LL_LLFEATUREMANAGER_H
 29
 30#include "stdtypes.h"
 31
 32#include "llsingleton.h"
 33#include "llstring.h"
 34#include <map>
 35
 36typedef enum EGPUClass
 37{
 38	GPU_CLASS_UNKNOWN = -1,
 39	GPU_CLASS_0 = 0,
 40	GPU_CLASS_1 = 1,
 41	GPU_CLASS_2 = 2,
 42	GPU_CLASS_3 = 3
 43} EGPUClass; 
 44
 45
 46class LLFeatureInfo
 47{
 48public:
 49	LLFeatureInfo() : mValid(FALSE), mAvailable(FALSE), mRecommendedLevel(-1) {}
 50	LLFeatureInfo(const std::string& name, const BOOL available, const F32 level);
 51
 52	BOOL isValid() const	{ return mValid; };
 53
 54public:
 55	BOOL		mValid;
 56	std::string	mName;
 57	BOOL		mAvailable;
 58	F32			mRecommendedLevel;
 59};
 60
 61
 62class LLFeatureList
 63{
 64public:
 65	typedef std::map<std::string, LLFeatureInfo> feature_map_t;
 66
 67	LLFeatureList(const std::string& name);
 68	virtual ~LLFeatureList();
 69
 70	BOOL isFeatureAvailable(const std::string& name);
 71	F32 getRecommendedValue(const std::string& name);
 72
 73	void setFeatureAvailable(const std::string& name, const BOOL available);
 74	void setRecommendedLevel(const std::string& name, const F32 level);
 75
 76	BOOL loadFeatureList(LLFILE *fp);
 77
 78	BOOL maskList(LLFeatureList &mask);
 79
 80	void addFeature(const std::string& name, const BOOL available, const F32 level);
 81
 82	feature_map_t& getFeatures()
 83	{
 84		return mFeatures;
 85	}
 86
 87	void dump();
 88protected:
 89	std::string	mName;
 90	feature_map_t	mFeatures;
 91};
 92
 93
 94class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManager>
 95{
 96public:
 97	LLFeatureManager()
 98	:	LLFeatureList("default"),
 99
100		mInited(FALSE),
101		mTableVersion(0),
102		mSafe(FALSE),
103		mGPUClass(GPU_CLASS_UNKNOWN),
104		mGPUSupported(FALSE)
105	{
106	}
107	~LLFeatureManager() {cleanupFeatureTables();}
108
109	// initialize this by loading feature table and gpu table
110	void init();
111
112	void maskCurrentList(const std::string& name); // Mask the current feature list with the named list
113
114	BOOL loadFeatureTables();
115
116	EGPUClass getGPUClass() 			{ return mGPUClass; }
117	std::string& getGPUString() 		{ return mGPUString; }
118	BOOL isGPUSupported()				{ return mGPUSupported; }
119	
120	void cleanupFeatureTables();
121
122	S32 getVersion() const				{ return mTableVersion; }
123	void setSafe(const BOOL safe)		{ mSafe = safe; }
124	BOOL isSafe() const					{ return mSafe; }
125
126	LLFeatureList *findMask(const std::string& name);
127	BOOL maskFeatures(const std::string& name);
128
129	// set the graphics to low, medium, high, or ultra.
130	// skipFeatures forces skipping of mostly hardware settings
131	// that we don't want to change when we change graphics
132	// settings
133	void setGraphicsLevel(S32 level, bool skipFeatures);
134	
135	void applyBaseMasks();
136	void applyRecommendedSettings();
137
138	// apply the basic masks.  Also, skip one saved
139	// in the skip list if true
140	void applyFeatures(bool skipFeatures);
141
142	// load the dynamic GPU/feature table from a website
143	void fetchHTTPTables();
144	
145protected:
146	void loadGPUClass();
147	BOOL parseFeatureTable(std::string filename);
148	void parseGPUTable(std::string filename);
149	void initBaseMask();
150
151
152	std::map<std::string, LLFeatureList *> mMaskList;
153	std::set<std::string> mSkippedFeatures;
154	BOOL		mInited;
155	S32			mTableVersion;
156	BOOL		mSafe;					// Reinitialize everything to the "safe" mask
157	EGPUClass	mGPUClass;
158	std::string	mGPUString;
159	BOOL		mGPUSupported;
160};
161
162
163#endif // LL_LLFEATUREMANAGER_H