TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/Node.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_NODE_HPP_
00002 #define _TUTTLE_HOST_NODE_HPP_
00003 
00004 #include "INode.hpp"
00005 #include "ComputeOptions.hpp"
00006 #include "memory/MemoryCache.hpp"
00007 
00008 #include <boost/assign/list_of.hpp>
00009 
00010 #include <memory>
00011 
00012 namespace tuttle {
00013 namespace host {
00014 
00015 class NodeInit;
00016 
00017 using boost::assign::list_of;
00018 
00019 INode* createNode( const std::string& pluginName );
00020 
00021 bool compute( const std::vector<NodeInit>& nodes,
00022                 const ComputeOptions& options = ComputeOptions() );
00023 
00024 bool compute( memory::IMemoryCache& memoryCache,
00025                 const std::vector<NodeInit>& nodes,
00026                 const ComputeOptions& options = ComputeOptions() );
00027 
00028 bool compute( memory::IMemoryCache& memoryCache,
00029                 const std::vector<NodeInit>& nodes,
00030                 const ComputeOptions& options,
00031                 memory::IMemoryCache& internMemoryCache );
00032 
00033 
00034 /**
00035  * @brief Node initializer class.
00036  */
00037 class NodeInit
00038 {
00039 public:
00040         NodeInit(){}
00041         NodeInit( const std::string& pluginName );
00042         NodeInit( INode& node );
00043         /**
00044          * @brief Non-standard copy contructor that steals the data.
00045          */
00046         NodeInit( const NodeInit& other )
00047         {
00048                 setNode( other.release() );
00049         }
00050 
00051         NodeInit& operator=( const NodeInit& other )
00052         {
00053                 setNode( other.release() );
00054                 return *this;
00055         }
00056         
00057         INode& operator->() { return *_node.get(); }
00058         const INode& operator->() const { return *_node.get(); }
00059         
00060         /**
00061          * @brief Set parameter values. If it's a multi-dimensional parameter,
00062          * you should put all dimensions values.
00063          * @exemple setParam("redColor", 1.0, 0.0, 0.0, 1.0)
00064          */
00065         NodeInit& setParam( const std::string& paramName, ... );
00066         
00067         /**
00068          * @brief Set parameter value from a string expression.
00069          */
00070         NodeInit& setParamExp( const std::string& paramName, const std::string& paramValue );
00071         
00072         const INode& get() const { return *_node; }
00073         INode& get() { return *_node; }
00074         
00075         void setNode( INode& node ) { _node.reset(&node); }
00076         INode& release() const { return *_node.release(); }
00077 
00078     void setBeforeRenderCallback(Callback *cb);
00079 
00080 private:
00081         mutable std::auto_ptr<INode> _node;
00082 };
00083 
00084 }
00085 }
00086 
00087 #endif