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

ShFixedManipulator.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 SHFIXEDMANIPULATOR_HPP 00028 #define SHFIXEDMANIPULATOR_HPP 00029 00030 #include <vector> 00031 #include "ShDllExport.hpp" 00032 #include "ShProgram.hpp" 00033 00034 namespace SH { 00035 00036 typedef ShProgramNode::VarList::const_iterator ShManipVarIterator; 00037 00043 class 00044 SH_DLLEXPORT ShFixedManipulatorNode: public ShRefCountable { 00045 public: 00046 ShFixedManipulatorNode(); 00047 virtual ~ShFixedManipulatorNode(); 00048 00054 virtual ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const = 0; 00055 00061 virtual ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const = 0; 00062 }; 00063 typedef ShPointer<ShFixedManipulatorNode> ShFixedManipulator; 00064 00065 class 00066 SH_DLLEXPORT ShKeepNode: public ShFixedManipulatorNode { 00067 public: 00068 ShKeepNode(int numChannels); 00069 ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00070 ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00071 00072 private: 00073 int m_numChannels; 00074 }; 00075 SH_DLLEXPORT 00076 ShFixedManipulator shKeep(int numChannels = 1); 00077 00078 class 00079 SH_DLLEXPORT ShLoseNode: public ShFixedManipulatorNode { 00080 public: 00081 ShLoseNode(int numChannels); 00082 ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00083 ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00084 00085 private: 00086 int m_numChannels; 00087 }; 00088 SH_DLLEXPORT 00089 ShFixedManipulator shLose(int numChannels = 1); 00090 00091 class 00092 SH_DLLEXPORT ShDupNode: public ShFixedManipulatorNode { 00093 public: 00094 ShDupNode(int numDups); 00095 ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00096 ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00097 00098 private: 00099 int m_numDups; 00100 }; 00101 SH_DLLEXPORT 00102 ShFixedManipulator shDup(int numDups = 2); 00103 00104 // TODO make class names less clunky 00105 // This node can only be created by using the & operator with another fixed manipulator 00106 // 00107 // This is the only manip node that allows number of channels 00108 // not to match when connected to a ShProgram. (extras are handled in the 00109 // default connect way when inputs != outpus) 00110 // 00111 class 00112 SH_DLLEXPORT ShProgramManipNode: public ShFixedManipulatorNode { 00113 public: 00114 ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00115 ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00116 00117 private: 00118 ShProgram p; 00119 00120 ShProgramManipNode(const ShProgram &p); 00121 00122 friend SH_DLLEXPORT 00123 ShFixedManipulator operator&(const ShFixedManipulator &m, const ShProgram &p ); 00124 friend SH_DLLEXPORT 00125 ShFixedManipulator operator&( const ShProgram &p, const ShFixedManipulator &m); 00126 }; 00127 00128 // This node can only be created using the & operator with another fixed manipulator 00129 class ShTreeManipNode: public ShFixedManipulatorNode { 00130 public: 00131 ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00132 ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const; 00133 private: 00134 ShFixedManipulator a, b; 00135 00136 ShTreeManipNode(const ShFixedManipulator &a, const ShFixedManipulator &b); 00137 00138 friend SH_DLLEXPORT 00139 00140 ShFixedManipulator operator&(const ShFixedManipulator &m, const ShFixedManipulator &n); 00141 }; 00142 00143 SH_DLLEXPORT 00144 ShProgram operator<<(const ShProgram &p, const ShFixedManipulator &m); 00145 SH_DLLEXPORT 00146 ShProgram operator<<(const ShFixedManipulator &m, const ShProgram &p); 00147 SH_DLLEXPORT 00148 ShFixedManipulator operator&(const ShFixedManipulator &m, 00149 const ShFixedManipulator &n); 00150 SH_DLLEXPORT 00151 ShFixedManipulator operator&(const ShFixedManipulator &m, 00152 const ShProgram &p ); 00153 SH_DLLEXPORT 00154 ShFixedManipulator operator&(const ShProgram &p, 00155 const ShFixedManipulator &m); 00156 00157 } 00158 00159 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7