ShFixedManipulator.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHFIXEDMANIPULATOR_HPP
00021 #define SHFIXEDMANIPULATOR_HPP
00022 
00023 #include <vector>
00024 #include "ShDllExport.hpp"
00025 #include "ShProgram.hpp"
00026 
00027 namespace SH {
00028 
00029 typedef ShProgramNode::VarList::const_iterator ShManipVarIterator;
00030 
00036 class
00037 SH_DLLEXPORT ShFixedManipulatorNode: public ShRefCountable { 
00038   public:
00039     ShFixedManipulatorNode();
00040     virtual ~ShFixedManipulatorNode(); 
00041 
00047     virtual ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const = 0;
00048 
00054     virtual ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const = 0;
00055 };
00056 typedef ShPointer<ShFixedManipulatorNode> ShFixedManipulator;
00057 
00058 class
00059 SH_DLLEXPORT ShKeepNode: public ShFixedManipulatorNode {
00060   public:
00061     ShKeepNode(int numChannels); 
00062     ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00063     ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00064 
00065   private:
00066     int m_numChannels;
00067 };
00068 SH_DLLEXPORT
00069 ShFixedManipulator shKeep(int numChannels = 1);
00070 
00071 class
00072 SH_DLLEXPORT ShLoseNode: public ShFixedManipulatorNode {
00073   public:
00074     ShLoseNode(int numChannels); 
00075     ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00076     ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00077 
00078   private:
00079     int m_numChannels;
00080 };
00081 SH_DLLEXPORT
00082 ShFixedManipulator shLose(int numChannels = 1);
00083 
00084 class
00085 SH_DLLEXPORT ShDupNode: public ShFixedManipulatorNode {
00086   public:
00087     ShDupNode(int numDups);
00088     ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00089     ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00090 
00091   private:
00092     int m_numDups;
00093 };
00094 SH_DLLEXPORT
00095 ShFixedManipulator shDup(int numDups = 2);
00096 
00097 // TODO make class names less clunky
00098 // This node can only be created by using the & operator with another fixed manipulator
00099 //
00100 // This is the only manip node that allows number of channels
00101 // not to match when connected to a ShProgram. (extras are handled in the
00102 // default connect way when inputs != outpus)
00103 //
00104 class
00105 SH_DLLEXPORT ShProgramManipNode: public ShFixedManipulatorNode {
00106   public:
00107     ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00108     ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00109 
00110   private:
00111     ShProgram p;
00112 
00113     ShProgramManipNode(const ShProgram &p);
00114 
00115   friend SH_DLLEXPORT
00116   ShFixedManipulator operator&(const ShFixedManipulator &m, const ShProgram &p );
00117   friend SH_DLLEXPORT
00118   ShFixedManipulator operator&( const ShProgram &p, const ShFixedManipulator &m);
00119 };
00120 
00121 // This node can only be created using the & operator with another fixed manipulator
00122 class ShTreeManipNode: public ShFixedManipulatorNode {
00123   public:
00124     ShProgram applyToInputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00125     ShProgram applyToOutputs(ShManipVarIterator &finger, ShManipVarIterator end) const;
00126   private:
00127     ShFixedManipulator a, b;
00128 
00129     ShTreeManipNode(const ShFixedManipulator &a, const ShFixedManipulator &b); 
00130 
00131     friend SH_DLLEXPORT
00132 
00133     ShFixedManipulator operator&(const ShFixedManipulator &m, const ShFixedManipulator &n);
00134 };
00135 
00136 SH_DLLEXPORT
00137 ShProgram operator<<(const ShProgram &p, const ShFixedManipulator &m); 
00138 SH_DLLEXPORT
00139 ShProgram operator<<(const ShFixedManipulator &m, const ShProgram &p);
00140 SH_DLLEXPORT
00141 ShFixedManipulator operator&(const ShFixedManipulator &m, 
00142                              const ShFixedManipulator &n);
00143 SH_DLLEXPORT
00144 ShFixedManipulator operator&(const ShFixedManipulator &m, 
00145                              const ShProgram &p );
00146 SH_DLLEXPORT
00147 ShFixedManipulator operator&(const ShProgram &p, 
00148                              const ShFixedManipulator &m);
00149 
00150 }
00151 
00152 #endif

Generated on Wed Nov 9 15:29:30 2005 for Sh by  doxygen 1.4.5