Wt::FlagMap Class Reference

maps the flags of the underlying system to ours More...

#include <flagmap.h>

Inheritance diagram for Wt::FlagMap:

Inheritance graph
[legend]
Collaboration diagram for Wt::FlagMap:

Collaboration graph
[legend]
List of all members.

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, intStdMap

Private Attributes

bool consequent_

Detailed Description

maps the flags of the underlying system to ours

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.


Member Typedef Documentation

typedef std::map<int, int> Wt::FlagMap::StdMap [private]

Definition at line 52 of file flagmap.h.


Constructor & Destructor Documentation

Wt::FlagMap::FlagMap (  )  [inline]

Definition at line 55 of file flagmap.h.

00055 : StdMap() {}

template<typename InputIterator>
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) {}


Member Function Documentation

int Wt::FlagMap::operator[] ( int  key  )  const [inline]

Definition at line 63 of file flagmap.h.

00063                                   {
00064         const_iterator it = find(key);
00065         const bool is_flag_valid = it != end();
00066         //assert(is_flag_valid);
00067         return is_flag_valid ? it->second : 0;
00068     }

int Wt::FlagMap::state ( int  flags  )  const [inline]

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     }


Member Data Documentation

bool Wt::FlagMap::consequent_ [private]

Definition at line 88 of file flagmap.h.

Referenced by state().


The documentation for this class was generated from the following file:

Generated Fri Jul 28 19:28:36 2006.
Copyright © 1998-2003 by the respective authors.

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.