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 2003-2005 Serious Hack Inc.
00004 // 
00005 // This software is provided 'as-is', without any express or implied
00006 // warranty. In no event will the authors be held liable for any damages
00007 // arising from the use of this software.
00008 // 
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it
00011 // freely, subject to the following restrictions:
00012 // 
00013 // 1. The origin of this software must not be misrepresented; you must
00014 // not claim that you wrote the original software. If you use this
00015 // software in a product, an acknowledgment in the product documentation
00016 // would be appreciated but is not required.
00017 // 
00018 // 2. Altered source versions must be plainly marked as such, and must
00019 // not be misrepresented as being the original software.
00020 // 
00021 // 3. This notice may not be removed or altered from any source
00022 // distribution.
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   /* Executes a program and assigns the result to this variable.
00055    *
00056    * In retained mode, the prg gets inserted into the ShProgram currently
00057    * being defined.
00058    */
00059   ShVariable& operator=(const ShProgram& prg);
00060  
00061   /* Attaches a ShProgram to this variable, making it a dependent uniform. */
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   // TODO check if this works when swizzle contains one index more than once
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

Generated on Thu Apr 21 17:32:50 2005 for Sh by  doxygen 1.4.2