From 7a53f65508a2c6f5a919c15d0d83ef0d5da6c491 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 29 Oct 2010 06:09:06 +0200 Subject: [PATCH] remove the separate pipeID field, because now the asset name is sufficient --- src/common/query/fake-configrules.cpp | 2 +- src/proc/asset.cpp | 10 ++++++++++ src/proc/asset.hpp | 2 ++ src/proc/asset/pipe.cpp | 14 ++++++-------- src/proc/asset/pipe.hpp | 7 +++---- src/proc/asset/struct-factory-impl.hpp | 6 ++---- src/proc/asset/struct.cpp | 4 ++-- src/proc/asset/struct.hpp | 3 ++- tests/components/proc/asset/basicpipetest.cpp | 2 +- .../proc/mobject/session/defsmanagerimpltest.cpp | 4 ++-- .../proc/mobject/session/defsmanagertest.cpp | 2 +- 11 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/common/query/fake-configrules.cpp b/src/common/query/fake-configrules.cpp index 054d36077..1e1dbf7d7 100644 --- a/src/common/query/fake-configrules.cpp +++ b/src/common/query/fake-configrules.cpp @@ -124,7 +124,7 @@ namespace lumiera { { typedef WrapReturn::Wrapper Ptr; - Ptr newPipe (Struct::retrieve (pipeID, streamID)); + Ptr newPipe (Struct::retrieve.newPipe (pipeID, streamID)); answer_->insert (entry (q, newPipe)); return true; // denotes query will now succeed... } diff --git a/src/proc/asset.cpp b/src/proc/asset.cpp index dd98bc7a4..36a4d7c49 100644 --- a/src/proc/asset.cpp +++ b/src/proc/asset.cpp @@ -38,6 +38,7 @@ using util::contains; using util::removeall; using util::for_each; using util::and_all; +using util::isnil; using util::cStr; @@ -84,6 +85,15 @@ namespace asset { format id_tuple("Asset(%2%:%3%.%1% v%4%)"); return str (id_tuple % ident.name % ident.category % ident.org % ident.version); } + + + bool + Asset::Ident::isValid() const + { + return !isnil (name) + && !isnil (org) + && version <= 1000000; + } diff --git a/src/proc/asset.hpp b/src/proc/asset.hpp index c4ba138bb..04e01a73c 100644 --- a/src/proc/asset.hpp +++ b/src/proc/asset.hpp @@ -190,6 +190,8 @@ namespace asset { bool operator< (Ident const& oi) const { return compare (oi) < 0; } operator string () const; + + bool isValid() const; }; diff --git a/src/proc/asset/pipe.cpp b/src/proc/asset/pipe.cpp index c1b21370f..849211d3e 100644 --- a/src/proc/asset/pipe.cpp +++ b/src/proc/asset/pipe.cpp @@ -38,19 +38,17 @@ namespace asset { */ Pipe::Pipe ( const Asset::Ident& idi , PProcPatt& wiring - , const string& pipeID , string shortName , string longName ) - : Struct (idi), - pipeID_ (pipeID), - wiringTemplate(wiring), - shortDesc (shortName), - longDesc (longName) + : Struct (idi) + , wiringTemplate(wiring) + , shortDesc (shortName) + , longDesc (longName) { - REQUIRE (!isnil (pipeID)); + REQUIRE (idi.isValid()); if (isnil (shortDesc)) - shortDesc = pipeID; + shortDesc = string(idi); } diff --git a/src/proc/asset/pipe.hpp b/src/proc/asset/pipe.hpp index 42d34b276..c018e9c7d 100644 --- a/src/proc/asset/pipe.hpp +++ b/src/proc/asset/pipe.hpp @@ -57,7 +57,6 @@ namespace asset { */ class Pipe : public Struct { - const string pipeID_; PProcPatt wiringTemplate; public: @@ -71,12 +70,12 @@ namespace asset { protected: - Pipe (const Asset::Ident&, PProcPatt& wiring, const string& pipeID, string shortName ="", string longName ="") ; + Pipe (Asset::Ident const&, PProcPatt& wiring, string shortName ="", string longName ="") ; friend class StructFactory; friend class StructFactoryImpl; public: - const string& getPipeID() const { return pipeID_; } + const string& getPipeID() const { return ident.name; } const PProcPatt& getProcPatt() const { return wiringTemplate; } /** use another wiring template. Triggers complete rebuild of the render engine. */ @@ -90,7 +89,7 @@ namespace asset { // catch up with postponed definition of ID ctors... // inline ID::ID(size_t id) : ID (id) {}; - inline ID::ID(const Pipe& pipe) : ID (pipe.getID()) {}; + inline ID::ID(Pipe const& pipe) : ID (pipe.getID()) {}; diff --git a/src/proc/asset/struct-factory-impl.hpp b/src/proc/asset/struct-factory-impl.hpp index 562916567..f59f3ebc3 100644 --- a/src/proc/asset/struct-factory-impl.hpp +++ b/src/proc/asset/struct-factory-impl.hpp @@ -177,21 +177,19 @@ namespace asset { { TODO ("actually extract properties/capabilities from the query..."); return new ProcPatt (createIdent (caps)); - } + } ///////////////////////TICKET #565 maybe store the capabilities query within the Struct asset somehow? template<> inline Pipe* StructFactoryImpl::fabricate (const Query& caps) { const Asset::Ident idi (createIdent (caps)); - string pipeID = extractID ("pipe", idi.name); string streamID = extractID ("stream", caps); if (isnil (streamID)) streamID = "default"; PProcPatt processingPattern = Session::current->defaults (Query("stream("+streamID+")")); return new Pipe( idi , processingPattern - , pipeID - ); + ); ///////////////////////TICKET #565 maybe store the capabilities query within the Struct asset somehow? } template<> diff --git a/src/proc/asset/struct.cpp b/src/proc/asset/struct.cpp index fbfaec89c..f3d4676e6 100644 --- a/src/proc/asset/struct.cpp +++ b/src/proc/asset/struct.cpp @@ -58,7 +58,7 @@ namespace asset { } /** query the currently defined properties of this - structural asset for a stream-ID predicate */ + structural asset for a pipe-ID predicate */ const string Struct::queryPipeID() const { @@ -141,7 +141,7 @@ namespace asset { * @see DefaultsManager */ P - StructFactory::operator() (string pipeID, string streamID) + StructFactory::newPipe (string pipeID, string streamID) { normaliseID (pipeID); normaliseID (streamID); diff --git a/src/proc/asset/struct.hpp b/src/proc/asset/struct.hpp index 76d6745dc..59144a2dd 100644 --- a/src/proc/asset/struct.hpp +++ b/src/proc/asset/struct.hpp @@ -153,11 +153,12 @@ namespace asset { template P operator() (Query const& query); - P operator() (string pipeID, string streamID); // P operator() (MORef); ///////////TODO doesn't this create circular includes?? Any better idea how to refer to an existing binding? template P newInstance (Symbol nameID =""); + + P newPipe (string pipeID, string streamID); }; diff --git a/tests/components/proc/asset/basicpipetest.cpp b/tests/components/proc/asset/basicpipetest.cpp index 7e3c8799c..ac62a92e5 100644 --- a/tests/components/proc/asset/basicpipetest.cpp +++ b/tests/components/proc/asset/basicpipetest.cpp @@ -83,7 +83,7 @@ namespace asset normaliseID (pID_sane); ASSERT (pID_sane != pID); - PPipe thePipe = asset::Struct::retrieve (pID,sID); + PPipe thePipe = asset::Struct::retrieve.newPipe (pID,sID); ASSERT (thePipe); ASSERT (thePipe->getProcPatt()); diff --git a/tests/components/proc/mobject/session/defsmanagerimpltest.cpp b/tests/components/proc/mobject/session/defsmanagerimpltest.cpp index be4aeccee..49c603d90 100644 --- a/tests/components/proc/mobject/session/defsmanagerimpltest.cpp +++ b/tests/components/proc/mobject/session/defsmanagerimpltest.cpp @@ -97,8 +97,8 @@ namespace asset { // create Pipes explicitly // (without utilising default queries) - PPipe pipe1 = Struct::retrieve (newID("pipe"), newID("stream")); - PPipe pipe2 = Struct::retrieve (newID("pipe"), sID ); + PPipe pipe1 = Struct::retrieve.newPipe (newID("pipe"), newID("stream")); + PPipe pipe2 = Struct::retrieve.newPipe (newID("pipe"), sID ); ASSERT (pipe1 != pipe2); ASSERT (sID == pipe2->getProcPatt()->queryStreamID()); diff --git a/tests/components/proc/mobject/session/defsmanagertest.cpp b/tests/components/proc/mobject/session/defsmanagertest.cpp index 5208337a9..d06cb625b 100644 --- a/tests/components/proc/mobject/session/defsmanagertest.cpp +++ b/tests/components/proc/mobject/session/defsmanagertest.cpp @@ -169,7 +169,7 @@ namespace test { ASSERT (3 == pipe1.use_count()); // that's the problem; it should be 2 QueryHandler& typeHandler = ConfigRules::instance(); - PPipe pipe2 = asset::Struct::retrieve (pID, "quatsch"); + PPipe pipe2 = asset::Struct::retrieve.newPipe (pID, "quatsch"); typeHandler.resolve (pipe2, query_for_pID); // in the mock impl this has the side effect ASSERT (pipe2); // of replacing the mock entry