TuttleOFX  1
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, const ComputeOptions& options = ComputeOptions() );
00022 bool compute( memory::MemoryCache& memoryCache, const std::vector<NodeInit>& nodes, const ComputeOptions& options = ComputeOptions() );
00023 
00024 
00025 /**
00026  * @brief Node initializer class.
00027  */
00028 class NodeInit
00029 {
00030 public:
00031         NodeInit(){}
00032         NodeInit( const std::string& pluginName );
00033         NodeInit( INode& node );
00034         /**
00035          * @brief Non-standard copy contructor that steals the data.
00036          */
00037         NodeInit( const NodeInit& other )
00038         {
00039                 setNode( other.release() );
00040         }
00041 
00042         NodeInit& operator=( const NodeInit& other )
00043         {
00044                 setNode( other.release() );
00045                 return *this;
00046         }
00047         
00048         INode& operator->() { return *_node.get(); }
00049         const INode& operator->() const { return *_node.get(); }
00050         
00051         /**
00052          * @brief Set parameter values. If it's a multi-dimensional parameter,
00053          * you should put all dimensions values.
00054          * @exemple setParam("redColor", 1.0, 0.0, 0.0, 1.0)
00055          */
00056         NodeInit& setParam( const std::string& paramName, ... );
00057         
00058         /**
00059          * @brief Set parameter value from a string expression.
00060          */
00061         NodeInit& setParamExp( const std::string& paramName, const std::string& paramValue );
00062         
00063         const INode& get() const { return *_node; }
00064         INode& get() { return *_node; }
00065         
00066         void setNode( INode& node ) { _node.reset(&node); }
00067         INode& release() const { return *_node.release(); }
00068         
00069 private:
00070         mutable std::auto_ptr<INode> _node;
00071 };
00072 
00073 }
00074 }
00075 
00076 #endif