00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
#ifndef SHVARIABLENODE_HPP
00028
#define SHVARIABLENODE_HPP
00029
00030
#include <string>
00031
#include <list>
00032
#include "ShDllExport.hpp"
00033
#include "ShRefCount.hpp"
00034
#include "ShMeta.hpp"
00035
#include "ShPool.hpp"
00036
00037
namespace SH {
00038
00041 enum ShBindingType {
00042 SH_INPUT = 0,
00043 SH_OUTPUT = 1,
00044 SH_INOUT = 2,
00045 SH_TEMP = 3,
00046 SH_CONST = 4,
00047 SH_TEXTURE = 5,
00048 SH_STREAM = 6
00049 };
00050
00053 enum ShSemanticType {
00054 SH_ATTRIB,
00055 SH_POINT,
00056 SH_VECTOR,
00057 SH_NORMAL,
00058 SH_COLOR,
00059 SH_TEXCOORD,
00060 SH_POSITION
00061 };
00062
00063
00064 SH_DLLEXPORT
extern const char* ShBindingTypeName[];
00065 SH_DLLEXPORT
extern const char* ShSemanticTypeName[];
00066
00067
class ShProgramNode;
00068
00069
00070
struct ShVariableNodeEval;
00071
00074 class
00075
SH_DLLEXPORT ShVariableNode :
public virtual ShRefCountable,
00076
public virtual ShMeta {
00077
public:
00078 ShVariableNode(
ShBindingType kind,
int size,
ShSemanticType type = SH_ATTRIB);
00079
virtual ~ShVariableNode();
00080
00081
bool uniform()
const;
00082
bool hasValues()
const;
00083
00084
int size()
const;
00085
00086
00087
void size(
int size);
00088
00089
void lock();
00090
void unlock();
00091
00092
00093 typedef float ValueType;
00094
00095
00096 std::string name() const;
00097
void name(const std::string& n);
00098
00100
void range(ShVariableNode::ValueType low, ShVariableNode::ValueType high);
00101 ShVariableNode::ValueType lowBound() const;
00102 ShVariableNode::ValueType highBound() const;
00103
00104 ShBindingType kind() const;
00105 ShSemanticType specialType() const;
00106
void specialType(ShSemanticType);
00107
00108 std::string nameOfType() const;
00109
00114
void setValue(
int i, ValueType value);
00115
00117 ValueType getValue(
int i) const;
00118
00123
void addValues();
00124
00130
00131
00132
void attach(const
ShPointer<
ShProgramNode>& evaluator);
00133
00135
void update();
00136
00138 const
ShPointer<
ShProgramNode>& evaluator() const;
00139
00142 #ifdef SH_USE_MEMORY_POOL
00143
00144
void* operator new(std::size_t size);
00145
void operator delete(
void* d);
00146 #endif
00147
00148 protected:
00149
00150
void add_dependent(ShVariableNode* dep);
00151
void remove_dependent(ShVariableNode* dep);
00152
00153
void update_dependents();
00154
void detach_dependencies();
00155
00156
bool m_uniform;
00157
00158 ShBindingType m_kind;
00159 ShSemanticType m_specialType;
00160
int m_size;
00161
int m_id;
00162
int m_locked;
00163
00164 ValueType* m_values;
00165
00166
00167 ValueType m_lowBound, m_highBound;
00168
00169
00170 mutable ShVariableNodeEval* m_eval;
00171 std::list<ShVariableNode*> m_dependents;
00172
00173 static
int m_maxID;
00174
00175 #ifdef SH_USE_MEMORY_POOL
00176 static ShPool* m_pool;
00177 #endif
00178 };
00179
00180 typedef
ShPointer<ShVariableNode>
ShVariableNodePtr;
00181 typedef
ShPointer<const ShVariableNode>
ShVariableNodeCPtr;
00182
00183 }
00184
00185 #endif