00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHVARIABLE_HPP
00025 #define SHVARIABLE_HPP
00026
00027 #include "ShDllExport.hpp"
00028 #include "ShRefCount.hpp"
00029 #include "ShSwizzle.hpp"
00030 #include "ShUtility.hpp"
00031 #include "ShMetaForwarder.hpp"
00032 #include "ShVariant.hpp"
00033 #include "ShVariableNode.hpp"
00034
00035 namespace SH {
00036
00037 class ShProgram;
00038
00045 class
00046 SH_DLLEXPORT ShVariable : public ShMetaForwarder {
00047 public:
00048 ShVariable();
00049 ShVariable(const ShVariableNodePtr& node);
00050 ShVariable(const ShVariableNodePtr& node, const ShSwizzle& swizzle, bool neg);
00051
00052 ~ShVariable() {}
00053
00054
00055
00056
00057
00058
00059 ShVariable& operator=(const ShProgram& prg);
00060
00061
00062 void attach(const ShProgram& prg);
00063
00064 bool null() const;
00065
00066 bool uniform() const;
00067 bool hasValues() const;
00068
00069
00070 int size() const;
00071
00072
00073 ShValueType valueType() const;
00074
00080
00081
00083
00084 void rangeVariant(const ShVariant* low, const ShVariant* high);
00085
00087
00088 ShVariantPtr lowBoundVariant() const;
00089
00091 ShVariantPtr highBoundVariant() const;
00092
00094
00096 const ShSwizzle& swizzle() const;
00097
00099 const ShVariableNodePtr& node() const;
00100
00102 bool neg() const;
00103
00104 bool& neg();
00105
00107
00109 ShVariantPtr getVariant() const;
00110 ShVariantPtr getVariant(int index) const;
00111
00127 bool loadVariant(ShVariant *&result) const;
00128 void updateVariant();
00129
00130
00131
00136 void setVariant(const ShVariant* other, bool neg, const ShSwizzle &writemask);
00137 void setVariant(ShVariantCPtr other, bool neg, const ShSwizzle &writemask);
00138
00139
00143 void setVariant(const ShVariant* other, int index);
00144 void setVariant(ShVariantCPtr other, int index);
00145
00146
00150 void setVariant(const ShVariant* other);
00151 void setVariant(ShVariantCPtr other);
00152
00153
00154
00155 ShVariable operator()() const;
00156 ShVariable operator()(int) const;
00157 ShVariable operator()(int, int) const;
00158 ShVariable operator()(int, int, int) const;
00159 ShVariable operator()(int, int, int, int) const;
00160 ShVariable operator()(int size, int indices[]) const;
00161 ShVariable operator()(const ShSwizzle &swizzle) const;
00162
00163
00164 ShVariable operator-() const;
00165
00166 bool operator==(const ShVariable& other) const;
00167 bool operator!=(const ShVariable& other) const { return !((*this) == other); }
00168
00172 void clone(const ShVariable& other);
00173
00174 protected:
00175
00176 ShVariableNodePtr m_node;
00177 ShSwizzle m_swizzle;
00178 bool m_neg;
00179
00180 friend SH_DLLEXPORT std::ostream& operator<<(std::ostream& out, const ShVariable& shVariableToPrint);
00181 };
00182
00183 }
00184
00185 #endif