00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PEEKABOT_SERVER_EXECUTION_CONTEXT_HH_INCLUDED
00023 #define PEEKABOT_SERVER_EXECUTION_CONTEXT_HH_INCLUDED
00024
00025
00026 #include "Types.hh"
00027 #include "Any.hh"
00028
00029 #include <string>
00030 #include <vector>
00031 #include <exception>
00032 #include <boost/filesystem/path.hpp>
00033
00034
00035 namespace peekabot
00036 {
00037 class Action;
00038 class SceneTree;
00039 class ActionSource;
00040 class Config;
00041 class Path;
00042 class SceneObject;
00043
00044 class ServerExecutionContext
00045 {
00046 public:
00047 class UniquenessViolation : public std::exception
00048 {
00049 std::string m_name;
00050
00051 public:
00052 UniquenessViolation(const std::string &name) throw()
00053 : m_name(name) {}
00054
00055 virtual ~UniquenessViolation() throw() {}
00056
00057 virtual const char *what() const throw()
00058 {
00059 return "Failed to add object, due to the name uniquness constraint.";
00060 }
00061
00062 const std::string &get_name() const throw()
00063 {
00064 return m_name;
00065 }
00066 };
00067
00068
00069 ServerExecutionContext(
00070 const Config &config,
00071 SceneTree &scene,
00072 ActionSource &action_source);
00073
00074 const Config &get_config() const;
00075
00080 Path make_data_path(const std::string &path) const;
00081
00082 void add_remote_file(
00083 const std::string &remote_filename,
00084 const void *data, std::size_t n);
00085
00086 void remove_remote_file(const std::string &remote_filename);
00087
00088 SceneObject *get_root() throw();
00089
00090 SceneObject *get_object(ObjectID id) throw();
00091
00092 template<class T>
00093 T *get_object(ObjectID id) throw()
00094 {
00095 return dynamic_cast<T *>(get_object(id));
00096 }
00097
00098 SceneObject *get_object(
00099 const std::string &path,
00100 SceneObject *path_parent = 0) throw();
00101
00102 void register_pseudonym(ObjectID real_id, ObjectID pseudonym_id) throw(std::exception);
00103
00104 void deregister_pseudonym(ObjectID pseudonym_id) throw(std::exception);
00105
00106
00107
00108 void post_response(Action *action) throw();
00109
00110 std::vector<SceneObject *> load_scene(const Path &path);
00111
00112 SceneObject *create_object(
00113 ObjectType type, const std::vector<Any> &args);
00114
00115 private:
00116 const Config &m_config;
00117 SceneTree &m_scene;
00118 ActionSource &m_action_source;
00119 };
00120 }
00121
00122
00123 #endif // PEEKABOT_SERVER_EXECUTION_CONTEXT_HH_INCLUDED