47 #ifndef LUMIERA_QUERY_DEFS_REGISTRY_H 48 #define LUMIERA_QUERY_DEFS_REGISTRY_H 79 _Fmt dumpRecord (
"%2i| %64s --> %s\n");
90 typedef std::vector< P<TableEntry> >
Table;
100 weak_ptr<TAR> objRef;
106 , degree(queryKey.degree())
118 operator() (
Record const& rec)
120 P<TAR> storedObj (rec.objRef.lock());
121 return storedObj && (storedObj == obj_);
128 return one.queryKey < two.queryKey;
131 operator string ()
const {
return dumpRecord % degree % queryKey.display() % dumpObj(); }
132 string dumpObj ()
const {
P<TAR> o (objRef.lock());
return o? string(*o):
"dead"; }
144 typedef std::set<Record<TAR>> Registry;
150 access (Table& table)
153 || index > table.size()
157 ASSERT (0 < index && index<=table.size() && table[index-1]);
158 Slot* item =
static_cast<Slot*
> (table[index-1].get());
159 return item->registry;
164 createSlot (Table& table)
169 if (index > table.size())
170 table.resize (index);
171 table[index-1].reset(
new Slot);
212 : p(from), i(from), e(to)
218 Iter (II match, II from, II to)
219 : p(match), i(from), e(to)
230 next = p->objRef.lock();
238 P<TAR> operator* () {
return ptr; }
239 bool hasNext () {
return next || findNext(); }
263 typedef typename Slot<TAR>::Registry Registry;
267 typename Registry::iterator pos = registry.find (entry);
268 typename Registry::iterator end = registry.end();
271 return Iter<TAR> (registry.begin(), end);
273 return Iter<TAR> (pos, registry.begin(), end);
289 typedef typename Slot<TAR>::Registry Registry;
290 typedef typename Registry::iterator RIter;
293 RIter pos = registry.lower_bound (entry);
294 if ( pos!=registry.end()
295 && pos->queryKey == query)
297 P<TAR> storedObj (pos->objRef.lock());
299 return (storedObj == obj);
302 registry.erase(pos++);
305 registry.insert(pos, entry);
306 ENSURE (registry.find (entry) != registry.end());
318 typedef typename Slot<TAR>::Registry Registry;
322 return util::remove_if(registry, SearchFunc (obj));
337 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...