2007-08-08 04:50:02 +02:00
|
|
|
/*
|
|
|
|
|
PROCNODE.hpp - Key abstraction of the Render Engine: a Processing Node
|
|
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2007-08-08 04:50:02 +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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2007-08-09 18:51:47 +02:00
|
|
|
#ifndef ENGINE_PROCNODE_H
|
|
|
|
|
#define ENGINE_PROCNODE_H
|
2007-08-08 04:50:02 +02:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2008-06-14 04:19:58 +02:00
|
|
|
#include "proc/state.hpp"
|
2007-08-08 04:50:02 +02:00
|
|
|
#include "proc/mobject/parameter.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-27 07:22:27 +02:00
|
|
|
namespace engine {
|
2007-08-08 04:50:02 +02:00
|
|
|
|
2008-05-27 07:22:27 +02:00
|
|
|
using std::vector;
|
2008-06-14 04:19:58 +02:00
|
|
|
using proc_interface::State;
|
2008-05-27 07:22:27 +02:00
|
|
|
|
|
|
|
|
class ProcNode;
|
|
|
|
|
class NodeFactory;
|
|
|
|
|
|
2008-06-14 04:19:58 +02:00
|
|
|
typedef ProcNode* PNode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Description of the input and output ports and the
|
|
|
|
|
* predecessor nodes for a given ProcNode.
|
|
|
|
|
*/
|
|
|
|
|
struct WiringDescriptor
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2007-08-08 04:50:02 +02:00
|
|
|
|
2008-06-14 04:19:58 +02:00
|
|
|
/**
|
|
|
|
|
* Adapter to shield the ProcNode from the actual buffer management,
|
|
|
|
|
* allowing the processing function within ProcNode to use logical
|
|
|
|
|
* buffer IDs. StateAdapter is created on the stack for each pull()
|
|
|
|
|
* call, using setup/wiring data preconfigured by the builder.
|
|
|
|
|
* Its job is to provide the actual implementation of the Cache
|
|
|
|
|
* push / fetch and recursive downcall to render the source frames.
|
|
|
|
|
*/
|
|
|
|
|
class StateAdapter
|
|
|
|
|
: public State
|
|
|
|
|
{
|
|
|
|
|
State& parent_;
|
|
|
|
|
State& current_;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
StateAdapter (State& callingProcess, WiringDescriptor const&)
|
|
|
|
|
: parent_ (callingProcess),
|
|
|
|
|
current_(callingProcess.getCurrentImplementation())
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
friend class ProcNode; // both are sharing implementation details...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual State& getCurrentImplementation () { return current_; }
|
|
|
|
|
|
|
|
|
|
/** contains the details of Cache query and recursive calls
|
|
|
|
|
* to the predecessor node(s), eventually followed by the
|
|
|
|
|
* ProcNode::process() callback
|
|
|
|
|
*/
|
|
|
|
|
void retrieve();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-08-09 18:51:47 +02:00
|
|
|
/**
|
|
|
|
|
* Key abstraction of the Render Engine: A Data processing Node
|
|
|
|
|
*/
|
|
|
|
|
class ProcNode
|
|
|
|
|
{
|
2008-06-14 04:19:58 +02:00
|
|
|
typedef mobject::Parameter<double> Param; //////TODO: just a placeholder for automation as of 6/2008
|
2007-08-09 18:51:47 +02:00
|
|
|
vector<Param> params;
|
2007-08-08 04:50:02 +02:00
|
|
|
|
2008-05-27 07:22:27 +02:00
|
|
|
protected:
|
|
|
|
|
ProcNode();
|
|
|
|
|
virtual ~ProcNode() {};
|
|
|
|
|
|
|
|
|
|
friend class NodeFactory;
|
|
|
|
|
|
|
|
|
|
|
2008-06-14 04:19:58 +02:00
|
|
|
/** Callback doing the actual calculations
|
|
|
|
|
* after input / output buffers are ready
|
2008-05-27 07:22:27 +02:00
|
|
|
* @internal dispatch to implementation.
|
2008-06-14 04:19:58 +02:00
|
|
|
* Client code should use #pull()
|
2008-05-27 07:22:27 +02:00
|
|
|
*/
|
2008-06-14 04:19:58 +02:00
|
|
|
virtual void process(State&) = 0;
|
|
|
|
|
|
|
|
|
|
friend void StateAdapter::retrieve(); // to issue the process() callback if necessary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Extension point for subclasses to modify the input sources
|
|
|
|
|
* according to automation data and other state dependent properties.
|
|
|
|
|
*/
|
|
|
|
|
virtual WiringDescriptor const& getWiring (State&);
|
|
|
|
|
|
2008-05-27 07:22:27 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static NodeFactory create;
|
|
|
|
|
|
2008-06-14 04:19:58 +02:00
|
|
|
/** Engine Core operation: render and pull output from this node.
|
|
|
|
|
* On return, currentProcess will hold onto output buffer(s)
|
|
|
|
|
* containing the calculated result frames.
|
2008-05-27 07:22:27 +02:00
|
|
|
*/
|
2008-06-14 04:19:58 +02:00
|
|
|
void
|
|
|
|
|
pull (State& currentProcess)
|
|
|
|
|
{
|
|
|
|
|
StateAdapter thisStep (currentProcess, getWiring (currentProcess));
|
|
|
|
|
thisStep.retrieve(); // fetch or calculate results
|
|
|
|
|
}
|
2008-05-27 07:22:27 +02:00
|
|
|
|
2007-08-09 18:51:47 +02:00
|
|
|
};
|
2007-08-08 04:50:02 +02:00
|
|
|
|
2007-08-09 18:51:47 +02:00
|
|
|
} // namespace engine
|
2007-08-08 04:50:02 +02:00
|
|
|
#endif
|