From 113678ff9324ad45836b354de4e58c473017232d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 15 Feb 2008 02:56:25 +0100 Subject: [PATCH] some refacturing of the (preliminary) struct asset impl... --- doc/devel/.gitignore | 2 + src/proc/asset/procpatt.cpp | 56 ++++++++++------------------ src/proc/asset/procpatt.hpp | 6 +-- src/proc/asset/struct.cpp | 25 +++++++++++++ src/proc/asset/struct.hpp | 3 ++ src/proc/asset/structfactoryimpl.hpp | 4 +- 6 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 doc/devel/.gitignore diff --git a/doc/devel/.gitignore b/doc/devel/.gitignore new file mode 100644 index 000000000..96886436c --- /dev/null +++ b/doc/devel/.gitignore @@ -0,0 +1,2 @@ +,doxylog +html/* diff --git a/src/proc/asset/procpatt.cpp b/src/proc/asset/procpatt.cpp index ec9ecb781..f7ce8895d 100644 --- a/src/proc/asset/procpatt.cpp +++ b/src/proc/asset/procpatt.cpp @@ -32,46 +32,26 @@ using util::isnil; namespace asset { - namespace // ProcPattern implementation details - { - /** @internal derive a sensible asset ident tuple when creating - * a processing pattern asset based on a query - * @todo define the actual naming scheme of struct assets - */ - const Asset::Ident - createPatternIdent (const string& properties) - { - string name ("pattern-" + properties); // TODO something sensible here; append number, sanitize etc. - TODO ("Implement ProcPatt name scheme!!"); - Category category (STRUCT,"patterns"); - return Asset::Ident (name, category ); - } - } - /** */ - ProcPatt::ProcPatt (const string& properties) - : Struct (createPatternIdent (properties)), - propDescriptor_ (properties) + /** new processing pattern with empty instruction list. + * @todo preliminary implementation, storing the capabilities + * in the asset name field. We can do better, when + * it's clear what capabilities we need + */ + ProcPatt::ProcPatt (const Asset::Ident& idi) + : Struct (idi), + instructions_() + { } + + + /** @internal used for creating a clone copy */ + ProcPatt::ProcPatt (const Asset::Ident& idi, const InstructionSequence& instru) + : Struct (idi), + instructions_(instru) { TODO ("verify building instructions, maybe preprocess..."); } - - /** @internal used for creating a clone */ - ProcPatt::ProcPatt (const string& props, const InstructionSequence& instructs) - : Struct (createPatternIdent (props)), - propDescriptor_ (props), - instructions_ (instructs) - { } - - /** query the currently defined properties of this - processing pattern for a stream-ID predicate */ - const string& - ProcPatt::queryStreamID() const - { - TODO ("really implement querying the properties"); - return propDescriptor_; /////////////////////////////TODO grober Unfug - } /** create a new ProcPatt asset as a literal copy @@ -84,7 +64,11 @@ namespace asset ProcPatt::newCopy (string newID) const { TODO ("implement the Pattern-ID within the propDescriptor!"); - ProcPatt* pP = new ProcPatt (this->propDescriptor_, this->instructions_); + TODO ("implement a consitent struct asset naming scheme at one central location!!!!!"); + const Asset::Ident newIdi ( this->ident.name+".X" + , this->ident.category + ); + ProcPatt* pP = new ProcPatt (newIdi, this->instructions_); return AssetManager::instance().wrap (*pP); } diff --git a/src/proc/asset/procpatt.hpp b/src/proc/asset/procpatt.hpp index 5cd22e1e1..593c57a0f 100644 --- a/src/proc/asset/procpatt.hpp +++ b/src/proc/asset/procpatt.hpp @@ -52,17 +52,15 @@ namespace asset */ class ProcPatt : public Struct { - string propDescriptor_; InstructionSequence instructions_; - ProcPatt (const string& props, const InstructionSequence& instructs); + ProcPatt (const Asset::Ident&, const InstructionSequence&); protected: - explicit ProcPatt (const string& propDescriptor); + explicit ProcPatt (const Asset::Ident& idi); friend class StructFactoryImpl; public: - const string& queryStreamID() const; shared_ptr newCopy (string newID) const; ProcPatt& attach (Symbol where, PProc& node); diff --git a/src/proc/asset/struct.cpp b/src/proc/asset/struct.cpp index 729da826a..47586202a 100644 --- a/src/proc/asset/struct.cpp +++ b/src/proc/asset/struct.cpp @@ -34,6 +34,12 @@ #include "common/util.hpp" #include "nobugcfg.h" +#include + +using boost::regex; +using boost::smatch; +using boost::regex_search; + using mobject::Session; using cinelerra::query::normalizeID; @@ -47,6 +53,25 @@ namespace asset /****** NOTE: not really implemented yet. What follows is partially a hack to build simple tests *******/ + namespace // Implementation details + { + regex streamID_pattern("stream\\(\\s*(\\w+)\\s*\\)"); + } + + + + /** query the currently defined properties of this + structural asset for a stream-ID predicate */ + const string + Struct::queryStreamID() const + { + smatch match; + + if (regex_search (this->ident.name, match, streamID_pattern)) + return string (match[1]); + else + return ""; + } diff --git a/src/proc/asset/struct.hpp b/src/proc/asset/struct.hpp index e9cb9de7d..4beb5479e 100644 --- a/src/proc/asset/struct.hpp +++ b/src/proc/asset/struct.hpp @@ -84,6 +84,9 @@ namespace asset return static_cast& > (Asset::getID()); } + const string queryStreamID() const; + + protected: Struct (const Asset::Ident& idi) : Asset(idi) {} friend class StructFactory; diff --git a/src/proc/asset/structfactoryimpl.hpp b/src/proc/asset/structfactoryimpl.hpp index 506baea83..a1086a9fa 100644 --- a/src/proc/asset/structfactoryimpl.hpp +++ b/src/proc/asset/structfactoryimpl.hpp @@ -84,7 +84,9 @@ namespace asset const Asset::Ident createIdent (const Query& query) { - string name (Traits::namePrefix + query); // TODO something sensible here; append number, sanitize etc. + static int i=0; + static format namePattern ("%s%d-%s"); // TODO finally just use the capability string as name?? + string name = str(namePattern % Traits::namePrefix % (++i) % query); TODO ("struct asset naming scheme??"); Category cat (STRUCT, Traits::catFolder); return Asset::Ident (name, cat );