Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   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 _CORE_PARAM_HANDLER_INL_
#define _CORE_PARAM_HANDLER_INL_

namespace Divide {

inline void ParamHandler::setDebugOutput(bool logState) {
    _logState = logState;
}

template <typename T>
inline bool ParamHandler::isParam(U64 paramID) const {
    ReadLock r_lock(_mutex);
    return _params.find(paramID) != std::cend(_params);
}

template <typename T>
inline bool ParamHandler::isParam(const char* param) const {
    return isParam<T>(_ID_RT(param));
}

template <typename T>
inline T ParamHandler::getParam(const char* name, T defaultValue) const {
    STUBBED("Please don't use strings directly for indexing with the ParamHandler");
    return getParam<T>(_ID_RT(name));
}

template <typename T>
inline T ParamHandler::getParam(U64 nameID, T defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamMap::const_iterator it = _params.find(nameID);
    if (it != std::cend(_params)) {
        bool success = false;
#       if !defined(CPP_17_SUPPORT)
        const T& ret = it->second.constant_cast<T>(success);
#       else
        const T& ret = std::any_cast<T>(it->second);
        success = true;
#       endif
        if (Config::Build::IS_DEBUG_BUILD) {
            if (!success) {
                Console::errorfn(Locale::get(_ID("ERROR_PARAM_CAST")), nameID);
                DIVIDE_ASSERT(success,
                              "ParamHandler error: Can't cast requested param to "
                              "specified type!");
            }
        }

        return ret;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), nameID);
    return defaultValue;  // integers will be 0, string will be empty, etc;
}

template <typename T>
inline void ParamHandler::setParam(const char* name, const T& value) {
    STUBBED("Please don't use strings directly for indexing with the ParamHandler");
    setParam<T>(_ID_RT(name), value);
}

template <typename T>
inline void ParamHandler::setParam(U64 nameID, const T& value) {
    WriteLock w_lock(_mutex);
    ParamMap::iterator it = _params.find(nameID);
    if (it == std::end(_params)) {
        bool result = hashAlg::emplace(_params, nameID, value).second;
        DIVIDE_ASSERT(result,"ParamHandler error: can't add specified value to map!");
    } else {
            it->second = AnyParam(value);
    }
}

template <typename T>
inline void ParamHandler::delParam(const char* name) {
    delParam<T>(_ID_RT(name));
}

template <typename T>
inline void ParamHandler::delParam(U64 nameID) {
    if (isParam<T>(nameID)) {
        WriteLock w_lock(_mutex);
        _params.erase(nameID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), nameID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), nameID);
    }
}

template <>
inline stringImpl ParamHandler::getParam(U64 paramID, stringImpl defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamStringMap::const_iterator it = _paramsStr.find(paramID);
    if (it != std::cend(_paramsStr)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(U64 paramID, const stringImpl& value) {
    WriteLock w_lock(_mutex);
    ParamStringMap::iterator it = _paramsStr.find(paramID);
    if (it == std::end(_paramsStr)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramsStr, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

#if defined(USE_CUSTOM_MEMORY_ALLOCATORS)
template <>
inline std::string ParamHandler::getParam(U64 paramID, std::string defaultValue) const {
    return getParam<stringImpl>(paramID, defaultValue.c_str()).c_str();
}
template <>
inline void ParamHandler::setParam(U64 paramID, const std::string& value) {
    setParam<stringImpl>(paramID, value.c_str());
}

#endif

template <>
inline bool ParamHandler::isParam<stringImpl>(U64 paramID) const {
    ReadLock r_lock(_mutex);
    return _paramsStr.find(paramID) != std::cend(_paramsStr);
}


template <>
inline void ParamHandler::delParam<stringImpl>(U64 paramID) {
    if (isParam<stringImpl>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramsStr.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

template <>
inline bool ParamHandler::getParam(U64 paramID, bool defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamBoolMap::const_iterator it = _paramBool.find(paramID);
    if (it != std::cend(_paramBool)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(U64 paramID, const bool& value) {
    WriteLock w_lock(_mutex);
    ParamBoolMap::iterator it = _paramBool.find(paramID);
    if (it == std::end(_paramBool)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramBool, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

template <>
inline bool ParamHandler::isParam<bool>(U64 paramID) const {
    ReadLock r_lock(_mutex);
    return _paramBool.find(paramID) != std::cend(_paramBool);
}

template <>
inline void ParamHandler::delParam<bool>(U64 paramID) {
    if (isParam<bool>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramBool.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

template <>
inline F32 ParamHandler::getParam(U64 paramID, F32 defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamFloatMap::const_iterator it = _paramsFloat.find(paramID);
    if (it != std::cend(_paramsFloat)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(U64 paramID, const F32& value) {
    WriteLock w_lock(_mutex);
    ParamFloatMap::iterator it = _paramsFloat.find(paramID);
    if (it == std::end(_paramsFloat)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramsFloat, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

template <>
inline bool ParamHandler::isParam<F32>(U64 paramID) const {
    ReadLock r_lock(_mutex);
    return _paramsFloat.find(paramID) != std::cend(_paramsFloat);
}

template <>
inline void ParamHandler::delParam<F32>(U64 paramID) {
    if (isParam<F32>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramsFloat.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

};  // namespace Divide

#endif  //_CORE_PARAM_HANDLER_INL_

Commits for Divide-Framework/trunk/Source Code/Core/Headers/ParamHandler.inl

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

923 Diff Diff IonutCava picture IonutCava Tue 01 Aug, 2017 22:23:24 +0000

[Ionut]
- Add (hack) new GL 4.6 KHR_NO_ERROR flag for non-GPU validated builds
- Disable GPU debug messages by default. Re-enabled only via a command line argument: “--enableGPUMessageGroups”.
- Cleanup GL texture and sampler binding
- Rework hash map insert and emplace
- Update SDL to 2.0.5

903 Diff Diff IonutCava picture IonutCava Sun 25 Jun, 2017 18:55:02 +0000

[IonutCava]
- Rework DebugInterface to be part of the PlatformContext and to allow adding of AntTweakBar elements via easy to use descriptors

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

795 Diff Diff IonutCava picture IonutCava Wed 23 Nov, 2016 17:14:33 +0000

[IonutCava]
- Remove ULL. Use U64 instead
- Various small bug fixes and typos.

782 Diff Diff IonutCava picture IonutCava Thu 13 Oct, 2016 16:12:04 +0000

[IonutCava]
- Added C++ version detection
- Improve Plane class
- Plane calculation improvements in Frustum class

760 Diff Diff IonutCava picture IonutCava Tue 09 Aug, 2016 16:30:12 +0000

[IonutCava]
- Complete rewrite of RenderPass system:
— Allow every rendering pass (reflection, environment, etc) to use the same rendering system: occlusion culling, light culling, etc
— Define render passes by a param based token similar to modern API systems (DX12/Vulkan)
— W.I.P.: Depth rendering slightly wrong; Environment Mapping ,reflection and refraction rendering currently disabled
- Add compile time variables for DEBUG/PROFILE/RELEASE builds to validate all code for every build

727 Diff Diff IonutCava picture IonutCava Tue 14 Jun, 2016 16:01:38 +0000

[IonutCava]
- Remove node and cmd buffers from GFXDevice and add them as a new BufferData struct to RenderPass class.
— Each render pass holds its own buffers
- Improvements / fixes to the CSM code
- Added a global toggle to enable/disable custom memory allocators

671 Diff Diff IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system

667 IonutCava picture IonutCava Fri 01 Apr, 2016 16:12:16 +0000

[IonutCava]
- replaced more strings with _ID equivalent
- streamlined shader include preprocessing
- improved intersection test performance for the Octree system at the cost of some memory