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

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

Generated on Wed Jun 15 18:12:39 2005 for Sh by  doxygen 1.4.3-20050530