/usr/include/OGRE/OgreRenderSystemCapabilitiesSerializer.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __RenderSystemCapabilitiesSerializer_H__
#define __RenderSystemCapabilitiesSerializer_H__
#include "OgrePrerequisites.h"
#include "OgreRenderSystemCapabilities.h"
#include "OgreStringVector.h"
#include "OgreDataStream.h"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup RenderSystem
* @{
*/
/** Class for serializing RenderSystemCapabilities to / from a .rendercaps script.*/
class _OgreExport RenderSystemCapabilitiesSerializer : public RenderSysAlloc
{
public:
/** default constructor*/
RenderSystemCapabilitiesSerializer();
/** default destructor*/
virtual ~RenderSystemCapabilitiesSerializer() {}
/** Writes a RenderSystemCapabilities object to a data stream */
void writeScript(const RenderSystemCapabilities* caps, String name, String filename);
/** Parses a RenderSystemCapabilities script file passed as a stream.
Adds it to RenderSystemCapabilitiesManager::_addRenderSystemCapabilities
*/
void parseScript(DataStreamPtr& stream);
protected:
enum CapabilityKeywordType {UNDEFINED_CAPABILITY_TYPE = 0, SET_STRING_METHOD, SET_INT_METHOD, SET_BOOL_METHOD, SET_REAL_METHOD,
SET_CAPABILITY_ENUM_BOOL, ADD_SHADER_PROFILE_STRING};
// determines what keyword is what type of capability. For example:
// "automipmap" and "pbuffer" are both activated with setCapability (passing RSC_AUTOMIPMAP and RSC_PBUFFER respectivelly)
// while "max_num_multi_render_targets" is an integer and has it's own method: setMaxMultiNumRenderTargets
// we need to know these types to automatically parse each capability
typedef map<String, CapabilityKeywordType>::type KeywordTypeMap;
KeywordTypeMap mKeywordTypeMap;
typedef void (RenderSystemCapabilities::*SetStringMethod)(const String&);
// maps capability keywords to setCapability(String& cap) style methods
typedef map<String, SetStringMethod>::type SetStringMethodDispatchTable;
SetStringMethodDispatchTable mSetStringMethodDispatchTable;
// SET_INT_METHOD parsing tables
typedef void (RenderSystemCapabilities::*SetIntMethod)(ushort);
typedef map<String, SetIntMethod>::type SetIntMethodDispatchTable;
SetIntMethodDispatchTable mSetIntMethodDispatchTable;
// SET_BOOL_METHOD parsing tables
typedef void (RenderSystemCapabilities::*SetBoolMethod)(bool);
typedef map<String, SetBoolMethod>::type SetBoolMethodDispatchTable;
SetBoolMethodDispatchTable mSetBoolMethodDispatchTable;
// SET_REAL_METHOD parsing tables
typedef void (RenderSystemCapabilities::*SetRealMethod)(Real);
typedef map<String, SetRealMethod>::type SetRealMethodDispatchTable;
SetRealMethodDispatchTable mSetRealMethodDispatchTable;
typedef map<String, Capabilities>::type CapabilitiesMap;
CapabilitiesMap mCapabilitiesMap;
inline void addCapabilitiesMapping(String name, Capabilities cap)
{
mCapabilitiesMap.insert(CapabilitiesMap::value_type(name, cap));
}
// capabilities lines for parsing are collected along with their line numbers for debugging
typedef vector<std::pair<String, int> >::type CapabilitiesLinesList;
// the set of states that the parser can be in
enum ParseAction {PARSE_HEADER, FIND_OPEN_BRACE, COLLECT_LINES};
int mCurrentLineNumber;
String* mCurrentLine;
DataStreamPtr mCurrentStream;
RenderSystemCapabilities* mCurrentCapabilities;
inline void addKeywordType(String keyword, CapabilityKeywordType type)
{
mKeywordTypeMap.insert(KeywordTypeMap::value_type(keyword, type));
}
inline CapabilityKeywordType getKeywordType(const String& keyword) const
{
KeywordTypeMap::const_iterator it = mKeywordTypeMap.find(keyword);
if(it != mKeywordTypeMap.end())
return (*it).second;
else
{
logParseError("Can't find the type for keyword: " + keyword);
return UNDEFINED_CAPABILITY_TYPE;
}
}
inline void addSetStringMethod(String keyword, SetStringMethod method)
{
mSetStringMethodDispatchTable.insert(SetStringMethodDispatchTable::value_type(keyword, method));
}
inline void callSetStringMethod(String& keyword, String& val)
{
SetStringMethodDispatchTable::iterator methodIter = mSetStringMethodDispatchTable.find(keyword);
if (methodIter != mSetStringMethodDispatchTable.end())
{
SetStringMethod m = (*methodIter).second;
(mCurrentCapabilities->*m)(val);
}
else
{
logParseError("undefined keyword: " + keyword);
}
}
inline void addSetIntMethod(String keyword, SetIntMethod method)
{
mSetIntMethodDispatchTable.insert(SetIntMethodDispatchTable::value_type(keyword, method));
}
inline void callSetIntMethod(String& keyword, ushort val)
{
SetIntMethodDispatchTable::iterator methodIter = mSetIntMethodDispatchTable.find(keyword);
if (methodIter != mSetIntMethodDispatchTable.end())
{
SetIntMethod m = (*methodIter).second;
(mCurrentCapabilities->*m)(val);
}
else
{
logParseError("undefined keyword: " + keyword);
}
}
inline void addSetBoolMethod(String keyword, SetBoolMethod method)
{
mSetBoolMethodDispatchTable.insert(SetBoolMethodDispatchTable::value_type(keyword, method));
}
inline void callSetBoolMethod(String& keyword, bool val)
{
SetBoolMethodDispatchTable::iterator methodIter = mSetBoolMethodDispatchTable.find(keyword);
if (methodIter != mSetBoolMethodDispatchTable.end())
{
SetBoolMethod m = (*methodIter).second;
(mCurrentCapabilities->*m)(val);
}
else
{
logParseError("undefined keyword: " + keyword);
}
}
inline void addSetRealMethod(String keyword, SetRealMethod method)
{
mSetRealMethodDispatchTable.insert(SetRealMethodDispatchTable::value_type(keyword, method));
}
inline void callSetRealMethod(String& keyword, Real val)
{
SetRealMethodDispatchTable::iterator methodIter = mSetRealMethodDispatchTable.find(keyword);
if (methodIter != mSetRealMethodDispatchTable.end())
{
SetRealMethod m = (*methodIter).second;
(mCurrentCapabilities->*m)(val);
}
else
{
logParseError("undefined keyword: " + keyword);
}
}
inline void addShaderProfile(String& val)
{
mCurrentCapabilities->addShaderProfile(val);
}
inline void setCapabilityEnumBool(String& name, bool val)
{
// check for errors
if(mCapabilitiesMap.find(name) == mCapabilitiesMap.end())
{
logParseError("Undefined capability: " + name);
return;
}
// only set true capabilities, we can't unset false
if(val)
{
Capabilities cap = mCapabilitiesMap[name];
mCurrentCapabilities->setCapability(cap);
}
}
void initialiaseDispatchTables();
void parseCapabilitiesLines(CapabilitiesLinesList& linesList);
void logParseError(const String& error) const;
};
/** @} */
/** @} */
}
#endif
|