adjustments and stubbing to get it past the compiler

This commit is contained in:
Fischlurch 2012-11-26 01:22:01 +01:00
parent b5a7055f29
commit dd8a88d095
46 changed files with 483 additions and 427 deletions

View file

@ -24,7 +24,7 @@
#include "lib/error.hpp" #include "lib/error.hpp"
#include "common/configrules.hpp" #include "common/configrules.hpp"
#include "common/query/fake-configrules.hpp" #include "proc/mobject/session/query/fake-configrules.hpp"
@ -39,7 +39,7 @@ namespace lumiera {
namespace { namespace {
/** type of the actual ConfigRules implementation to use */ /** type of the actual ConfigRules implementation to use */
lib::singleton::UseSubclass<query::MockConfigRules> typeinfo; lib::singleton::UseSubclass<proc::mobject::session::query::MockConfigRules> typeinfo;
} }

View file

@ -41,6 +41,7 @@
** @see mobject::session::DefsManager ** @see mobject::session::DefsManager
** @see asset::StructFactory ** @see asset::StructFactory
** @see fake-configrules.hpp currently used dummy-implementation ** @see fake-configrules.hpp currently used dummy-implementation
** @see
** **
*/ */
@ -98,6 +99,7 @@ namespace lumiera { ///////TODO: shouldn't that be namespace lib? or proc?
using lib::Symbol; using lib::Symbol;
using lib::Literal; using lib::Literal;
using lib::Query;
/** placeholder definition for later. /** placeholder definition for later.
* @todo intention is to integrate with lib::Symbol * @todo intention is to integrate with lib::Symbol

View file

@ -228,7 +228,7 @@ namespace advice {
inline Binding const& inline Binding const&
Binding::addTypeGuard() Binding::addTypeGuard()
{ {
atoms_.insert (Atom ("advice.type."+lumiera::query::buildTypeID<TY>())); atoms_.insert (Atom ("advice.type."+lib::query::buildTypeID<TY>()));
return *this; return *this;
} }

View file

@ -30,8 +30,6 @@ namespace lib {
/* generate vtables here... */ /* generate vtables here... */
Goal::~Goal() { }
Resolution::~Resolution() { } Resolution::~Resolution() { }
QueryResolver::~QueryResolver() { } QueryResolver::~QueryResolver() { }
@ -57,12 +55,14 @@ namespace lib {
/* == dispatch to resolve typed queries == */ /* == dispatch to resolve typed queries == */
using factory::BuildRefcountPtr;
/** factory used as dispatcher table /** factory used as dispatcher table
* for resolving typed queries */ * for resolving typed queries */
typedef MultiFact< Resolution(Goal const&) // nominal signature of fabrication typedef factory::MultiFact< Resolution(Goal const&) // nominal signature of fabrication
, Goal::QueryID // select resolution function by kind-of-Query , Goal::QueryID // select resolution function by kind-of-Query
, BuildRefcountPtr // wrapper: manage result set by smart-ptr , BuildRefcountPtr // wrapper: manage result set by smart-ptr
> DispatcherTable; // > DispatcherTable; //
struct QueryDispatcher struct QueryDispatcher
: DispatcherTable : DispatcherTable

View file

@ -1,5 +1,5 @@
/* /*
QUERY-RESOLVER.hpp - interface for discovering contents of a scope QUERY-RESOLVER.hpp - framework for resolving generic queries
Copyright (C) Lumiera.org Copyright (C) Lumiera.org
2009, Hermann Vosseler <Ichthyostega@web.de> 2009, Hermann Vosseler <Ichthyostega@web.de>
@ -21,235 +21,41 @@
*/ */
#ifndef PROC_MOBJECT_SESSION_QUERY_RESOLVER_H #ifndef LIB_QUERY_RESOLVER_H
#define PROC_MOBJECT_SESSION_QUERY_RESOLVER_H #define LIB_QUERY_RESOLVER_H
//#include "proc/mobject/mobject.hpp" #include "lib/query.hpp"
//#include "proc/mobject/placement.hpp"
#include "lib/bool-checkable.hpp"
#include "lib/typed-counter.hpp"
#include "lib/iter-adapter.hpp" #include "lib/iter-adapter.hpp"
#include "lib/nocopy.hpp"
#include "lib/util.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <tr1/functional> #include <tr1/functional>
#include <tr1/memory> #include <tr1/memory>
//#include <vector>
#include <string> #include <string>
//using std::vector; using std::tr1::function;
//using std::string;
namespace lib { namespace lib {
using lib::IxID;
using util::unConst;
using boost::noncopyable; using boost::noncopyable;
using boost::lexical_cast;
using boost::scoped_ptr; using boost::scoped_ptr;
using std::tr1::function;
using std::string; using std::string;
class Goal;
class Resolution; class Resolution;
class QueryResolver; class QueryResolver;
class QueryDispatcher; class QueryDispatcher;
/** Allow for taking ownership of a result set */ /** Allow for taking ownership of a result set */
typedef std::tr1::shared_ptr<Resolution> PReso; typedef std::tr1::shared_ptr<Resolution> PReso;
/**
* TODO type comment
* Query ABC
*/
class Goal
: util::no_copy_by_client
{
public:
virtual ~Goal() ;
enum Kind
{ GENERIC = 0
, DISCOVERY
};
struct QueryID
{
Kind kind;
IxID type;
};
QueryID const&
getQID() const
{
return id_;
}
/**
* Single Solution, possibly part of a result set.
* A pointer-like object, usually to be down-casted
* to a specifically typed Query::Cursor
* @see Resolution
*/
class Result
: public lib::BoolCheckable<Result>
{
void* cur_;
protected:
void point_at(void* p) { cur_ = p; }
template<typename RES>
RES&
access()
{
REQUIRE (cur_);
return *reinterpret_cast<RES*> (cur_);
}
public:
bool isValid() const { return bool(cur_); }
Result() : cur_(0) { } ///< create an NIL result
};
protected:
QueryID id_;
Goal (QueryID qid)
: id_(qid)
{ }
};
inline bool
operator== (Goal::QueryID const& id1, Goal::QueryID const& id2)
{
return id1.kind == id2.kind
&& id1.type == id2.type;
}
inline bool
operator!= (Goal::QueryID const& id1, Goal::QueryID const& id2)
{
return ! (id1 == id2);
}
/** Context used for generating type-IDs to denote
* the specific result types of issued queries */
typedef lib::TypedContext<Goal::Result> ResultType;
template<typename RES>
inline IxID
getResultTypeID() ///< @return unique ID denoting result type RES
{
return ResultType::ID<RES>::get();
}
/**
* TODO type comment
* Concrete query to yield specifically typed result elements
*/
template<class RES>
class Query
: public Goal
{
protected:
static QueryID
defineQueryTypeID (Kind queryType = Goal::GENERIC)
{
QueryID id = {queryType, getResultTypeID<RES>() };
return id;
}
class Builder;
public:
Query()
: Goal (defineQueryTypeID())
{ }
static Builder
build (Kind queryType = Goal::GENERIC);
/* results retrieval */
class Cursor
: public Goal::Result
{
public:
typedef RES value_type;
typedef RES& reference;
typedef RES* pointer;
RES& operator* () { return access<RES>(); }
RES* operator->() { return & access<RES>(); }
void point_at(RES* r){ Goal::Result::point_at(r);}
void point_at(RES& r){ Goal::Result::point_at(&r);}
};
typedef lib::IterAdapter<Cursor,PReso> iterator;
iterator operator() (QueryResolver const& resolver) const;
iterator resolveBy (QueryResolver const& resolver) const;
protected:
Query (QueryID qID)
: Goal (qID)
{ }
friend class Builder;
};
/**
* Helper for establishing,
* reworking and remolding queries.
*/
template<class RES>
class Query<RES>::Builder
{
string predicateForm_;
public:
const string
asKey() const
{
return "type("
+ lexical_cast<string> (getResultTypeID<RES>())
+ "), "+predicateForm_;
}
};
/** /**
* ABC denoting the result set * ABC representing the result set
* of an individual query resolution * of an individual query resolution
*/ */
class Resolution class Resolution
: noncopyable : boost::noncopyable
{ {
public: public:
typedef Goal::Result Result; typedef Goal::Result Result;

View file

@ -1,5 +1,5 @@
/* /*
Query - interface for capability queries Query - interface for generic queries
Copyright (C) Lumiera.org Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de> 2008, Hermann Vosseler <Ichthyostega@web.de>
@ -40,7 +40,7 @@ using util::contains;
using util::isnil; using util::isnil;
namespace lumiera { namespace lib {
namespace query { namespace query {
namespace { // local definitions namespace { // local definitions
@ -142,7 +142,9 @@ namespace lumiera {
} // namespace query } // namespace query
/** */
Goal::~Goal() { }
} // namespace lumiera } // namespace lib

View file

@ -1,5 +1,5 @@
/* /*
QUERY.hpp - interface for capability queries QUERY.hpp - interface for generic queries
Copyright (C) Lumiera.org Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de> 2008, Hermann Vosseler <Ichthyostega@web.de>
@ -21,63 +21,271 @@
*/ */
#ifndef LUMIERA_QUERY_H #ifndef LIB_QUERY_H
#define LUMIERA_QUERY_H #define LIB_QUERY_H
#include <string> #include "lib/bool-checkable.hpp"
#include <cctype> #include "lib/typed-counter.hpp"
#include <typeinfo> #include "lib/iter-adapter.hpp"
#include "lib/nocopy.hpp"
#include "lib/symbol.hpp" #include "lib/symbol.hpp"
#include "lib/util.hpp"
#include <boost/lexical_cast.hpp>
#include <tr1/memory>
#include <typeinfo>
#include <cctype>
#include <string>
namespace lumiera { namespace lib {
using lib::IxID;
using lib::Symbol; using lib::Symbol;
using lib::Literal; using lib::Literal;
using util::unConst;
using boost::lexical_cast;
using std::string; using std::string;
/* ==== common definitions for rule based queries ==== */ /* ==== common definitions for rule based queries ==== */
class Goal;
class Resolution;
class QueryResolver;
/** Allow for taking ownership of a result set */
typedef std::tr1::shared_ptr<Resolution> PReso;
/**
* Query ABC: unspecific goal for resolution or retrieval.
* Goal elements are used within the backbone of a generic query system
* to access individual resolution mechanisms based on an internal classification
* of the type of query.
*/
class Goal
: util::no_copy_by_client
{
public:
virtual ~Goal() ;
enum Kind
{ GENERIC = 0
, DISCOVERY
};
struct QueryID
{
Kind kind;
IxID type;
};
QueryID const&
getQID() const
{
return id_;
}
/**
* Single Solution, possibly part of a result set.
* A pointer-like object, usually to be down-casted
* to a specifically typed Query::Cursor
* @see Resolution
*/
class Result
: public lib::BoolCheckable<Result>
{
void* cur_;
protected:
void point_at(void* p) { cur_ = p; }
template<typename RES>
RES&
access()
{
REQUIRE (cur_);
return *reinterpret_cast<RES*> (cur_);
}
public:
bool isValid() const { return bool(cur_); }
Result() : cur_(0) { } ///< create an NIL result
};
protected:
QueryID id_;
Goal (QueryID qid)
: id_(qid)
{ }
};
inline bool
operator== (Goal::QueryID const& id1, Goal::QueryID const& id2)
{
return id1.kind == id2.kind
&& id1.type == id2.type;
}
inline bool
operator!= (Goal::QueryID const& id1, Goal::QueryID const& id2)
{
return ! (id1 == id2);
}
/** Context used for generating type-IDs to denote
* the specific result types of issued queries */
typedef lib::TypedContext<Goal::Result> ResultType;
template<typename RES>
inline IxID
getResultTypeID() ///< @return unique ID denoting result type RES
{
return ResultType::ID<RES>::get();
}
/** /**
* Generic query interface for retrieving objects * Generic interface to express a query
* matching the given capability query * for specifically typed result elements
* providing some capabilities or fulfilling
* some properties. This is a generic umbrella
* for several kinds of queries and provides a
* mechanism for uniform usage of various
* resolution mechanisms.
*
* Any query bears an internal type classification and can be
* represented in a common syntactical form based on predicate logic.
* Query instances are created by some facilities allowing to query for objects.
* These query providers \em do know the specific kind (type) of query to expose.
* While client code uses these queries only by reference, there is the possibility
* to involve a generic QueryResolver, which -- behind the scenes -- manages a registry
* of specific resolution mechanisms. This way, clients may retrieve a set of results,
* each representing a possible solution to the posed query.
*
* @note until really integrating a rules based system * @note until really integrating a rules based system
* this is a dummy placeholder implementation * this is largely dummy placeholder implementation.
* based on a dressed-up std::string * Some more specific query resolvers are available already,
* @warning in this preliminary implementation, the * so, depending on the circumstances the actual resolution might be
* given query-string is used as-is, without any * substantial or just a fake.
* normalisation. Moreover, as espeically the * @warning especially the classical resolution-type queries are just
* fake-configrules match by string comparision, * faked and use the given query-string as-is, without any normalisation.
* Moreover, as especially the fake-configrules match by string comparison,
* this may led to unexpected mis-matches. * this may led to unexpected mis-matches.
* @todo the »real thing« should be based on a
* normalised syntax tree representation
* of the atoms in the query.
*/ */
template<class OBJ> template<class RES>
class Query class Query
: public Goal
{ {
std::string predicateForm_; protected:
static QueryID
public: defineQueryTypeID (Kind queryType = Goal::GENERIC)
explicit Query (string const& predicate="")
: predicateForm_(predicate)
{ }
void
clear()
{ {
predicateForm_.clear(); QueryID id = {queryType, getResultTypeID<RES>() };
return id;
} }
operator string() const { return predicateForm_; } class Builder;
// operator string& () { return predicateForm_; } //TICKET #710 : needed temporarily by fake-configrules public:
}; // for calling removeTerm on the string-ref.... Query()
: Goal (defineQueryTypeID())
{ }
explicit
Query (string querySpec)
: Goal (defineQueryTypeID(Goal::GENERIC))
{
UNIMPLEMENTED("how to issue generic queries");////////////////////////////////////////////////////////////////////////////////////////////TODO
}
static Builder
build (Kind queryType = Goal::GENERIC);
/* results retrieval */
class Cursor
: public Goal::Result
{
public:
typedef RES value_type;
typedef RES& reference;
typedef RES* pointer;
RES& operator* () { return access<RES>(); }
RES* operator->() { return & access<RES>(); }
void point_at(RES* r){ Goal::Result::point_at(r);}
void point_at(RES& r){ Goal::Result::point_at(&r);}
};
typedef lib::IterAdapter<Cursor,PReso> iterator;
iterator operator() (QueryResolver const& resolver) const;
iterator resolveBy (QueryResolver const& resolver) const;
friend size_t
hash_value (Query const& q)
{
UNIMPLEMENTED("generic standard representation");////////////////////////////////////////////////////////////////////////////////////////////TODO
}
friend bool
operator== (Query const& q1, Query const& q2)
{
UNIMPLEMENTED("how to define equality on queries");////////////////////////////////////////////////////////////////////////////////////////////TODO
}
protected:
Query (QueryID qID)
: Goal (qID)
{ }
friend class Builder;
};
/**
* Helper for establishing,
* reworking and remolding queries.
*/
template<class RES>
class Query<RES>::Builder
{
string predicateForm_;
public:
const string
asKey() const
{
return "type("
+ lexical_cast<string> (getResultTypeID<RES>())
+ "), "+predicateForm_;
}
};
namespace query { namespace query {

View file

@ -58,9 +58,10 @@ namespace asset {
PPipe PPipe
Pipe::query (string properties) Pipe::query (Query<Pipe> const& properties)
{ {
return Struct::retrieve (Query<Pipe> (properties)); UNIMPLEMENTED ("maybe provide a direct way to query, based on a predicate string?");//////////////////////////////////TODO
return Struct::retrieve (properties);
} }

View file

@ -27,6 +27,7 @@
#include "proc/asset/struct.hpp" #include "proc/asset/struct.hpp"
#include "proc/asset/procpatt.hpp" #include "proc/asset/procpatt.hpp"
#include "proc/streamtype.hpp" #include "proc/streamtype.hpp"
#include "lib/query.hpp"
#include <string> #include <string>
@ -35,6 +36,7 @@
namespace proc { namespace proc {
namespace asset { namespace asset {
using lib::Query;
using std::string; using std::string;
class Pipe; class Pipe;
@ -96,7 +98,7 @@ namespace asset {
void switchProcPatt (PProcPatt& another); void switchProcPatt (PProcPatt& another);
/** convenience shortcut for retrieving default configured pipes */ /** convenience shortcut for retrieving default configured pipes */
static PPipe query (string properties); static PPipe query (Query<Pipe> const& properties);
/** convenience shortcut for lookup by id */ /** convenience shortcut for lookup by id */
static PPipe lookup (ID<Pipe> id); static PPipe lookup (ID<Pipe> id);

View file

@ -69,7 +69,7 @@ namespace asset {
using util::isnil; using util::isnil;
using util::contains; using util::contains;
using lumiera::query::LUMIERA_ERROR_CAPABILITY_QUERY; using lumiera::query::LUMIERA_ERROR_CAPABILITY_QUERY;
using lumiera::query::extractID; using lib::query::extractID;
using proc::mobject::Session; using proc::mobject::Session;
using proc::mobject::MObject; using proc::mobject::MObject;
@ -113,9 +113,11 @@ namespace asset {
createIdent (Query<STRU> const& query) createIdent (Query<STRU> const& query)
{ {
// does the query somehow specify the desired name-ID? // does the query somehow specify the desired name-ID?
string nameID = extractID (genericIdSymbol, query); string nameID = "TODO";//extractID (genericIdSymbol, query);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("Query rebuilding");////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
nameID = extractID (StructTraits<STRU>::idSymbol(), query); nameID = "TODO";//extractID (StructTraits<STRU>::idSymbol(), query);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("Query rebuilding");////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
{ {
// no name-ID contained in the query... // no name-ID contained in the query...
@ -127,7 +129,8 @@ namespace asset {
ENSURE (!isnil (nameID)); ENSURE (!isnil (nameID));
// does the query actually demand the Nth instance/element? // does the query actually demand the Nth instance/element?
string seqID = extractID (seqNrPredicate, query); string seqID = "TODO";//extractID (seqNrPredicate, query);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("Query rebuilding");////////////////////////////////////////////////////////////////////////////////////////////TODO)
if (!isnil (seqID) && 1 < asNumber(seqID)) if (!isnil (seqID) && 1 < asNumber(seqID))
nameID += "."+seqID; nameID += "."+seqID;
@ -200,7 +203,8 @@ namespace asset {
StructFactoryImpl::fabricate (Query<Pipe> const& caps) StructFactoryImpl::fabricate (Query<Pipe> const& caps)
{ {
const Asset::Ident idi (createIdent (caps)); const Asset::Ident idi (createIdent (caps));
string streamID = extractID ("stream", caps); string streamID = "TODO";//extractID ("stream", caps);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("fabricate a Pipe by query");////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (streamID)) streamID = "default"; if (isnil (streamID)) streamID = "default";
PProcPatt processingPattern = Session::current->defaults (Query<const ProcPatt>("stream("+streamID+")")); PProcPatt processingPattern = Session::current->defaults (Query<const ProcPatt>("stream("+streamID+")"));
return new Pipe( idi return new Pipe( idi
@ -215,7 +219,8 @@ namespace asset {
{ {
TODO ("extract additional properties/capabilities from the query..."); TODO ("extract additional properties/capabilities from the query...");
const Asset::Ident idi (createIdent (caps)); const Asset::Ident idi (createIdent (caps));
string sequenceID = extractID ("sequence", caps); string sequenceID = "TODO";//extractID ("sequence", caps);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("fabricate a Timeline by query");////////////////////////////////////////////////////////////////////////////////////////////TODO
Query<Sequence> desiredSequence (isnil (sequenceID)? "" : "id("+sequenceID+")"); Query<Sequence> desiredSequence (isnil (sequenceID)? "" : "id("+sequenceID+")");
PSequence sequence = recursive_create_(desiredSequence); PSequence sequence = recursive_create_(desiredSequence);
ASSERT (sequence); ASSERT (sequence);
@ -232,7 +237,8 @@ namespace asset {
{ {
// when we reach this point it is clear a suitable sequence doesn't yet exist in the model // when we reach this point it is clear a suitable sequence doesn't yet exist in the model
TODO ("actually extract properties/capabilities from the query..."); TODO ("actually extract properties/capabilities from the query...");
string trackID = extractID ("track", caps); string trackID = "TODO";//extractID ("track", caps);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED("fabricate a Sequence by query");////////////////////////////////////////////////////////////////////////////////////////////TODO
Query<Track> desiredTrack (isnil (trackID)? "" : "id("+trackID+")"); Query<Track> desiredTrack (isnil (trackID)? "" : "id("+trackID+")");
// PTrack track = Session::current->query (desiredTrack); ///////////////////////////////////TICKET #639 // PTrack track = Session::current->query (desiredTrack); ///////////////////////////////////TICKET #639
// TODO: handle the following cases // TODO: handle the following cases

View file

@ -36,7 +36,7 @@
using boost::format; using boost::format;
using lib::Symbol; using lib::Symbol;
using lumiera::query::normaliseID; using lib::query::normaliseID;
using lumiera::query::QueryHandler; using lumiera::query::QueryHandler;
using lumiera::ConfigRules; using lumiera::ConfigRules;

View file

@ -72,7 +72,7 @@ namespace asset {
using std::string; using std::string;
using boost::scoped_ptr; using boost::scoped_ptr;
using lumiera::Query; using lib::Query;
using lib::Symbol; using lib::Symbol;
class Struct; class Struct;

View file

@ -49,10 +49,10 @@
#include <cstdlib> #include <cstdlib>
using lumiera::query::QueryHandler; using lumiera::query::QueryHandler;
using lumiera::query::removeTerm;
using lumiera::query::extractID;
using lumiera::ConfigRules; using lumiera::ConfigRules;
using lumiera::Symbol; using lumiera::Symbol;
using lib::query::removeTerm;
using lib::query::extractID;
namespace proc { namespace proc {
namespace mobject { namespace mobject {
@ -179,7 +179,8 @@ namespace mobject {
uint uint
is_defaults_query_with_channel (Query<asset::Pipe> const& query4pipe) is_defaults_query_with_channel (Query<asset::Pipe> const& query4pipe)
{ {
string seqNr = extractID (SEQNR_PREDICATE, query4pipe); string seqNr = "TODO";//extractID (SEQNR_PREDICATE, query4pipe);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED ("Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
return abs(std::atoi (seqNr.c_str())); // also 0 in case of an invalid number return abs(std::atoi (seqNr.c_str())); // also 0 in case of an invalid number
} }
@ -187,7 +188,8 @@ namespace mobject {
build_corresponding_sourceQuery (Query<asset::Pipe> const& query4pipe) build_corresponding_sourceQuery (Query<asset::Pipe> const& query4pipe)
{ {
Query<asset::Pipe> srcQuery = query4pipe; Query<asset::Pipe> srcQuery = query4pipe;
removeTerm (SEQNR_PREDICATE, srcQuery); // removeTerm (SEQNR_PREDICATE, srcQuery);////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED ("Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
return srcQuery; return srcQuery;
} }
} }

View file

@ -96,7 +96,7 @@ namespace mobject {
}//(End) type rebinding helper }//(End) type rebinding helper
namespace error = lumiera::error; namespace error = lumiera::error;
using lumiera::Query; using lib::Query;
using asset::HashVal; using asset::HashVal;

View file

@ -118,10 +118,11 @@ namespace session {
return res; return res;
else else
res = create (capabilities); // not yet known as default, create new res = create (capabilities); // not yet known as default, create new
UNIMPLEMENTED("String representation of queries, here just for diagnostics");
if (!res) if (!res)
throw lumiera::error::Config (_Fmt("The following Query could not be resolved: %s.") throw lumiera::error::Config (_Fmt("The following Query could not be resolved: %s.")
% capabilities.asKey() % "TODO"//capabilities.asKey()////////////////////////////////////////////////////////////////////////////////////////////TODO
, LUMIERA_ERROR_CAPABILITY_QUERY ); , LUMIERA_ERROR_CAPABILITY_QUERY );
else else
return res; return res;

View file

@ -39,6 +39,7 @@ namespace session {
using lib::P; using lib::P;
using lib::Query;
using boost::scoped_ptr; using boost::scoped_ptr;
namespace impl { class DefsRegistry; } namespace impl { class DefsRegistry; }
@ -73,14 +74,14 @@ namespace session {
* is considered \e misconfiguration. * is considered \e misconfiguration.
*/ */
template<class TAR> template<class TAR>
P<TAR> operator() (lumiera::Query<TAR> const&); P<TAR> operator() (Query<TAR> const&);
/** search through the registered defaults, never create anything. /** search through the registered defaults, never create anything.
* @return object fulfilling the query, \c empty ptr if not found. * @return object fulfilling the query, \c empty ptr if not found.
*/ */
template<class TAR> template<class TAR>
P<TAR> search (lumiera::Query<TAR> const&); P<TAR> search (Query<TAR> const&);
/** retrieve an object fulfilling the query and register it as default. /** retrieve an object fulfilling the query and register it as default.
* The resolution is delegated to the ConfigQuery system (which may cause * The resolution is delegated to the ConfigQuery system (which may cause
@ -88,7 +89,7 @@ namespace session {
* @return object fulfilling the query, \c empty ptr if no solution. * @return object fulfilling the query, \c empty ptr if no solution.
*/ */
template<class TAR> template<class TAR>
P<TAR> create (lumiera::Query<TAR> const&); P<TAR> create (Query<TAR> const&);
/** register the given object as default, after ensuring it fulfils the /** register the given object as default, after ensuring it fulfils the
* query. The latter may cause some properties of the object to be set, * query. The latter may cause some properties of the object to be set,
@ -97,7 +98,7 @@ namespace session {
* @note only a weak ref to the object is stored * @note only a weak ref to the object is stored
*/ */
template<class TAR> template<class TAR>
bool define (P<TAR> const&, lumiera::Query<TAR> const& =lumiera::Query<TAR>()); bool define (P<TAR> const&, Query<TAR> const& =Query<TAR>());
/** remove the defaults registration of the given object, if there was such /** remove the defaults registration of the given object, if there was such
* @return false if nothing has been changed because the object wasn't registered * @return false if nothing has been changed because the object wasn't registered

View file

@ -59,7 +59,7 @@ namespace mobject {
namespace session { namespace session {
using lib::P; using lib::P;
using lumiera::Query; using lib::Query;
using lib::ClassLock; using lib::ClassLock;
using std::tr1::weak_ptr; using std::tr1::weak_ptr;
@ -97,10 +97,12 @@ namespace session {
weak_ptr<TAR> objRef; weak_ptr<TAR> objRef;
Record (const Query<TAR>& q, const P<TAR>& obj) Record (const Query<TAR>& q, const P<TAR>& obj)
: degree (lumiera::query::countPred (q)), : degree (lib::query::countPred ("TODO")),//q)),////////////////////////////////////////////////////////////////////////////////////////////TODO
query (q), query (q),
objRef (obj) objRef (obj)
{ } {
UNIMPLEMENTED("Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
}
struct Search ///< Functor searching for a specific object struct Search ///< Functor searching for a specific object
@ -123,8 +125,9 @@ namespace session {
inline bool inline bool
operator() (Record one, Record two) ///< @note doesn't touch the objRef operator() (Record one, Record two) ///< @note doesn't touch the objRef
{ {
UNIMPLEMENTED ("arbitrary total ordering of queries");
return ( one.degree < two.degree return ( one.degree < two.degree
||(one.degree == two.degree && one.query < two.query) ||(one.degree == two.degree && false)//one.query < two.query)////////////////////////////////////////////////////////////////////////////////////////////TODO
); );
} }
}; };

View file

@ -148,7 +148,7 @@ namespace session {
LocatingPin::LocatingSolution::getPipe() LocatingPin::LocatingSolution::getPipe()
{ {
TODO ("implement Placement LocatingSolution"); TODO ("implement Placement LocatingSolution");
return asset::Pipe::query ("pipe(master)"); // yet another idiotic dummy return asset::Pipe::query (lib::Query<asset::Pipe>("pipe(master)")); // yet another idiotic dummy
} }

View file

@ -39,6 +39,10 @@ namespace session {
using boost::scoped_ptr; using boost::scoped_ptr;
using lib::Goal;
using lib::Query;
using lib::Resolution;
using lib::getResultTypeID;
typedef PlacementIndex::ID PID; typedef PlacementIndex::ID PID;
@ -190,7 +194,7 @@ namespace session {
* there is a smart-ptr managing this ResultSet. * there is a smart-ptr managing this ResultSet.
*/ */
class ResultSet class ResultSet
: public Resolution : public lib::Resolution
{ {
ContentFilter acceptable_; ContentFilter acceptable_;
ExplorerBuilder buildExploartion_; ExplorerBuilder buildExploartion_;

View file

@ -87,7 +87,7 @@ namespace session {
* * more generally, any ScopeQuery with these properties, in some variations * * more generally, any ScopeQuery with these properties, in some variations
*/ */
class PlacementIndexQueryResolver class PlacementIndexQueryResolver
: public session::QueryResolver : public lib::QueryResolver
{ {
function<IndexLink> _getIndex; function<IndexLink> _getIndex;
@ -106,7 +106,7 @@ namespace session {
void defineHandling(); void defineHandling();
template<typename MO> template<typename MO>
Resolution* resolutionFunction (Goal const& goal); lib::Resolution* resolutionFunction (Goal const& goal);
public: public:

View file

@ -21,7 +21,7 @@
* *****************************************************/ * *****************************************************/
#include "common/query/fake-configrules.hpp" #include "proc/mobject/session/query/fake-configrules.hpp"
#include "proc/mobject/session.hpp" #include "proc/mobject/session.hpp"
#include "proc/mobject/session/track.hpp" #include "proc/mobject/session/track.hpp"
@ -31,13 +31,17 @@
#include "include/logging.h" #include "include/logging.h"
#include "lib/symbol.hpp"
#include "lib/util.hpp" #include "lib/util.hpp"
using lib::Literal;
using util::isnil; using util::isnil;
//////////////////////////////////////////////////////////////////TICKET #710 : to be removed entirely in Alpha //////////////////////////////////////////////////////////////////TICKET #710 : to be removed entirely in Alpha
namespace lumiera { namespace proc {
namespace mobject {
namespace session {
namespace query { namespace query {
@ -49,7 +53,7 @@ namespace lumiera {
using asset::PProcPatt; using asset::PProcPatt;
// using lumiera::query::extractID; // using lumiera::query::extractID;
using lumiera::query::removeTerm; using lib::query::removeTerm;
namespace { namespace {
@ -58,9 +62,10 @@ namespace lumiera {
/** helper to simplify creating mock table entries, wrapped correctly */ /** helper to simplify creating mock table entries, wrapped correctly */
template<class TY> template<class TY>
AnyPair entry (const string& query, typename WrapReturn<TY>::Wrapper& obj) AnyPair entry (Query<TY> const& query, typename WrapReturn<TY>::Wrapper& obj)
{ {
return AnyPair ( Query<TY> (query).asKey() UNIMPLEMENTED ("generic query-key");////////////////////////////////////////////////////////////////////////////////////////////TODO
return AnyPair ( "TODO"//Query<TY> (query).asKey()////////////////////////////////////////////////////////////////////////////////////////////TODO
, any(obj)); , any(obj));
} }
@ -73,7 +78,8 @@ namespace lumiera {
string capabilities (caps); string capabilities (caps);
Query<STRU> query (capabilities); Query<STRU> query (capabilities);
Ptr obj = Struct::retrieve (query); Ptr obj = Struct::retrieve (query);
return AnyPair(query.asKey(), obj); UNIMPLEMENTED("generic query-key");
// return AnyPair(query.asKey(), obj);////////////////////////////////////////////////////////////////////////////////////////////TODO
} }
/** shortcut for simply accessing a table entry */ /** shortcut for simply accessing a table entry */
@ -81,7 +87,8 @@ namespace lumiera {
any& any&
item (PTAB& table, const string& query) item (PTAB& table, const string& query)
{ {
return (*table)[Query<STRU>(query).asKey()]; UNIMPLEMENTED ("generic Query-key");////////////////////////////////////////////////////////////////////////////////////////////TODO
//return (*table)[Query<STRU>(query).asKey()];////////////////////////////////////////////////////////////////////////////////////////////TODO
} }
} }
@ -162,13 +169,14 @@ namespace lumiera {
{ {
typedef asset::Timeline aTl; typedef asset::Timeline aTl;
typedef WrapReturn<aTl>::Wrapper Ptr; typedef WrapReturn<aTl>::Wrapper Ptr;
string nameID = removeTerm ("id", query); UNIMPLEMENTED ("generic query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
string nameID = "TODO";//removeTerm ("id", query);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
nameID = removeTerm ("timeline", query); nameID = "TODO";//removeTerm ("timeline", query);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
nameID = "prime"; nameID = "prime";
query.insert (0, "id("+nameID+"), "); // query.insert (0, "id("+nameID+"), ");
// try to find an existing one with the desired id // try to find an existing one with the desired id
Ptr newTimeline; Ptr newTimeline;
@ -193,13 +201,14 @@ namespace lumiera {
{ {
typedef asset::Sequence aSq; typedef asset::Sequence aSq;
typedef WrapReturn<aSq>::Wrapper Ptr; typedef WrapReturn<aSq>::Wrapper Ptr;
string nameID = removeTerm ("id", query); UNIMPLEMENTED ("generic Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
string nameID = "TODO";//removeTerm ("id", query);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
nameID = removeTerm ("sequence", query); nameID = "TODO";//removeTerm ("sequence", query);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (isnil (nameID)) if (isnil (nameID))
nameID = "first"; nameID = "first";
query.insert (0, "id("+nameID+"), "); // query.insert (0, "id("+nameID+"), ");
// try to find an existing sequence with the desired id // try to find an existing sequence with the desired id
Ptr newSequence; Ptr newSequence;
@ -224,7 +233,8 @@ namespace lumiera {
bool bool
MockTable::set_new_mock_solution (Query<TY>& q, typename WrapReturn<TY>::Wrapper& obj) MockTable::set_new_mock_solution (Query<TY>& q, typename WrapReturn<TY>::Wrapper& obj)
{ {
answer_->erase (q.asKey()); UNIMPLEMENTED ("generic query-key");////////////////////////////////////////////////////////////////////////////////////////////TODO
// answer_->erase (q.asKey());////////////////////////////////////////////////////////////////////////////////////////////TODO
answer_->insert (entry<TY> (q, obj)); answer_->insert (entry<TY> (q, obj));
return true; return true;
} }
@ -275,5 +285,4 @@ namespace lumiera {
} // namespace query } // namespace query
}}} // namespace proc::mobject::session
} // namespace lumiera

View file

@ -37,8 +37,8 @@
*/ */
#ifndef LUMIERA_FAKECONFIGRULES_H #ifndef MOBJECT_SESSION_QUERY_FAKECONFIGRULES_H
#define LUMIERA_FAKECONFIGRULES_H #define MOBJECT_SESSION_QUERY_FAKECONFIGRULES_H
#include "proc/mobject/session.hpp" #include "proc/mobject/session.hpp"
#include "common/configrules.hpp" #include "common/configrules.hpp"
@ -51,7 +51,9 @@
namespace lumiera { namespace proc {
namespace mobject {
namespace session {
namespace query { namespace query {
namespace asset = proc::asset; namespace asset = proc::asset;
@ -62,6 +64,11 @@ namespace lumiera {
using proc::mobject::Session; using proc::mobject::Session;
using lib::meta::InstantiateChained; using lib::meta::InstantiateChained;
using lib::Query;
using lib::query::removeTerm; //////////////TODO better use Query::Builder
using lib::query::extractID; ///////////////TODO dto
using lumiera::query::isFakeBypass; /////////TODO placeholder until there is a real resolution engine
using util::contains; using util::contains;
using util::isnil; using util::isnil;
@ -144,7 +151,7 @@ namespace lumiera {
virtual bool virtual bool
resolve (Ret& solution, Query<TY> const& q) resolve (Ret& solution, Query<TY> const& q)
{ {
const any& entry = this->fetch_from_table_for (q.asKey()); const any& entry = this->fetch_from_table_for ("TODO");//q.asKey());////////////////////////////////////////////////////////////////////////////////////////////TODO
if (!isnil (entry)) if (!isnil (entry))
{ {
Ret const& candidate (any_cast<Ret const&> (entry)); Ret const& candidate (any_cast<Ret const&> (entry));
@ -160,10 +167,10 @@ namespace lumiera {
bool bool
try_special_case (Ret& solution, Query<TY> const& q) try_special_case (Ret& solution, Query<TY> const& q)
{ {
if (solution && isFakeBypass(q)) // backdoor for tests if (true)//solution && isFakeBypass(q)) // backdoor for tests////////////////////////////////////////////////////////////////////////////////////////////TODO
return solution; return solution;
string querySpec (q); string querySpec ;//(q);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (treat_as_defaults_query (querySpec)) if (treat_as_defaults_query (querySpec))
{ {
Query<TY> defaultsQuery(querySpec); Query<TY> defaultsQuery(querySpec);
@ -184,19 +191,19 @@ namespace lumiera {
inline bool inline bool
MockTable::detect_case (typename WrapReturn<TY>::Wrapper&, Query<TY>& q) MockTable::detect_case (typename WrapReturn<TY>::Wrapper&, Query<TY>& q)
{ {
q.clear(); // end recursion // q.clear(); // end recursion////////////////////////////////////////////////////////////////////////////////////////////TODO
return false; return false;
} }
template<> template<>
inline bool inline bool
MockTable::detect_case (WrapReturn<Pipe>::Wrapper& candidate, Query<Pipe>& q) MockTable::detect_case (WrapReturn<Pipe>::Wrapper& candidate, Query<Pipe>& q)
{ {
if (!isnil (extractID("make", q))) if (true)//!isnil (extractID("make", q)))////////////////////////////////////////////////////////////////////////////////////////////TODO
// used by tests to force fabrication of a new "solution" // used by tests to force fabrication of a new "solution"
return fabricate_just_new_Pipe (q); return fabricate_just_new_Pipe (q);
const string pipeID = extractID("pipe", q); const string pipeID = "TODO";//extractID("pipe", q);////////////////////////////////////////////////////////////////////////////////////////////TODO
const string streamID = extractID("stream", q); const string streamID = "TODO";//extractID("stream", q);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (candidate && pipeID == candidate->getPipeID()) if (candidate && pipeID == candidate->getPipeID())
return set_new_mock_solution (q, candidate); // "learn" this solution to be "valid" return set_new_mock_solution (q, candidate); // "learn" this solution to be "valid"
@ -207,19 +214,19 @@ namespace lumiera {
if (!candidate && (!isnil(streamID) || !isnil(pipeID))) if (!candidate && (!isnil(streamID) || !isnil(pipeID)))
return fabricate_just_new_Pipe (q); return fabricate_just_new_Pipe (q);
q.clear(); // q.clear();////////////////////////////////////////////////////////////////////////////////////////////TODO
return false; return false;
} }
template<> template<>
inline bool inline bool
MockTable::detect_case (WrapReturn<const ProcPatt>::Wrapper& candidate, Query<const ProcPatt>& q) MockTable::detect_case (WrapReturn<const ProcPatt>::Wrapper& candidate, Query<const ProcPatt>& q)
{ {
const string streamID = extractID("stream", q); const string streamID = "TODO";//extractID("stream", q);////////////////////////////////////////////////////////////////////////////////////////////TODO
if (!candidate && !isnil(streamID)) if (!candidate && !isnil(streamID))
return fabricate_ProcPatt_on_demand (q); return fabricate_ProcPatt_on_demand (q);
q.clear(); // q.clear();////////////////////////////////////////////////////////////////////////////////////////////TODO
return false; return false;
} }
template<> template<>
@ -229,7 +236,7 @@ namespace lumiera {
if (!candidate) if (!candidate)
return fabricate_Timeline_on_demand (q); return fabricate_Timeline_on_demand (q);
q.clear(); // q.clear();////////////////////////////////////////////////////////////////////////////////////////////TODO
return bool(candidate); return bool(candidate);
} }
template<> template<>
@ -239,7 +246,7 @@ namespace lumiera {
if (!candidate) if (!candidate)
return fabricate_Sequence_on_demand (q); return fabricate_Sequence_on_demand (q);
q.clear(); // q.clear();////////////////////////////////////////////////////////////////////////////////////////////TODO
return bool(candidate); return bool(candidate);
} }
@ -254,7 +261,7 @@ namespace lumiera {
* values for some types of interest for testing and debugging. * values for some types of interest for testing and debugging.
*/ */
class MockConfigRules class MockConfigRules
: public InstantiateChained < InterfaceTypes : public InstantiateChained < lumiera::InterfaceTypes
, LookupPreconfigured // building block used for each of the types , LookupPreconfigured // building block used for each of the types
, MockTable // for implementing the base class (interface) , MockTable // for implementing the base class (interface)
> >
@ -272,6 +279,6 @@ namespace lumiera {
} // namespace query
}} // namespace lumiera::query }}} // namespace proc::mobject::session
#endif #endif

View file

@ -97,7 +97,7 @@ namespace session {
friend class lib::singleton::StaticCreate<ScopeLocator>; friend class lib::singleton::StaticCreate<ScopeLocator>;
private: private:
QueryResolver const& theResolver(); lib::QueryResolver const& theResolver();
}; };

View file

@ -56,6 +56,9 @@ namespace session {
using std::tr1::function; using std::tr1::function;
using std::tr1::placeholders::_1; using std::tr1::placeholders::_1;
using lib::Goal;
using lib::Query;
/** /**

View file

@ -119,7 +119,7 @@ namespace session {
* of contents discovery queries to the PlacementIndex * of contents discovery queries to the PlacementIndex
* managed within the session * managed within the session
*/ */
QueryResolver const& lib::QueryResolver const&
ScopeLocator::theResolver() ScopeLocator::theResolver()
{ {
return SessionServiceExploreScope::getResolver(); return SessionServiceExploreScope::getResolver();

View file

@ -126,7 +126,7 @@ namespace session {
REQUIRE (0 == session_->timelines.size(), "injecting default timeline, but session isn't pristine"); REQUIRE (0 == session_->timelines.size(), "injecting default timeline, but session isn't pristine");
// issue a default query to retrieve or create a Timeline and a default Sequence // issue a default query to retrieve or create a Timeline and a default Sequence
asset::PTimeline initialTimeline = session_->defaults (lumiera::Query<asset::Timeline> ()); asset::PTimeline initialTimeline = session_->defaults (lib::Query<asset::Timeline> ());
// these got registered automatically // these got registered automatically
ENSURE (1 == session_->timelines.size()); ENSURE (1 == session_->timelines.size());

View file

@ -68,7 +68,7 @@ namespace session {
*/ */
struct SessionServiceExploreScope struct SessionServiceExploreScope
{ {
static QueryResolver const& getResolver(); static lib::QueryResolver const& getResolver();
static PlacementMO& getScope (PlacementMO const&); static PlacementMO& getScope (PlacementMO const&);
static PlacementMO& getScope (PlacementMO::ID const&); static PlacementMO& getScope (PlacementMO::ID const&);

View file

@ -37,6 +37,8 @@ namespace session {
using std::tr1::function; using std::tr1::function;
using lib::QueryResolver;
/** /**
* Specialised version of the ContentsQuery to pick some objects * Specialised version of the ContentsQuery to pick some objects

View file

@ -124,8 +124,8 @@ namespace play {
using asset::PTimeline; using asset::PTimeline;
using mobject::ModelPort; using mobject::ModelPort;
using mobject::builder::ModelPortRegistry; using mobject::builder::ModelPortRegistry;
using lumiera::Query;
using util::contains; using util::contains;
using lib::Query;
// using lib::ScopedCollection; // using lib::ScopedCollection;
// using lib::Literal; // using lib::Literal;
using lib::eachEntry; using lib::eachEntry;
@ -139,7 +139,7 @@ namespace play {
inline PID inline PID
getPipe (string id) getPipe (string id)
{ {
return Pipe::query("id("+id+")"); return Pipe::query (Query<Pipe> ("id("+id+")"));
} }
inline TID inline TID

View file

@ -47,8 +47,8 @@ namespace asset {
namespace test { namespace test {
using mobject::Session; using mobject::Session;
using lumiera::Query; using lib::Query;
using lumiera::query::normaliseID; using lib::query::normaliseID;
@ -107,19 +107,19 @@ namespace test {
{ {
normaliseID (pID); normaliseID (pID);
PPipe pipe1 = Pipe::query ("pipe("+pID+")"); PPipe pipe1 = Pipe::query (Query<Pipe> ("pipe("+pID+")"));
CHECK (pipe1); CHECK (pipe1);
CHECK (pipe1->getPipeID() == pID); CHECK (pipe1->getPipeID() == pID);
string pID2 = "another-" + pID; string pID2 = "another-" + pID;
PPipe pipe2 = Pipe::query ("pipe("+pID2+")"); PPipe pipe2 = Pipe::query (Query<Pipe> ("pipe("+pID2+")"));
CHECK (pipe2); CHECK (pipe2);
CHECK (pipe2 != pipe1); CHECK (pipe2 != pipe1);
Category c1 = pipe1->ident.category; Category c1 = pipe1->ident.category;
Category c2 = pipe2->ident.category; Category c2 = pipe2->ident.category;
CHECK (c1 == c2); CHECK (c1 == c2);
PPipe pipe3 = Pipe::query ("pipe("+pID2+")"); PPipe pipe3 = Pipe::query (Query<Pipe> ("pipe("+pID2+")"));
//////////////////////////////////////////////////////////////TODO: that's broken; creating a new one instead to find the existing one, as it should be //////////////////////////////////////////////////////////////TODO: that's broken; creating a new one instead to find the existing one, as it should be
CHECK (pipe3 == pipe2); CHECK (pipe3 == pipe2);
} }
@ -127,7 +127,7 @@ namespace test {
void create_using_default() void create_using_default()
{ {
PPipe pipe1 = Pipe::query (""); // "the default pipe" PPipe pipe1 = Pipe::query (Query<Pipe>("")); // "the default pipe"
PPipe pipe2; PPipe pipe2;
CHECK (pipe1); CHECK (pipe1);
CHECK (pipe1 == Session::current->defaults (Query<Pipe>())); CHECK (pipe1 == Session::current->defaults (Query<Pipe>()));
@ -145,7 +145,7 @@ namespace test {
CHECK (pipe2 == pipe1); CHECK (pipe2 == pipe1);
string sID = pipe1->getStreamID(); // sort of a "default stream type" string sID = pipe1->getStreamID(); // sort of a "default stream type"
PPipe pipe3 = Pipe::query ("stream("+sID+")"); PPipe pipe3 = Pipe::query (Query<Pipe> ("stream("+sID+")"));
CHECK (pipe3); CHECK (pipe3);
CHECK (pipe3->getStreamID() == StreamType::ID(sID)); CHECK (pipe3->getStreamID() == StreamType::ID(sID));
CHECK (pipe3->getProcPatt() == Session::current->defaults (Query<const ProcPatt>("stream("+sID+")"))); CHECK (pipe3->getProcPatt() == Session::current->defaults (Query<const ProcPatt>("stream("+sID+")")));
@ -157,7 +157,7 @@ namespace test {
typedef P<Pipe> PPipe; /////TODO: transition to P<> typedef P<Pipe> PPipe; /////TODO: transition to P<>
typedef P<const ProcPatt> PProcPatt; typedef P<const ProcPatt> PProcPatt;
PPipe thePipe = Pipe::query ("pipe("+pID+")"); PPipe thePipe = Pipe::query (Query<Pipe> ("pipe("+pID+")"));
CHECK (thePipe); CHECK (thePipe);
PProcPatt thePatt = thePipe->getProcPatt(); PProcPatt thePatt = thePipe->getProcPatt();
CHECK (thePatt); CHECK (thePatt);
@ -171,7 +171,7 @@ namespace test {
// now querying for a pipe using this pattern (created on-the-fly) // now querying for a pipe using this pattern (created on-the-fly)
// note: because the pattern is new, this new pipe will be used as // note: because the pattern is new, this new pipe will be used as
// default pipe for this pattern automatically // default pipe for this pattern automatically
PPipe pipe2x = Pipe::query ("pattern(another)"); PPipe pipe2x = Pipe::query (Query<Pipe> ("pattern(another)"));
CHECK (pattern2 == pipe2x->getProcPatt()); CHECK (pattern2 == pipe2x->getProcPatt());
CHECK (pipe2x == Session::current->defaults (Query<Pipe>("pattern(another)"))); CHECK (pipe2x == Session::current->defaults (Query<Pipe>("pattern(another)")));
@ -193,7 +193,7 @@ namespace test {
CHECK (thePipe->getProcPatt()); CHECK (thePipe->getProcPatt());
CHECK ( pattern3 == pattern2); // but is still valid, as long as the ref is alive.... CHECK ( pattern3 == pattern2); // but is still valid, as long as the ref is alive....
PPipe pipe3x = Pipe::query ("pattern(another)"); PPipe pipe3x = Pipe::query (Query<Pipe> ("pattern(another)"));
pattern3 = pipe3x->getProcPatt(); /////TODO: transition to P<> pattern3 = pipe3x->getProcPatt(); /////TODO: transition to P<>
CHECK (pattern3 != pattern2); // because pattern2 is already unlinked... CHECK (pattern3 != pattern2); // because pattern2 is already unlinked...
CHECK (pipe3x == Session::current->defaults (Query<Pipe>("pattern(another)"))); CHECK (pipe3x == Session::current->defaults (Query<Pipe>("pattern(another)")));

View file

@ -91,7 +91,7 @@ namespace test {
EngineService& engine = EngineService::instance(); EngineService& engine = EngineService::instance();
EngineDiagnostics monitor(engine); EngineDiagnostics monitor(engine);
PID pipe = Pipe::query("id(dummy)"); PID pipe = Pipe::query(lib::Query<Pipe> ("id(dummy)"));
ModelPort port(pipe); ModelPort port(pipe);
OutputSlot& oSlot = DiagnosticOutputSlot::build(); OutputSlot& oSlot = DiagnosticOutputSlot::build();

View file

@ -43,7 +43,7 @@ namespace test {
using asset::Struct; using asset::Struct;
using asset::Timeline; using asset::Timeline;
using asset::PTimeline; using asset::PTimeline;
using lumiera::Query; using lib::Query;
// //
typedef asset::ID<Pipe> PID; typedef asset::ID<Pipe> PID;
typedef asset::ID<Struct> TID; typedef asset::ID<Struct> TID;
@ -56,7 +56,7 @@ namespace test {
inline PID inline PID
getPipe (string id) getPipe (string id)
{ {
return Pipe::query("id("+id+")"); return Pipe::query (Query<Pipe> ("id("+id+")"));
} }
inline TID inline TID

View file

@ -43,7 +43,7 @@ namespace test {
using asset::Struct; using asset::Struct;
using asset::Timeline; using asset::Timeline;
using asset::PTimeline; using asset::PTimeline;
using lumiera::Query; using lib::Query;
typedef asset::ID<Pipe> PID; typedef asset::ID<Pipe> PID;
typedef asset::ID<Struct> TID; typedef asset::ID<Struct> TID;
@ -56,7 +56,7 @@ namespace test {
inline PID inline PID
getPipe (string id) getPipe (string id)
{ {
return Pipe::query("id("+id+")"); return Pipe::query (Query<Pipe> ("id("+id+")"));
} }
inline TID inline TID

View file

@ -43,7 +43,7 @@ namespace test {
using asset::Struct; using asset::Struct;
using asset::Timeline; using asset::Timeline;
using asset::PTimeline; using asset::PTimeline;
using lumiera::Query; using lib::Query;
// //
typedef asset::ID<Pipe> PID; typedef asset::ID<Pipe> PID;
typedef asset::ID<Struct> TID; typedef asset::ID<Struct> TID;
@ -56,7 +56,7 @@ namespace test {
inline PID inline PID
getPipe (string id) getPipe (string id)
{ {
return Pipe::query("id("+id+")"); return Pipe::query (Query<Pipe> ("id("+id+")"));
} }
inline TID inline TID

View file

@ -98,9 +98,9 @@ namespace test {
Mapping map; Mapping map;
CHECK (isnil (map)); CHECK (isnil (map));
PPipe p1 = Pipe::query("id(hairy)"); PPipe p1 = Pipe::query(Query<Pipe> ("id(hairy)"));
PPipe p2 = Pipe::query("id(furry)"); PPipe p2 = Pipe::query(Query<Pipe> ("id(furry)"));
PPipe pX = Pipe::query("id(curly)"); PPipe pX = Pipe::query(Query<Pipe> ("id(curly)"));
map[p1] = p2; map[p1] = p2;
CHECK (!isnil (map)); CHECK (!isnil (map));
@ -125,9 +125,9 @@ namespace test {
{ {
Mapping m1; Mapping m1;
PPipe p1 = Pipe::query("id(hairy)"); PPipe p1 = Pipe::query(Query<Pipe> ("id(hairy)"));
PPipe p2 = Pipe::query("id(furry)"); PPipe p2 = Pipe::query(Query<Pipe> ("id(furry)"));
PPipe pi = Pipe::query("id(nappy)"); PPipe pi = Pipe::query(Query<Pipe> ("id(nappy)"));
m1[pi] = p1; m1[pi] = p1;
Mapping m2(m1); Mapping m2(m1);
@ -158,8 +158,8 @@ namespace test {
Mapping map; Mapping map;
CHECK (isnil (map)); CHECK (isnil (map));
PPipe p1 = Pipe::query("stream(hairy)"); PPipe p1 = Pipe::query(Query<Pipe> ("stream(hairy)"));
PPipe p2 = Pipe::query("stream(furry)"); PPipe p2 = Pipe::query(Query<Pipe> ("stream(furry)"));
CHECK (map[p1] == "master_hairy"); CHECK (map[p1] == "master_hairy");
CHECK (map[p2] == "master_furry"); CHECK (map[p2] == "master_furry");

View file

@ -45,13 +45,13 @@ namespace session {
namespace test { namespace test {
using lib::Symbol; using lib::Symbol;
using lib::Query;
using lib::query::normaliseID;
using asset::Asset; using asset::Asset;
using asset::AssetManager; using asset::AssetManager;
using asset::Pipe; using asset::Pipe;
using asset::PPipe; using asset::PPipe;
using asset::Struct; using asset::Struct;
using lumiera::Query;
using lumiera::query::normaliseID;
using lumiera::ConfigRules; using lumiera::ConfigRules;
using lumiera::query::QueryHandler; using lumiera::query::QueryHandler;
@ -154,7 +154,7 @@ lumiera::query::setFakeBypass("stream("+sID+")"); //////////////////////////////
void void
forget (string pID) forget (string pID)
{ {
PPipe pipe = Pipe::query ("pipe("+pID+")"); PPipe pipe = Pipe::query (Query<Pipe> ("pipe("+pID+")"));
REQUIRE (find (pipe->getPipeID()), "test assumes pre-registered default pipe"); REQUIRE (find (pipe->getPipeID()), "test assumes pre-registered default pipe");
long cnt = pipe.use_count(); long cnt = pipe.use_count();

View file

@ -54,8 +54,8 @@ namespace test {
using asset::Pipe; using asset::Pipe;
using asset::PPipe; using asset::PPipe;
using asset::Struct; using asset::Struct;
using lumiera::Query; using lib::Query;
using lumiera::query::normaliseID; using lib::query::normaliseID;
/** shortcut: run just a query /** shortcut: run just a query
@ -103,13 +103,13 @@ namespace test {
void void
retrieveSimpleDefault (string) retrieveSimpleDefault (string)
{ {
PPipe pipe1 = Pipe::query (""); // "the default pipe" PPipe pipe1 = Pipe::query (Query<Pipe> ("")); // "the default pipe"
PPipe pipe2; PPipe pipe2;
// several variants to query for "the default pipe" // several variants to query for "the default pipe"
pipe2 = Pipe::query (""); pipe2 = Pipe::query (Query<Pipe> (""));
CHECK (pipe2 == pipe1); CHECK (pipe2 == pipe1);
pipe2 = Pipe::query ("default(X)"); pipe2 = Pipe::query (Query<Pipe> ("default(X)"));
CHECK (pipe2 == pipe1); CHECK (pipe2 == pipe1);
pipe2 = Session::current->defaults(Query<Pipe> ()); pipe2 = Session::current->defaults(Query<Pipe> ());
CHECK (pipe2 == pipe1); CHECK (pipe2 == pipe1);
@ -123,7 +123,7 @@ namespace test {
void void
retrieveConstrainedDefault (string pID, string sID) retrieveConstrainedDefault (string pID, string sID)
{ {
PPipe pipe1 = Pipe::query (""); // "the default pipe" PPipe pipe1 = Pipe::query (Query<Pipe> ("")); // "the default pipe"
CHECK ( pipe1->getStreamID() != StreamType::ID(sID), CHECK ( pipe1->getStreamID() != StreamType::ID(sID),
"stream-ID \"%s\" not suitable for test, because " "stream-ID \"%s\" not suitable for test, because "
"the default-pipe \"%s\" happens to have the same " "the default-pipe \"%s\" happens to have the same "
@ -132,10 +132,10 @@ namespace test {
); );
string query_for_sID ("stream("+sID+")"); string query_for_sID ("stream("+sID+")");
PPipe pipe2 = Pipe::query (query_for_sID); PPipe pipe2 = Pipe::query (Query<Pipe> (query_for_sID));
CHECK (pipe2->getStreamID() == StreamType::ID(sID)); CHECK (pipe2->getStreamID() == StreamType::ID(sID));
CHECK (pipe2 != pipe1); CHECK (pipe2 != pipe1);
CHECK (pipe2 == Pipe::query (query_for_sID)); // reproducible CHECK (pipe2 == Pipe::query (Query<Pipe> (query_for_sID))); // reproducible
} }

View file

@ -34,8 +34,8 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include <map> #include <map>
using lumiera::Query; using lib::Query;
using lumiera::query::test::garbage_query; using lib::query::test::garbage_query;
using util::isnil; using util::isnil;
using lib::P; using lib::P;
@ -165,9 +165,11 @@ namespace test {
{ {
Prd px (fabricate<23>()); Prd px (fabricate<23>());
Q23 qx (garbage_query()); Q23 qx (garbage_query());
ps[qx] = px; UNIMPLEMENTED ("generic query key and ordering for map access");////////////////////////////////////////////////////////////////////////////////////////////TODO
// ps[qx] = px;
reg_->put (px, qx); reg_->put (px, qx);
px->instanceID = qx; UNIMPLEMENTED ("Query building from predicate string");////////////////////////////////////////////////////////////////////////////////////////////TODO
// px->instanceID = qx;////////////////////////////////////////////////////////////////////////////////////////////TODO
} }
} }
@ -213,8 +215,10 @@ namespace test {
{ {
CHECK ( *j ); CHECK ( *j );
Q23 qx ((*j)->instanceID); Q23 qx ((*j)->instanceID);
CHECK ( ps[qx] == (*j)); UNIMPLEMENTED ("generic query key and ordering for map access");////////////////////////////////////////////////////////////////////////////////////////////TODO
d = lumiera::query::countPred (qx); // CHECK ( ps[qx] == (*j));////////////////////////////////////////////////////////////////////////////////////////////TODO
UNIMPLEMENTED ("Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO
// d = lib::query::countPred (qx);////////////////////////////////////////////////////////////////////////////////////////////TODO
CHECK ( d_prev <= d ); CHECK ( d_prev <= d );
d_prev = d; d_prev = d;
} }

View file

@ -39,6 +39,7 @@ namespace mobject {
namespace session { namespace session {
namespace test { namespace test {
using lib::QueryResolver;
using session::PathQuery; using session::PathQuery;
using session::ContentsQuery; using session::ContentsQuery;
using util::isSameObject; using util::isSameObject;

View file

@ -31,10 +31,8 @@
namespace proc { namespace lib {
namespace mobject { namespace test{
namespace session {
namespace test {
using lib::test::showSizeof; using lib::test::showSizeof;
using std::string; using std::string;
@ -223,4 +221,4 @@ namespace test {
LAUNCHER (QueryResolver_test, "unit session"); LAUNCHER (QueryResolver_test, "unit session");
}}}} // namespace proc::mobject::session::test }} // namespace lib::test

View file

@ -84,7 +84,7 @@ namespace test {
using lumiera::Query; using lib::Query;
using asset::Timeline; using asset::Timeline;
using asset::PTimeline; using asset::PTimeline;
using asset::AssetManager; using asset::AssetManager;

View file

@ -58,7 +58,7 @@ namespace test {
using asset::PSequence; using asset::PSequence;
using asset::Sequence; using asset::Sequence;
using lumiera::Query; using lib::Query;
typedef MORef<session::Clip> RClip; typedef MORef<session::Clip> RClip;
typedef PlacementMO::ID PID; typedef PlacementMO::ID PID;

View file

@ -55,7 +55,7 @@ namespace test {
using asset::PSequence; using asset::PSequence;
using asset::Pipe; using asset::Pipe;
using lumiera::Query; using lib::Query;
/******************************************************************************** /********************************************************************************

View file

@ -32,7 +32,7 @@
#include <tr1/functional> #include <tr1/functional>
#include <iostream> #include <iostream>
using lumiera::Query; using lib::Query;
using lib::Cmdline; using lib::Cmdline;
using util::isnil; using util::isnil;
using util::contains; using util::contains;
@ -46,7 +46,7 @@ using std::endl;
namespace lumiera { namespace lib {
namespace query { namespace query {
namespace test{ namespace test{
@ -83,7 +83,8 @@ namespace test{
void void
check_Query () check_Query ()
{ {
cout << Query<Thing> ("I am writing a test sentence.").asKey() << endl; UNIMPLEMENTED ("generate a generic query key");////////////////////////////////////////////////////////////////////////////////////////////TODO
// cout << Query<Thing> ("I am writing a test sentence.").asKey() << endl;////////////////////////////////////////////////////////////////////////////////////////////TODO
} }
@ -166,4 +167,4 @@ namespace test{
}}} // namespace lumiera::query::test }}} // namespace lib::query::test

View file

@ -21,65 +21,56 @@
*/ */
#ifndef LUMIERA_TEST_QUERY_QUERYDIAGNOSTICS_H #ifndef LIB_QUERY_TEST_QUERYDIAGNOSTICS_H
#define LUMIERA_TEST_QUERY_QUERYDIAGNOSTICS_H #define LIB_QUERY_TEST_QUERYDIAGNOSTICS_H
#include <boost/format.hpp> #include "lib/format-string.hpp"
using boost::format; using util::_Fmt;
using std::string; using std::string;
using std::rand; using std::rand;
namespace lumiera namespace lib {
{ namespace query{
namespace query namespace test {
{
namespace test
{
namespace // implementation constants
{
format predicatePatt ("%s_%2i( %s )");
const string garbage ("asdfghjklqwertzuiop");
const uint MAX_DEGREE_RAND = 9; namespace {// implementation constants
}
inline string
garbage_term () ///< yields a random string of 3 letters
{
return str (predicatePatt
% char ('a'+ rand() % 26)
% (rand() % 100)
% garbage.substr(rand() % 17 , 3)
);
}
inline string
garbage_query (int degree=0) ///< fabricating (random) query strings
{
string fake;
if (!degree)
degree = 1 + rand() % MAX_DEGREE_RAND;
while (0 < --degree)
fake += garbage_term() + ", ";
fake += garbage_term() + ".";
return fake;
}
} // namespace test
} // namespace query _Fmt predicatePattern ("%s_%2i( %s )");
const string garbage ("asanisimasabibeddiboom");
} // namespace lumiera
const uint MAX_DEGREE_RAND = 9;
}
inline string
garbage_term () ///< yields a random string of 3 letters
{
return predicatePattern
% char ('a'+ rand() % 26)
% (rand() % 100)
% garbage.substr(rand() % 19 , 3);
}
inline string
garbage_query (int degree=0) ///< fabricating (random) query strings
{
string fake;
if (!degree)
degree = 1 + rand() % MAX_DEGREE_RAND;
while (0 < --degree)
fake += garbage_term() + ", ";
fake += garbage_term() + ".";
return fake;
}
}}} // namespace lib::query::test
#endif #endif

View file

@ -42,6 +42,8 @@ using std::tr1::bind;
using util::isnil; using util::isnil;
using util::cStr; using util::cStr;
using test::Test; using test::Test;
using lib::Literal;
using lib::query::extractID;
using backend::Thread; using backend::Thread;
@ -50,7 +52,7 @@ namespace test {
namespace { // private test classes and data... namespace { // private test classes and data...
using query::extractID; using lib::query::extractID;
/** limit for the randomly selected duration of /** limit for the randomly selected duration of
* subsystem's running phase (milliseconds) */ * subsystem's running phase (milliseconds) */