00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHVARIABLE_HPP
00021 #define SHVARIABLE_HPP
00022
00023 #include "ShDllExport.hpp"
00024 #include "ShRefCount.hpp"
00025 #include "ShSwizzle.hpp"
00026 #include "ShUtility.hpp"
00027 #include "ShMetaForwarder.hpp"
00028 #include "ShVariant.hpp"
00029 #include "ShVariableNode.hpp"
00030
00031 namespace SH {
00032
00033 class ShProgram;
00034
00041 class
00042 SH_DLLEXPORT ShVariable : public ShMetaForwarder {
00043 public:
00044 ShVariable();
00045 ShVariable(const ShVariableNodePtr& node);
00046 ShVariable(const ShVariableNodePtr& node, const ShSwizzle& swizzle, bool neg);
00047
00048 ~ShVariable() {}
00049
00050
00051
00052
00053
00054
00055 ShVariable& operator=(const ShProgram& prg);
00056
00057
00058 void attach(const ShProgram& prg);
00059
00060 bool null() const;
00061
00062 bool uniform() const;
00063 bool hasValues() const;
00064
00065
00066 int size() const;
00067
00068
00069 ShValueType valueType() const;
00070
00076
00077
00079
00080 void rangeVariant(const ShVariant* low, const ShVariant* high);
00081
00083
00084 ShVariantPtr lowBoundVariant() const;
00085
00087 ShVariantPtr highBoundVariant() const;
00088
00090
00092 const ShSwizzle& swizzle() const;
00093
00095 const ShVariableNodePtr& node() const;
00096
00098 bool neg() const;
00099
00100 bool& neg();
00101
00103
00105 ShVariantPtr getVariant() const;
00106 ShVariantPtr getVariant(int index) const;
00107
00123 bool loadVariant(ShVariant *&result) const;
00124 void updateVariant();
00125
00126
00127
00132 void setVariant(const ShVariant* other, bool neg, const ShSwizzle &writemask);
00133 void setVariant(const ShVariantCPtr& other, bool neg, const ShSwizzle &writemask);
00134
00135
00139 void setVariant(const ShVariant* other, int index);
00140 void setVariant(const ShVariantCPtr& other, int index);
00141
00142
00146 void setVariant(const ShVariant* other);
00147 void setVariant(const ShVariantCPtr& other);
00148
00149
00150
00151 ShVariable operator()() const;
00152 ShVariable operator()(int) const;
00153 ShVariable operator()(int, int) const;
00154 ShVariable operator()(int, int, int) const;
00155 ShVariable operator()(int, int, int, int) const;
00156 ShVariable operator()(int size, int indices[]) const;
00157 ShVariable operator()(const ShSwizzle &swizzle) const;
00158
00159
00160 ShVariable operator-() const;
00161
00162 bool operator==(const ShVariable& other) const;
00163 bool operator!=(const ShVariable& other) const { return !((*this) == other); }
00164
00168 void clone(const ShVariable& other);
00169
00170 protected:
00171
00172 ShVariableNodePtr m_node;
00173 ShSwizzle m_swizzle;
00174 bool m_neg;
00175
00176 friend SH_DLLEXPORT std::ostream& operator<<(std::ostream& out, const ShVariable& shVariableToPrint);
00177 };
00178
00179 }
00180
00181 #endif