#include <flagmap.h>
Inheritance diagram for Wt::FlagMap:
Public Member Functions | |
FlagMap () | |
template<typename InputIterator> | |
FlagMap (InputIterator first, InputIterator last) | |
int | operator[] (int key) const |
int | state (int flags) const |
Private Types | |
typedef std::map< int, int > | StdMap |
Private Attributes | |
bool | consequent_ |
This is one weird class that needs some documenting since it competely not obvious.
This is a map between two different but equivalent flags sets.
The mapped type (value_type) is always an enum in power of two.
The key_type can be consequent or power of two. We use a heuristic to decide if it is consequent or not. if consequent = true then the key is expected in consequent numbers starting from 1 (1, 2, 3) else it is expected an enum with powers of two (1, 2, 4, 8)
You can map a key of the original system to a Wt flag using operator[].
It is also possible to map an ored combination of the original flags using state().
Definition at line 51 of file flagmap.h.
typedef std::map<int, int> Wt::FlagMap::StdMap [private] |
Wt::FlagMap::FlagMap | ( | InputIterator | first, | |
InputIterator | last | |||
) | [inline] |
Definition at line 58 of file flagmap.h.
00058 : 00059 StdMap(first, last), 00060 consequent_(size() > 2 && find(3) == end() ? false : true) {}
Definition at line 70 of file flagmap.h.
References consequent_.
Referenced by Wt::SDLInput::EventInfo::EventInfo(), Wt::SDLInput::handleKeyEvent(), and Wt::SDLDisplay::load().
00070 { 00071 const FlagMap& self = *this; 00072 int state_ = 0; 00073 int key; 00074 00075 for (const_iterator it = begin(), e = end(); it != e; ++it) { 00076 if (consequent_) { 00077 key = (flags & (1 << (it->first - 1))) ? it->first : 0; 00078 } else { 00079 key = flags & it->first; 00080 } 00081 state_ |= self[key]; 00082 } 00083 00084 return state_; 00085 }
bool Wt::FlagMap::consequent_ [private] |
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.