Defaults Manager finished for now
...passes high level test (with help by the mock 'resolution engine') ;-)
This commit is contained in:
parent
0b5b9b593e
commit
a869c71077
4 changed files with 32 additions and 8 deletions
|
|
@ -100,7 +100,7 @@ namespace lumiera
|
||||||
item<cPP> (answer_, "stream(default)") = item<cPP> (answer_,"stream(video)"); // set up a default stream
|
item<cPP> (answer_, "stream(default)") = item<cPP> (answer_,"stream(video)"); // set up a default stream
|
||||||
|
|
||||||
answer_->insert (entry_Struct<Pipe> ("pipe(master), stream(video)"));
|
answer_->insert (entry_Struct<Pipe> ("pipe(master), stream(video)"));
|
||||||
item<Pipe> (answer_, "default(P)") = item<Pipe>(answer_,"pipe(master), stream(video)");
|
item<Pipe> (answer_, "") = item<Pipe>(answer_,"pipe(master), stream(video)");// use as default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ namespace lumiera
|
||||||
}
|
}
|
||||||
/** special case: create a new pipe for a specific stream ID */
|
/** special case: create a new pipe for a specific stream ID */
|
||||||
bool
|
bool
|
||||||
MockTable::fabricate_new_Pipe_for_stream (Query<Pipe>& q, string const& streamID)
|
MockTable::fabricate_just_new_Pipe (Query<Pipe>& q )
|
||||||
{
|
{
|
||||||
typedef WrapReturn<Pipe>::Wrapper Ptr;
|
typedef WrapReturn<Pipe>::Wrapper Ptr;
|
||||||
|
|
||||||
|
|
@ -147,6 +147,7 @@ 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());
|
||||||
answer_->insert (entry<TY> (q, obj));
|
answer_->insert (entry<TY> (q, obj));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ namespace lumiera
|
||||||
template<class TY>
|
template<class TY>
|
||||||
bool detect_case (typename WrapReturn<TY>::Wrapper&, Query<TY>& q);
|
bool detect_case (typename WrapReturn<TY>::Wrapper&, Query<TY>& q);
|
||||||
bool fabricate_matching_new_Pipe (Query<Pipe>& q, string const& pipeID, string const& streamID);
|
bool fabricate_matching_new_Pipe (Query<Pipe>& q, string const& pipeID, string const& streamID);
|
||||||
bool fabricate_new_Pipe_for_stream (Query<Pipe>& q, string const& streamID);
|
bool fabricate_just_new_Pipe (Query<Pipe>& q);
|
||||||
bool fabricate_ProcPatt_on_demand (Query<const ProcPatt>& q, string const& streamID);
|
bool fabricate_ProcPatt_on_demand (Query<const ProcPatt>& q, string const& streamID);
|
||||||
|
|
||||||
template<class TY>
|
template<class TY>
|
||||||
|
|
@ -195,8 +195,8 @@ namespace lumiera
|
||||||
if (!isnil(pipeID) && !isnil(streamID))
|
if (!isnil(pipeID) && !isnil(streamID))
|
||||||
return fabricate_matching_new_Pipe (q, pipeID, streamID);
|
return fabricate_matching_new_Pipe (q, pipeID, streamID);
|
||||||
|
|
||||||
if (!candidate && !isnil(streamID))
|
if (!candidate && (!isnil(streamID) || !isnil(pipeID)))
|
||||||
return fabricate_new_Pipe_for_stream (q, streamID);
|
return fabricate_just_new_Pipe (q);
|
||||||
|
|
||||||
q.clear();
|
q.clear();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ PLANNED "AddClip_test" AddClip_test <<END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
PLANNED "DefsManager_test" DefsManager_test <<END
|
TEST "DefsManager_test" DefsManager_test <<END
|
||||||
|
return: 0
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "proc/asset.hpp"
|
#include "proc/asset.hpp"
|
||||||
#include "proc/asset/pipe.hpp"
|
#include "proc/asset/pipe.hpp"
|
||||||
#include "common/query.hpp"
|
#include "common/query.hpp"
|
||||||
|
#include "common/configrules.hpp" ///////TODO just temp
|
||||||
#include "proc/assetmanager.hpp"
|
#include "proc/assetmanager.hpp"
|
||||||
#include "proc/mobject/session.hpp"
|
#include "proc/mobject/session.hpp"
|
||||||
|
|
||||||
|
|
@ -46,6 +47,9 @@ namespace asset
|
||||||
using lumiera::Query;
|
using lumiera::Query;
|
||||||
using lumiera::query::normalizeID;
|
using lumiera::query::normalizeID;
|
||||||
|
|
||||||
|
using lumiera::ConfigRules; ////TODO just temp
|
||||||
|
using lumiera::query::QueryHandler; ////TODO just temp
|
||||||
|
|
||||||
|
|
||||||
/** shortcut: run just a query
|
/** shortcut: run just a query
|
||||||
* without creating new instances
|
* without creating new instances
|
||||||
|
|
@ -60,7 +64,7 @@ namespace asset
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* @test basic behaviour of the defaults manager.
|
* @test basic behaviour of the defaults manager ("the big picture")
|
||||||
* <ol><li>retrieving a "default" object repeatedly</li>
|
* <ol><li>retrieving a "default" object repeatedly</li>
|
||||||
* <li>retrieving a more constrained "default" object</li>
|
* <li>retrieving a more constrained "default" object</li>
|
||||||
* <li>failure registers a new "default"</li>
|
* <li>failure registers a new "default"</li>
|
||||||
|
|
@ -101,7 +105,7 @@ namespace asset
|
||||||
ASSERT (pipe2 == pipe1);
|
ASSERT (pipe2 == pipe1);
|
||||||
pipe2 = asset::Struct::create (Query<Pipe> ());
|
pipe2 = asset::Struct::create (Query<Pipe> ());
|
||||||
ASSERT (pipe2 == pipe1);
|
ASSERT (pipe2 == pipe1);
|
||||||
pipe2 = asset::Struct::create (Query<Pipe> ("default(X)"));
|
pipe2 = asset::Struct::create (Query<Pipe> ("default(P)"));
|
||||||
ASSERT (pipe2 == pipe1);
|
ASSERT (pipe2 == pipe1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,12 +148,30 @@ namespace asset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** verify the defaults manager holds only weak refs,
|
||||||
|
* so if an object goes out of scope, any defaults entries
|
||||||
|
* are purged silently
|
||||||
|
*/
|
||||||
void verifyRemoval (string pID)
|
void verifyRemoval (string pID)
|
||||||
{
|
{
|
||||||
Query<Pipe> query_for_pID ("pipe("+pID+")");
|
Query<Pipe> query_for_pID ("pipe("+pID+")");
|
||||||
size_t hash;
|
size_t hash;
|
||||||
{
|
{
|
||||||
PPipe pipe1 = Session::current->defaults (query_for_pID);
|
PPipe pipe1 = Session::current->defaults (query_for_pID);
|
||||||
|
//
|
||||||
|
// this is fine but doesn't work as long as there is another entry in the mock table...
|
||||||
|
// ...for now we use hack to overwrite the reference in the mock table
|
||||||
|
//
|
||||||
|
ASSERT (3 == pipe1.use_count()); // that's the problem; it should be 2
|
||||||
|
|
||||||
|
QueryHandler<Pipe>& typeHandler = ConfigRules::instance();
|
||||||
|
PPipe pipe2 = asset::Struct::create (pID, "quatsch");
|
||||||
|
|
||||||
|
typeHandler.resolve (pipe2, query_for_pID); // in the mock impl this has the side effect
|
||||||
|
ASSERT (pipe2); // of replacing the mock entry
|
||||||
|
//////////////////////////////////////////// so from now on the test works as intended....
|
||||||
|
|
||||||
|
ASSERT (2 == pipe1.use_count());
|
||||||
hash = pipe1->getID();
|
hash = pipe1->getID();
|
||||||
}
|
}
|
||||||
// now AssetManager should hold the only ref
|
// now AssetManager should hold the only ref
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue