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 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
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