rewrite to retrieve default-pipe query from the defintion context
This commit is contained in:
parent
5ba7468f41
commit
c7794e7cbf
2 changed files with 47 additions and 29 deletions
|
|
@ -120,6 +120,8 @@ namespace mobject {
|
||||||
* - a functor \c DEF::output usable as function pipe-ID --> Target
|
* - a functor \c DEF::output usable as function pipe-ID --> Target
|
||||||
* - the concrete output-functor also defines the concrete Target type,
|
* - the concrete output-functor also defines the concrete Target type,
|
||||||
* which will be returned when accessing the OutputMapping
|
* which will be returned when accessing the OutputMapping
|
||||||
|
* - a function \c DEF::buildQuery(sourcePipeID) yielding a defaults querry,
|
||||||
|
* to be issued in case of accessing a non existant mapping
|
||||||
*/
|
*/
|
||||||
template<class DEF>
|
template<class DEF>
|
||||||
class OutputMapping
|
class OutputMapping
|
||||||
|
|
@ -245,25 +247,9 @@ namespace mobject {
|
||||||
|
|
||||||
/* === Map-style access for clients === */
|
/* === Map-style access for clients === */
|
||||||
|
|
||||||
Resolver
|
Resolver operator[] (PId sourcePipeID);
|
||||||
operator[] (PId sourcePipeID)
|
Resolver operator[] (PPipe const& pipe);
|
||||||
{
|
Resolver operator[] (Query<asset::Pipe> const& query4pipe);
|
||||||
if (!contains (table_, sourcePipeID))
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED ("how to resolve");
|
|
||||||
}
|
|
||||||
return buildResolutionWrapper (sourcePipeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Resolver
|
|
||||||
operator[] (PPipe const& pipe)
|
|
||||||
{
|
|
||||||
REQUIRE (pipe);
|
|
||||||
return (*this) [pipe->getID()];
|
|
||||||
}
|
|
||||||
|
|
||||||
Resolver
|
|
||||||
operator[] (Query<asset::Pipe> const& query4pipe);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -283,6 +269,10 @@ namespace mobject {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ===== Implementation details ===== */
|
||||||
|
|
||||||
namespace _mapping {
|
namespace _mapping {
|
||||||
|
|
||||||
/** yield a suitable table slot for this query */
|
/** yield a suitable table slot for this query */
|
||||||
|
|
@ -293,6 +283,28 @@ namespace mobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class DEF>
|
||||||
|
inline typename OutputMapping<DEF>::Resolver
|
||||||
|
OutputMapping<DEF>::operator[] (PId sourcePipeID)
|
||||||
|
{
|
||||||
|
if (!contains (table_, sourcePipeID))
|
||||||
|
{
|
||||||
|
// issue a defaults query to resolve this mapping first
|
||||||
|
Query<asset::Pipe> query4pipe = DEF::buildQuery (sourcePipeID);
|
||||||
|
table_[sourcePipeID] = _mapping::resolveQuery (query4pipe);
|
||||||
|
}
|
||||||
|
return buildResolutionWrapper (sourcePipeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class DEF>
|
||||||
|
inline typename OutputMapping<DEF>::Resolver
|
||||||
|
OutputMapping<DEF>::operator[] (PPipe const& pipe)
|
||||||
|
{
|
||||||
|
REQUIRE (pipe);
|
||||||
|
return (*this) [pipe->getID()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** determine an OutputMapping by resolving a complex query,
|
/** determine an OutputMapping by resolving a complex query,
|
||||||
* instead of just picking a mapped pipe (which is the default usage).
|
* instead of just picking a mapped pipe (which is the default usage).
|
||||||
|
|
@ -312,17 +324,17 @@ namespace mobject {
|
||||||
* if in doubt.
|
* if in doubt.
|
||||||
*/
|
*/
|
||||||
template<class DEF>
|
template<class DEF>
|
||||||
typename OutputMapping<DEF>::Resolver
|
inline typename OutputMapping<DEF>::Resolver
|
||||||
OutputMapping<DEF>::operator[] (Query<asset::Pipe> const& query4pipe)
|
OutputMapping<DEF>::operator[] (Query<asset::Pipe> const& query4pipe)
|
||||||
{
|
{
|
||||||
HashVal hash4query = _mapping::slot (query4pipe);
|
HashVal hash4query = _mapping::slot (query4pipe);
|
||||||
if (!contains (table_, hash4query))
|
if (!contains (table_, hash4query))
|
||||||
// need to resolve this query first
|
// need to resolve this query first
|
||||||
table_[hash4query] = _mapping::resolveQuery (query4pipe);
|
table_[hash4query] = _mapping::resolveQuery (query4pipe);
|
||||||
|
|
||||||
ENSURE (contains (table_, hash4query));
|
ENSURE (contains (table_, hash4query));
|
||||||
return buildResolutionWrapper (hash4query);
|
return buildResolutionWrapper (hash4query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace mobject
|
} // namespace mobject
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,12 @@ namespace test {
|
||||||
{
|
{
|
||||||
return Pipe::lookup(target)->ident.name;
|
return Pipe::lookup(target)->ident.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Query<Pipe>
|
||||||
|
buildQuery (PID sourcePipeID)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED ("fabricate defaults query for unit-test");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef OutputMapping<DummyDef> Mapping;
|
typedef OutputMapping<DummyDef> Mapping;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue