38 #ifndef LUMIERA_QUERY_DEFS_REGISTRY_H 39 #define LUMIERA_QUERY_DEFS_REGISTRY_H 70 _Fmt dumpRecord (
"%2i| %64s --> %s\n");
81 typedef std::vector< P<TableEntry> >
Table;
97 , degree(queryKey.degree())
109 operator() (
Record const& rec)
111 P<TAR> storedObj (rec.objRef.lock());
112 return storedObj && (storedObj == obj_);
119 return one.queryKey < two.queryKey;
122 operator string ()
const {
return dumpRecord % degree % queryKey.display() % dumpObj(); }
123 string dumpObj ()
const {
P<TAR> o (objRef.lock());
return o? string(*o):
"dead"; }
135 typedef std::set<Record<TAR>> Registry;
141 access (Table& table)
144 || index > table.size()
148 ASSERT (0 < index && index<=table.size() && table[index-1]);
149 Slot* item =
static_cast<Slot*
> (table[index-1].get());
150 return item->registry;
155 createSlot (Table& table)
160 if (index > table.size())
161 table.resize (index);
162 table[index-1].reset(
new Slot);
203 : p(from), i(from), e(to)
209 Iter (II match, II from, II to)
210 : p(match), i(from), e(to)
221 next = p->objRef.lock();
229 P<TAR> operator* () {
return ptr; }
230 bool hasNext () {
return next || findNext(); }
254 typedef typename Slot<TAR>::Registry Registry;
258 typename Registry::iterator pos = registry.find (entry);
259 typename Registry::iterator end = registry.end();
262 return Iter<TAR> (registry.begin(), end);
264 return Iter<TAR> (pos, registry.begin(), end);
280 typedef typename Slot<TAR>::Registry Registry;
281 typedef typename Registry::iterator RIter;
284 RIter pos = registry.lower_bound (entry);
285 if ( pos!=registry.end()
286 && pos->queryKey == query)
288 P<TAR> storedObj (pos->objRef.lock());
290 return (storedObj == obj);
293 registry.erase(pos++);
296 registry.insert(pos, entry);
297 ENSURE (registry.find (entry) != registry.end());
309 typedef typename Slot<TAR>::Registry Registry;
313 return util::remove_if(registry, SearchFunc (obj));
328 res += string(entry);
used for enumerating solutions
static size_t index
where to find this Slot in every Table
Utilities to support working with predicate queries.
Basic and generic representation of an internal query.
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
< Functor searching for a specific object
Any copy and copy construction prohibited.
Customised refcounting smart pointer.
A front-end for using printf-style formatting.
Iter(II match, II from, II to)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
holding a single "default object" entry
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
every new kind of object (Type) creates a new slot in the main Table holding all registered default o...
A special implementation of lib::Sync, where the storage of the object monitor is associated directly...
Iter< TAR > candidates(Query< TAR > const &query)
find a sequence of "default" objects possibly matching the query.
Wrapper for indexing and ordering.
A synchronisation protection guard employing a lock scoped to the parameter type as a whole...
ExampleStrategy::Qualifier two(string additionalArg)
definition of another qualifier two(arg), accepting an additional argument
Lumiera public interface.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
uint maxSlots(0)
number of different registered Types
string dump()
helper for diagnostics.
bool forget(P< TAR > const &obj)
if this object is registered as "default" in some way, drop the registration.
ExampleStrategy::Qualifier one()
definition of a qualifier one()
std::vector< P< TableEntry > > Table
we maintain an independent defaults registry for every participating kind of object.
Perform operations "for each element" of a collection.
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
bool put(P< TAR > const &obj, Query< TAR > const &query)
register the object as being "default" when searching something similar as designated by the given qu...