2007-09-22 16:44:50 +02:00
|
|
|
/*
|
|
|
|
|
ProcPatt - template for building some render processing network
|
|
|
|
|
|
|
|
|
|
Copyright (C) CinelerraCV
|
2007-11-27 03:19:35 +01:00
|
|
|
2007, Hermann Vosseler <Ichthyostega@web.de>
|
2007-09-22 16:44:50 +02:00
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "proc/asset/procpatt.hpp"
|
2008-02-10 17:23:16 +01:00
|
|
|
#include "proc/asset/proc.hpp"
|
2008-01-14 01:01:11 +01:00
|
|
|
#include "proc/assetmanager.hpp"
|
2008-02-10 17:23:16 +01:00
|
|
|
#include "proc/asset/buildinstruct.hpp"
|
|
|
|
|
#include "common/util.hpp"
|
|
|
|
|
|
|
|
|
|
using util::isnil;
|
2007-09-22 16:44:50 +02:00
|
|
|
|
|
|
|
|
namespace asset
|
|
|
|
|
{
|
|
|
|
|
|
2008-01-14 01:01:11 +01:00
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-22 16:44:50 +02:00
|
|
|
/** */
|
2008-02-10 17:23:16 +01:00
|
|
|
ProcPatt::ProcPatt (const string& properties)
|
2008-01-14 01:01:11 +01:00
|
|
|
: Struct (createPatternIdent (properties)),
|
2008-02-10 17:23:16 +01:00
|
|
|
propDescriptor_ (properties)
|
2008-01-14 01:01:11 +01:00
|
|
|
{
|
|
|
|
|
TODO ("verify building instructions, maybe preprocess...");
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-10 17:23:16 +01:00
|
|
|
/** @internal used for creating a clone */
|
|
|
|
|
ProcPatt::ProcPatt (const string& props, const InstructionSequence& instructs)
|
|
|
|
|
: Struct (createPatternIdent (props)),
|
|
|
|
|
propDescriptor_ (props),
|
|
|
|
|
instructions_ (instructs)
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-01-14 01:01:11 +01:00
|
|
|
|
|
|
|
|
/** 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
|
|
|
|
|
* of this one. The new ProcPatt can then be customized
|
|
|
|
|
* independently of the original one. This allows using
|
2008-02-10 17:23:16 +01:00
|
|
|
* some ProcPatt as a template for creating more
|
2008-01-14 01:01:11 +01:00
|
|
|
* spezialized patterns.
|
|
|
|
|
*/
|
|
|
|
|
shared_ptr<ProcPatt>
|
|
|
|
|
ProcPatt::newCopy (string newID) const
|
|
|
|
|
{
|
|
|
|
|
TODO ("implement the Pattern-ID within the propDescriptor!");
|
2008-02-10 17:23:16 +01:00
|
|
|
ProcPatt* pP = new ProcPatt (this->propDescriptor_, this->instructions_);
|
2008-01-14 01:01:11 +01:00
|
|
|
return AssetManager::instance().wrap (*pP);
|
|
|
|
|
}
|
2008-02-10 17:23:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** extend the processing instructions to add some Effect
|
|
|
|
|
* @param where denotes the insertion point where to attach the Effect
|
|
|
|
|
* @param node prototype of the Effect to be inserted when building.
|
|
|
|
|
*/
|
|
|
|
|
ProcPatt&
|
|
|
|
|
ProcPatt::attach(Symbol where, PProc& node)
|
|
|
|
|
{
|
|
|
|
|
DoAttach *last (0);
|
|
|
|
|
if ( !isnil (instructions_)
|
|
|
|
|
&& (last = boost::get<DoAttach> (&(instructions_.back())))
|
|
|
|
|
&& last->point==where
|
|
|
|
|
)
|
|
|
|
|
// instead of adding a new build instruct entry,
|
|
|
|
|
// we can extend the list in the last "DoAttach" entry.
|
|
|
|
|
last->nodes.push_back(node);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DoAttach entry(node, where);
|
|
|
|
|
instructions_.push_back(BuildInstruct(entry));
|
|
|
|
|
}
|
|
|
|
|
TODO ("declare dependency??");
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** extend the processing instructions by reference to another
|
|
|
|
|
* ProcPatt, which will be "executed" at this point while building.
|
|
|
|
|
* This allowes for using simple PorcPatt instances as building blocks
|
|
|
|
|
* to define more complicated patterns.
|
|
|
|
|
*/
|
|
|
|
|
ProcPatt&
|
|
|
|
|
ProcPatt::operator+= (PProcPatt& toReuse)
|
|
|
|
|
{
|
|
|
|
|
DoRecurse entry(toReuse);
|
|
|
|
|
instructions_.push_back(BuildInstruct (entry));
|
|
|
|
|
TODO ("declare dependency??");
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-22 16:44:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace asset
|