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 SH_PALETTE = 7
00050 };
00051
00054 enum ShSemanticType {
00055 SH_ATTRIB,
00056 SH_POINT,
00057 SH_VECTOR,
00058 SH_NORMAL,
00059 SH_COLOR,
00060 SH_TEXCOORD,
00061 SH_POSITION
00062 };
00063
00064
00065 SH_DLLEXPORT
extern const char* ShBindingTypeName[];
00066 SH_DLLEXPORT
extern const char* ShSemanticTypeName[];
00067
00068
class ShProgramNode;
00069
00070
00071
struct ShVariableNodeEval;
00072
00075 class
00076
SH_DLLEXPORT ShVariableNode :
public virtual ShRefCountable,
00077
public virtual ShMeta {
00078
public:
00079 ShVariableNode(
ShBindingType kind,
int size,
ShSemanticType type = SH_ATTRIB);
00080
virtual ~ShVariableNode();
00081
00082
bool uniform()
const;
00083
bool hasValues()
const;
00084
00085
int size()
const;
00086
00087
00088
void size(
int size);
00089
00090
void lock();
00091
void unlock();
00092
00093
00094 typedef float ValueType;
00095
00096
00097 std::string name() const;
00098
void name(const std::string& n);
00099
00101
void range(ShVariableNode::ValueType low, ShVariableNode::ValueType high);
00102 ShVariableNode::ValueType lowBound() const;
00103 ShVariableNode::ValueType highBound() const;
00104
00105 ShBindingType kind() const;
00106 ShSemanticType specialType() const;
00107
void specialType(ShSemanticType);
00108
00109 std::string nameOfType() const;
00110
00115
void setValue(
int i, ValueType value);
00116
00118 ValueType getValue(
int i) const;
00119
00124
void addValues();
00125
00131
00132
00133
void attach(const
ShPointer<
ShProgramNode>& evaluator);
00134
00136
void update();
00137
00139 const
ShPointer<
ShProgramNode>& evaluator() const;
00140
00143 #ifdef SH_USE_MEMORY_POOL
00144
00145
void* operator new(std::size_t size);
00146
void operator delete(
void* d);
00147 #endif
00148
00149 protected:
00150
00151
void add_dependent(ShVariableNode* dep);
00152
void remove_dependent(ShVariableNode* dep);
00153
00154
void update_dependents();
00155
void detach_dependencies();
00156
00157
bool m_uniform;
00158
00159 ShBindingType m_kind;
00160 ShSemanticType m_specialType;
00161
int m_size;
00162
int m_id;
00163
int m_locked;
00164
00165 ValueType* m_values;
00166
00167
00168 ValueType m_lowBound, m_highBound;
00169
00170
00171 mutable ShVariableNodeEval* m_eval;
00172 std::list<ShVariableNode*> m_dependents;
00173
00174 static
int m_maxID;
00175
00176 #ifdef SH_USE_MEMORY_POOL
00177 static ShPool* m_pool;
00178 #endif
00179 };
00180
00181 typedef
ShPointer<ShVariableNode>
ShVariableNodePtr;
00182 typedef
ShPointer<const ShVariableNode>
ShVariableNodeCPtr;
00183
00184 }
00185
00186 #endif