now complete and passing the compiler

This commit is contained in:
Fischlurch 2008-04-07 03:19:24 +02:00
parent 3ed3813be3
commit b86a8605e7
6 changed files with 61 additions and 26 deletions

View file

@ -52,12 +52,13 @@ namespace lumiera
explicit Query (const string& predicate="") : string(predicate) {}
explicit Query (format& pattern) : string(str(pattern)) {}
const string asKey() const
{
return string(typeid(OBJ).name())+": "+*this;
}
};
operator string& () { return *this; } // TODO: needed temporarily by mockconfigrules
}; // for calling removeTerm on the string-ref....
namespace query

View file

@ -93,6 +93,7 @@ namespace lumiera
typedef const ProcPatt cPP;
// for baiscpipetest.cpp ---------
answer_->insert (entry_Struct<cPP> ("stream(video)"));
answer_->insert (entry_Struct<cPP> ("stream(teststream)"));
@ -104,6 +105,8 @@ namespace lumiera
}
/* under some circumstances we need to emulate the behaviour *
* of a real resolution engine in a more detailed manner. *
* These case are hard wired in code below */
@ -112,17 +115,22 @@ namespace lumiera
bool
MockTable::fabricate_matching_new_Pipe (Query<Pipe>& q, string const& pipeID, string const& streamID)
{
answer_->insert (entry<Pipe> (q, Struct::create (pipeID, streamID)));
typedef WrapReturn<Pipe>::Wrapper Ptr;
Ptr newPipe (Struct::create (pipeID, streamID));
answer_->insert (entry<Pipe> (q, newPipe));
return true; // denotes query will now succeed...
}
/** special case: create/retrieve new rocessing pattern for given stream ID... */
bool
MockTable::fabricate_ProcPatt_on_demand (Query<const ProcPatt>& q, string const& streamID)
{
typedef const ProcPatt cPP;
typedef typename WrapReturn<cPP>::Wrapper Ptr;
typedef WrapReturn<cPP>::Wrapper Ptr;
Ptr newPP (Struct::create (Query<cPP> ("make(PP), "+q)));
answer_->insert (entry<cPP> (q, newPP));
return true;
}

View file

@ -67,12 +67,28 @@ namespace lumiera
/** a traits-class to define the smart-ptr to wrap the result */
template<class TY>
struct WrapReturn { typedef shared_ptr<TY> Wrapper; };
template<>
struct WrapReturn<ProcPatt> { typedef PProcPatt Wrapper; };
namespace // internal details
{
/** a traits-class to define the smart-ptr to wrap the result */
template<class TY>
struct WrapReturn { typedef shared_ptr<TY> Wrapper; };
template<>
struct WrapReturn<ProcPatt> { typedef PProcPatt Wrapper; };
/** helper detecting if a query actually intended to retrieve a "default" object.
* This implementation is quite crude, of cours it would be necessary to actually
* parse and evaluate the query. @note query is modified if "default" ... */
inline bool
is_defaults_query (string& query)
{
return !isnil (removeTerm ("default", query));
}
} // details (end)
/**
@ -92,6 +108,8 @@ namespace lumiera
const any& fetch_from_table_for (const string& queryStr);
// special cases....
template<class TY>
bool detect_case (Query<TY>& q);
bool fabricate_matching_new_Pipe (Query<Pipe>& q, string const& pipeID, string const& streamID);
bool fabricate_ProcPatt_on_demand (Query<const ProcPatt>& q, string const& streamID);
@ -133,32 +151,28 @@ namespace lumiera
try_special_case (Ret& solution, const Query<TY>& q)
{
Query<TY> newQuery = q;
if (is_defaults_query (q)) // modified query..
if (is_defaults_query (newQuery)) // modified query..
return solution = Session::current->defaults (newQuery);
// may cause recursion
// may cause recursion
if (detect_case (newQuery))
return resolve (solution, newQuery);
return solution = Ret();
// fail: return default-constructed empty smart ptr
return solution = Ret(); // fail: return default-constructed empty smart ptr
}
bool
detect_case (Query<TY>& q);
};
/** Hook for treating very special cases for individual types only */
template<class TY, class BASE>
template<class TY>
inline bool
LookupPreconfigured<TY,BASE>::detect_case (Query<TY>& q)
MockTable::detect_case (Query<TY>& q)
{
q.clear(); // end recursion
return false;
}
template<class BASE>
template<>
inline bool
LookupPreconfigured<Pipe,BASE>::detect_case (Query<Pipe>& q)
MockTable::detect_case (Query<Pipe>& q)
{
const string pipeID = extractID("pipe", q);
const string streamID = extractID("stream", q);
@ -170,7 +184,7 @@ namespace lumiera
}
template<>
inline bool
LookupPreconfigured<const ProcPatt>::detect_case (Query<const ProcPatt>& q)
MockTable::detect_case (Query<const ProcPatt>& q)
{
const string streamID = extractID("stream", q);
if (!isnil(streamID))

View file

@ -134,6 +134,8 @@ namespace mobject
#include "proc/asset/procpatt.hpp"
#include "proc/asset/pipe.hpp"
#include "proc/asset/track.hpp"
#include "proc/mobject/session/track.hpp"
namespace mobject
{
@ -145,9 +147,15 @@ namespace mobject
using asset::ProcPatt;
using asset::PProcPatt;
using mobject::session::Track;
using mobject::session::TrackAsset;
using mobject::session::PTrack;
using mobject::session::PTrackAsset;
template PPipe DefsManager::operator() (const Query<Pipe>&);
template PProcPatt DefsManager::operator() (const Query<const ProcPatt>&);
template PPipe DefsManager::operator() (const Query<Pipe>&);
template PProcPatt DefsManager::operator() (const Query<const ProcPatt>&);
template PTrack DefsManager::operator() (const Query<Track>&);
template PTrackAsset DefsManager::operator() (const Query<TrackAsset>&);
template bool DefsManager::define (const PPipe&, const Query<Pipe>&);
template bool DefsManager::forget (const PPipe&);

View file

@ -45,7 +45,7 @@ namespace mobject
class Track;
class Effect;
typedef shared_ptr<const asset::Track> PTrackAsset;
typedef shared_ptr<asset::Track> PTrackAsset;
class MObjectFactory

View file

@ -34,7 +34,11 @@ namespace mobject
{
namespace session
{
typedef shared_ptr<const asset::Track> PTrackAsset;
class Track;
typedef asset::Track TrackAsset;
typedef shared_ptr<Track> PTrack;
typedef shared_ptr<TrackAsset> PTrackAsset;
/**
@ -57,7 +61,7 @@ namespace mobject
public:
/** Child tracks in a tree structure */
vector<Placement<Track> > subTracks; // TODO: Placement!!!!!!!
vector<Placement<Track> > subTracks; ////TODO: it should really work with Placements! this here is just a decoy!!!!!!!
virtual bool isValid() const;
};