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

ShContext.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 SHCONTEXT_HPP
00021 #define SHCONTEXT_HPP
00022 
00023 #include <string>
00024 #include <map>
00025 #include "ShDllExport.hpp"
00026 #include "ShProgram.hpp"
00027 
00028 namespace SH {
00029 
00030 class
00031 SH_DLLEXPORT ShContext {
00032 public:
00033   static ShContext* current();
00034 
00036   int optimization() const;
00037   void optimization(int level);
00038 
00041   bool throw_errors() const;
00042   void throw_errors(bool on);
00043 
00047   void disable_optimization(const std::string& name);
00049   void enable_optimization(const std::string& name);
00051   bool optimization_disabled(const std::string& name) const;
00052 
00053   bool is_bound(const std::string& target);
00054   ShProgramNodePtr bound_program(const std::string& target);
00055 
00056   
00057   typedef std::map<std::string, ShProgram> BoundProgramMap;
00058 
00059   BoundProgramMap::iterator begin_bound();
00060   BoundProgramMap::iterator end_bound();
00061 
00063   void set_binding(const std::string& unit, const ShProgram& program);
00065   void unset_binding(const std::string& unit);
00066 
00068   ShProgramNodePtr parsing();
00069 
00071   void enter(const ShProgramNodePtr& program);
00072 
00074   void exit();
00075   
00076 private:
00077   ShContext();
00078 
00079   int m_optimization;
00080   bool m_throw_errors;
00081   
00082   BoundProgramMap m_bound;
00083   std::stack<ShProgramNodePtr> m_parsing;
00084 
00085   std::set<std::string> m_disabled_optimizations;
00086   
00087   static ShContext* m_instance;
00088 
00089   // NOT IMPLEMENTED
00090   ShContext(const ShContext& other);
00091   ShContext& operator=(const ShContext& other);
00092 };
00093 
00094 typedef ShContext::BoundProgramMap::iterator ShBoundIterator;
00095 
00097 SH_DLLEXPORT
00098 bool shIsBound(const std::string& target);
00099 
00101 SH_DLLEXPORT
00102 ShProgramNodePtr shBound(const std::string& target);
00103 
00105 SH_DLLEXPORT
00106 ShBoundIterator shBeginBound();
00107 
00109 SH_DLLEXPORT
00110 ShBoundIterator shEndBound();
00111 
00112 }
00113 
00114 #endif

Generated on Thu Jul 28 17:33:02 2005 for Sh by  doxygen 1.4.3-20050530