Rosetta Utilities  2014.35
Classes | Namespaces
KeyLookup.hh File Reference

Key lookup map and collection and functors. More...

#include <utility/keys/KeyLookup.fwd.hh>
#include <utility/keys/Key.hh>
#include <utility/keys/NoClient.hh>
#include <utility/keys/VariantKey.hh>
#include <cassert>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>

Classes

class  utility::keys::KeyLookup< K >
 Key lookup map and collection. More...
 
struct  utility::keys::lookup::has< K >
 Key lookup has query functor. More...
 
struct  utility::keys::lookup::key< K >
 Key lookup key query functor. More...
 
struct  utility::keys::lookup::gen< K >
 Key lookup/generator functor. More...
 
struct  utility::keys::lookup::n_key< K >
 Key lookup n_key query functor. More...
 
struct  utility::keys::lookup::begin< K >
 Key lookup begin iterator functor. More...
 
struct  utility::keys::lookup::end< K >
 Key lookup end iterator functor. More...
 

Namespaces

 utility
 unresizable vector whose size is known at compile time, which may be allocated on the stack, and which indexes from 1.
 
 utility::keys
 
 utility::keys::lookup
 

Detailed Description

Key lookup map and collection and functors.

Author
Stuart G. Mentzer (Stuar.nosp@m.t_Me.nosp@m.ntzer.nosp@m.@obj.nosp@m.exx.c.nosp@m.om)
Note
  • Monostate singleton: map and collection are static
  • Key (K) parameter: The key type
  • Client (C) parameter: The client (user) of the KeyLookup
  • Key must provide id(), identifier(), and code() members returning std::string
  • KeyLookup doesn't use map::operator[] to avoid default constructing keys, which would trigger an infinite cycle of add/insert calls
  • Holds copy of key in VariantKey to preserve dynamic key type
  • Holds just one copy of each key with a given value (determined by its operator <) even if the identifiers vary
  • If same value key is added again with any different identifiers all the identifiers refer to the original key in the lookup map
  • An identifier can only be used for a single key value: assert will catch violation
  • Keys are cloned by VariantKey so add them in their actual type constructor body
  • Functors for KeyLookup queries and key iterators are provided for key collections