77 lines
2.7 KiB
C
Raw Normal View History

#ifndef HGL_GRAPH_SHADER_NODE_INCLUDE
#define HGL_GRAPH_SHADER_NODE_INCLUDE
#include<hgl/type/BaseString.h>
#include<hgl/type/List.h>
2019-12-13 17:55:20 +08:00
#include<hgl/type/Map.h>
#include<hgl/graph/shader/node/type.h>
#include<hgl/graph/shader/param/in.h>
#include<hgl/graph/shader/param/out.h>
BEGIN_SHADER_NODE_NAMESPACE
2019-12-13 17:55:20 +08:00
#define SHADER_INPUT_PARAM(mj,name,type) AddInput(mj,#name,SHADER_PARAM_NAMESPACE::ParamType::type);
#define SHADER_OUTPUT_PARAM(name,type) AddOutput(#name,SHADER_PARAM_NAMESPACE::ParamType::type));
using InputParamList=ObjectList<param::InputParam>;
using OutputParamList=ObjectList<param::OutputParam>;
2019-12-13 17:55:20 +08:00
using InputParamMapByName=Map<UTF8String,param::InputParam *>;
using OutputParamMapByName=Map<UTF8String,param::OutputParam *>;
2019-12-10 22:12:09 +08:00
/**
2019-12-13 17:55:20 +08:00
* Shader Shader的基础()
2019-12-10 22:12:09 +08:00
*/
class Node
{
NodeType type;
2019-12-12 22:25:40 +08:00
protected:
2019-12-13 17:55:20 +08:00
UTF8String user_name; ///<节点用户自定义名称
InputParamList input_params;
OutputParamList output_params;
2019-12-12 22:25:40 +08:00
2019-12-13 17:55:20 +08:00
InputParamMapByName input_params_by_name;
OutputParamMapByName output_params_by_name;
protected:
void AddInput (bool mj,const UTF8String &n,const param::ParamType &pt);
void AddOutput (const UTF8String &n,const param::ParamType &pt);
public:
2019-12-13 17:55:20 +08:00
param::InputParam * GetInput (const UTF8String &n) ///<根据名称获取输入参数
{return GetListObject(input_params_by_name,n);}
param::OutputParam *GetOutput (const UTF8String &n) ///<根据名称获取输出参数
{return GetListObject(output_params_by_name,n);}
2019-12-10 22:12:09 +08:00
public:
Node(const NodeType &nt){type=nt;}
Node(const NodeType &nt,const UTF8String &n){type=nt;user_name=n;}
2019-12-10 22:12:09 +08:00
virtual ~Node()=default;
2019-12-12 22:25:40 +08:00
const NodeType GetNodeType ()const{return type;}
2019-12-13 17:55:20 +08:00
const UTF8String & GetUsername ()const{return user_name;}
void SetUsername (const UTF8String &n){user_name=n;}
public: //参数相关
InputParamList & GetInputParamList (){return input_params;}
OutputParamList & GetOutputParamList (){return output_params;}
2019-12-12 22:25:40 +08:00
virtual bool JoinInput (const UTF8String &,node::Node *,param::OutputParam *);
2019-12-13 17:55:20 +08:00
2019-12-12 22:25:40 +08:00
public: //参数相关
2019-12-13 17:55:20 +08:00
virtual bool IsOutput(param::OutputParam *);
2019-12-12 22:25:40 +08:00
virtual bool Check(); ///<检测当前节点是否可用
2019-12-10 22:12:09 +08:00
};//class Node
END_SHADER_NODE_NAMESPACE
#endif//HGL_GRAPH_SHADER_NODE_INCLUDE