Loading...
Searching...
No Matches
GlobalFlags.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31#ifndef GLOBAL_FLAGS_H_
32#define GLOBAL_FLAGS_H_
33
34#include "Flags.h"
35#include "Static.h"
36
37namespace drain
38{
39
40/*
41template <class E>
42class MultiFlagger2 : public SingleFlagger<E> {
43
44
45public:
46
47
48 static inline
49 Flags & getShared(){
50 return Static::get<Flags,E>();
51 }
52
53 static inline
54 Flagger::dict_t & getSharedDict(){
55 return getShared().getDict();
56 }
57
58
59 MultiFlagger2() : SingleFlagger<E>(ownValue, getSharedDict()){
60 };
61
63 template <class T2>
64 inline
65 MultiFlagger2<T> & operator=(const T2 &x){
66 assign(x);
67 return *this;
68 }
69
70};
71*/
72
73
74// A Flagger with a global dict. Also provides a global Flagger, ie. Flagger with a global value and global dict.
76
79//
80template <class T>
81class GlobalFlags : public MultiFlagger<int> {
82
83
84public:
85
86
87 static inline
88 MultiFlagger<int> & getShared(){
89 return Static::get<MultiFlagger<int>,T>();
90 }
91
92 static inline
93 const MultiFlagger<int>::dict_t & getSharedDict(){
94 return getShared().getDict();
95 }
96
97
98 /*
99 GlobalFlags() : MultiFlagger<int>(ownValue, getSharedDict()){
100 };
101 */
102
104 template <class T2>
105 inline
106 GlobalFlags<T> & operator=(const T2 &x){
107 assign(x);
108 return *this;
109 }
110
112
117 // Consider adding a warning if value reserved
118 // Consider adding a notif if key already defined
119 /*
120 static inline
121 int addEntry(const std::string & key, int i=0){
122 return FlaggerBase<T>::addEntry(GlobalFlags<T>::getSharedDict(), key, i);
123 }
124 */
125
126 // System error (Network error, , memory error)
127
128
129
130};
131
132
133} // ::drain
134
135#endif
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
Flags using a global dictionary.
Definition GlobalFlags.h:81
GlobalFlags< T > & operator=(const T2 &x)
Sets value, ie. set or unsets all the flags.
Definition GlobalFlags.h:106
Definition Flags.h:220
virtual void assign(const std::string &s) override
Split a string to separate keys and/or values and set them.
Definition Flags.h:328
virtual const dict_t & getDict() const override
Returns the static dictionary created for this value_t .
Definition Flags.h:255
Definition DataSelector.cpp:1277