Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParamHandler.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_CORE_PARAM_HANDLER_H_
34#define DVD_CORE_PARAM_HANDLER_H_
35
36namespace Divide {
37
38
40
41public:
42 using HashType = U64;
43
45
53
54 public:
55 ParamHandler() noexcept = default;
56 ~ParamHandler() = default;
57
58 void setDebugOutput(bool logState) noexcept;
59
60 template <typename T>
61 [[nodiscard]] T getParam(HashType nameID, T defaultValue = T()) const;
62
63 template <typename T>
64 void setParam(HashType nameID, T&& value);
65
66 template <typename T>
67 void delParam(HashType nameID);
68
69 template <typename T>
70 [[nodiscard]] bool isParam(HashType nameID) const;
71
72 private:
78 std::atomic_bool _logState;
79};
80
81} // namespace Divide
82
83#endif //DVD_CORE_PARAM_HANDLER_H_
84
85#include "ParamHandler.inl"
T getParam(HashType nameID, T defaultValue=T()) const
SharedMutex _mutex
Definition: ParamHandler.h:77
bool isParam(HashType nameID) const
void setParam(HashType nameID, T &&value)
hashMap< HashType, std::any > ParamMap
Definition: ParamHandler.h:44
hashMap< HashType, string > ParamStringMap
A special map for string types (small perf. optimization for add/retrieve)
Definition: ParamHandler.h:47
ParamBoolMap _paramBool
Definition: ParamHandler.h:74
ParamStringMap _paramsStr
Definition: ParamHandler.h:75
ParamHandler() noexcept=default
void setDebugOutput(bool logState) noexcept
hashMap< HashType, F32 > ParamFloatMap
Floats are also used often.
Definition: ParamHandler.h:52
void delParam(HashType nameID)
ParamFloatMap _paramsFloat
Definition: ParamHandler.h:76
std::atomic_bool _logState
Definition: ParamHandler.h:78
hashMap< HashType, bool > ParamBoolMap
Definition: ParamHandler.h:50
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
uint64_t U64