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 "Flags.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 MultiFlagger<int> {
82 
83 
84 public:
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
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:199
virtual void assign(const std::string &s) override
Split a string to separate keys and/or values and set them.
Definition: Flags.h:330
virtual const dict_t & getDict() const override
Returns the static dictionary created for this value_t .
Definition: Flags.h:252
Definition: DataSelector.cpp:1277