00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 {
00061 return m_bound.begin();
00062 }
00063
00064 BoundProgramMap::iterator end_bound()
00065 {
00066 return m_bound.end();
00067 }
00068
00070 void set_binding(const std::string& unit, const ShProgram& program);
00072 void unset_binding(const std::string& unit);
00073
00075 ShProgramNodePtr parsing();
00076
00078 void enter(const ShProgramNodePtr& program);
00079
00081 void exit();
00082
00083 private:
00084 ShContext();
00085
00086 int m_optimization;
00087 bool m_throw_errors;
00088
00089 BoundProgramMap m_bound;
00090 std::stack<ShProgramNodePtr> m_parsing;
00091
00092 std::set<std::string> m_disabled_optimizations;
00093
00094 static ShContext* m_instance;
00095
00096
00097 ShContext(const ShContext& other);
00098 ShContext& operator=(const ShContext& other);
00099 };
00100
00101 typedef ShContext::BoundProgramMap::iterator ShBoundIterator;
00102
00104 SH_DLLEXPORT
00105 bool shIsBound(const std::string& target);
00106
00108 SH_DLLEXPORT
00109 ShProgramNodePtr shBound(const std::string& target);
00110
00112 inline ShBoundIterator shBeginBound()
00113 {
00114 return ShContext::current()->begin_bound();
00115 }
00116
00118 inline ShBoundIterator shEndBound()
00119 {
00120 return ShContext::current()->end_bound();
00121 }
00122
00123 }
00124
00125 #endif