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

ShContext.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 SHCONTEXT_HPP 00028 #define SHCONTEXT_HPP 00029 00030 #include <string> 00031 #include <map> 00032 #include "ShDllExport.hpp" 00033 #include "ShProgram.hpp" 00034 00035 namespace SH { 00036 00037 class 00038 SH_DLLEXPORT ShContext { 00039 public: 00040 static ShContext* current(); 00041 00043 int optimization() const; 00044 void optimization(int level); 00045 00048 bool throw_errors() const; 00049 void throw_errors(bool on); 00050 00054 void disable_optimization(const std::string& name); 00056 void enable_optimization(const std::string& name); 00058 bool optimization_disabled(const std::string& name) const; 00059 00060 typedef std::map<std::string, ShProgram> BoundProgramMap; 00061 00062 BoundProgramMap::iterator begin_bound(); 00063 BoundProgramMap::iterator end_bound(); 00064 00066 void set_binding(const std::string& unit, ShProgram program); 00067 00069 ShProgramNodePtr parsing(); 00070 00072 void enter(const ShProgramNodePtr& program); 00073 00075 void exit(); 00076 00077 private: 00078 ShContext(); 00079 00080 int m_optimization; 00081 bool m_throw_errors; 00082 00083 BoundProgramMap m_bound; 00084 std::stack<ShProgramNodePtr> m_parsing; 00085 00086 std::set<std::string> m_disabled_optimizations; 00087 00088 static ShContext* m_instance; 00089 00090 // NOT IMPLEMENTED 00091 ShContext(const ShContext& other); 00092 ShContext& operator=(const ShContext& other); 00093 }; 00094 00095 typedef ShContext::BoundProgramMap::iterator ShBoundIterator; 00096 00098 SH_DLLEXPORT 00099 ShBoundIterator shBeginBound(); 00100 00102 SH_DLLEXPORT 00103 ShBoundIterator shEndBound(); 00104 00105 00106 } 00107 00108 #endif

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