GlobalFlags.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 #ifndef GLOBAL_FLAGS_H_
32 #define GLOBAL_FLAGS_H_
33 
34 #include "FlagsOld.h"
35 #include "Static.h"
36 
37 namespace drain
38 {
39 
40 /*
41 template <class E>
42 class MultiFlagger2 : public SingleFlagger<E> {
43 
44 
45 public:
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 //
80 template <class T>
81 class GlobalFlags : public Flagger {
82 
83 
84 public:
85 
86 
87  static inline
88  Flags & getShared(){
89  return Static::get<Flags,T>();
90  }
91 
92  static inline
93  Flagger::dict_t & getSharedDict(){
94  return getShared().getDict();
95  }
96 
97 
98  GlobalFlags() : Flagger(ownValue, getSharedDict()){
99  };
100 
102  template <class T2>
103  inline
104  GlobalFlags<T> & operator=(const T2 &x){
105  assign(x);
106  return *this;
107  }
108 
110 
115  // Consider adding a warning if value reserved
116  // Consider adding a notif if key already defined
117  static inline
118  Flagger::ivalue_t addEntry(const Flagger::dict_t::key_t & key, ivalue_t i=0){
120  }
121 
122  // System error (Network error, , memory error)
123 
124 
125 
126 };
127 
128 
129 } // ::drain
130 
131 #endif
static ivalue_t addEntry(drain::Dictionary< key_t, T > &dict, const key_t &key, ivalue_t i=0)
Add a new entry in the dictionary.
A bit vector with external Dictionary mapping from strings to bits and vice versa.
Definition: FlagsOld.h:45
void assign(ivalue_t x)
Sets value, ie. set or unsets all the flags.
Definition: FlagsOld.h:196
Self-contained Flagger – with an own dictionary and value.
Definition: FlagsOld.h:314
Flags using a global dictionary.
Definition: GlobalFlags.h:81
static Flagger::ivalue_t addEntry(const Flagger::dict_t::key_t &key, ivalue_t i=0)
Add a new entry in the dictionary.
Definition: GlobalFlags.h:118
GlobalFlags< T > & operator=(const T2 &x)
Sets value, ie. set or unsets all the flags.
Definition: GlobalFlags.h:104
Definition: DataSelector.cpp:1277