Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShVariable.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory
00004 // Project administrator: Michael D. McCool
00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa,
00006 //          Michael D. McCool
00007 // 
00008 // This software is provided 'as-is', without any express or implied
00009 // warranty. In no event will the authors be held liable for any damages
00010 // arising from the use of this software.
00011 // 
00012 // Permission is granted to anyone to use this software for any purpose,
00013 // including commercial applications, and to alter it and redistribute it
00014 // freely, subject to the following restrictions:
00015 // 
00016 // 1. The origin of this software must not be misrepresented; you must
00017 // not claim that you wrote the original software. If you use this
00018 // software in a product, an acknowledgment in the product documentation
00019 // would be appreciated but is not required.
00020 // 
00021 // 2. Altered source versions must be plainly marked as such, and must
00022 // not be misrepresented as being the original software.
00023 // 
00024 // 3. This notice may not be removed or altered from any source
00025 // distribution.
00027 #ifndef SHVARIABLE_HPP
00028 #define SHVARIABLE_HPP
00029 
00030 #include "ShDllExport.hpp"
00031 #include "ShRefCount.hpp"
00032 #include "ShSwizzle.hpp"
00033 #include "ShUtility.hpp"
00034 #include "ShMetaForwarder.hpp"
00035 #include "ShVariant.hpp"
00036 #include "ShVariableNode.hpp"
00037 
00038 namespace SH {
00039 
00040 class ShProgram;
00041 
00048 class 
00049 SH_DLLEXPORT ShVariable : public ShMetaForwarder {
00050 public:
00051   ShVariable();
00052   ShVariable(const ShVariableNodePtr& node);
00053   ShVariable(const ShVariableNodePtr& node, const ShSwizzle& swizzle, bool neg);
00054 
00055   ~ShVariable() {}
00056 
00057   ShVariable& operator=(const ShProgram& prg);
00058   
00059   bool null() const; 
00060   
00061   bool uniform() const; 
00062   bool hasValues() const; 
00063 
00064   
00065   int size() const; 
00066 
00067                     
00068   ShValueType valueType() const; 
00069 
00075 
00076   
00078   // TODO check if this works when swizzle contains one index more than once
00079   void rangeVariant(const ShVariant* low, const ShVariant* high);
00080 
00082   // @{
00083   ShVariantPtr lowBoundVariant() const;
00084 
00086   ShVariantPtr highBoundVariant() const;
00087 
00089   
00091   const ShSwizzle& swizzle() const;
00092 
00094   const ShVariableNodePtr& node() const;
00095 
00097   bool neg() const;
00098 
00099   bool& neg();
00100 
00102   
00104   ShVariantPtr getVariant() const;
00105   ShVariantPtr getVariant(int index) const;
00106 
00122   bool loadVariant(ShVariant *&result) const;
00123   void updateVariant();
00124   // @}
00125 
00126   
00131   void setVariant(const ShVariant* other, bool neg, const ShSwizzle &writemask);
00132   void setVariant(ShVariantCPtr other, bool neg, const ShSwizzle &writemask);
00133   // @}
00134  
00138   void setVariant(const ShVariant* other, int index);
00139   void setVariant(ShVariantCPtr other, int index);
00140   // @}
00141 
00145   void setVariant(const ShVariant* other);
00146   void setVariant(ShVariantCPtr other);
00147   // @}
00148 
00149 
00150   ShVariable operator()() const; 
00151   ShVariable operator()(int) const;
00152   ShVariable operator()(int, int) const;
00153   ShVariable operator()(int, int, int) const;
00154   ShVariable operator()(int, int, int, int) const;
00155   ShVariable operator()(int size, int indices[]) const;
00156   
00157   ShVariable operator-() const;
00158 
00159   bool operator==(const ShVariable& other) const;
00160   bool operator!=(const ShVariable& other) const { return !((*this) == other); }
00161 
00165   void clone(const ShVariable& other);
00166   
00167 protected:
00168   
00169   ShVariableNodePtr m_node; 
00170   ShSwizzle m_swizzle; 
00171   bool m_neg; 
00172 
00173   friend SH_DLLEXPORT std::ostream& operator<<(std::ostream& out, const ShVariable& shVariableToPrint);
00174 };
00175 
00176 }
00177 
00178 #endif

Generated on Mon Jan 24 18:36:36 2005 for Sh by  doxygen 1.4.1