00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_PROXY_CONTEXT_H
00021 #define ARCHON_X3D_PROXY_CONTEXT_H
00022
00023 #include <archon/util/uri.H>
00024
00025 #include <archon/x3d/proxy/session.H>
00026
00027 namespace Archon
00028 {
00029 namespace X3D
00030 {
00031 namespace Proxy
00032 {
00033 struct Session;
00034 struct NodeBase;
00035 struct Node;
00036 struct Group;
00037 struct Field;
00038
00039 template<typename F> struct EventSource;
00040 template<typename F> struct EventTarget;
00041
00042 struct ExecutionContext: virtual RefObjectBase
00043 {
00044 Ref<Session> getSession() const { return session; }
00045
00046 Uri getBaseUri() const;
00047 Ref<Group> getRootGroup() const;
00048 void setRootGroup(Ref<Group>);
00049 Ref<Node> getNamedNode(string name) const;
00050
00051
00052 ~ExecutionContext() { session->destroyContext(this); }
00053
00054 template<typename F, typename G>
00055 void createRoute(EventSource<F> &s, EventTarget<G> &t)
00056 {
00057 route(s, t, false);
00058 }
00059
00060 template<typename F, typename G>
00061 void removeRoute(EventSource<F> &s, EventTarget<G> &t)
00062 {
00063 route(s, t, true);
00064 }
00065
00066 protected:
00067 friend struct NodeBase;
00068 friend struct Session;
00069
00070 ExecutionContext(Session *s, unsigned long id):
00071 session(s), id(id), transCount(0) {}
00072
00073 Ref<Session> session;
00074
00075 unsigned long id;
00076 unsigned long transCount;
00077
00078 private:
00079 template<typename T> static void checkDerivation(T *) {}
00080
00081 template<typename F, typename G>
00082 void route(EventSource<F> &s, EventTarget<G> &t, bool destroy)
00083 {
00084 if(false) { F *p; checkDerivation<G>(p); }
00085 route(&s, &t, destroy);
00086 }
00087
00088 template<typename C, typename D>
00089 void route(EventSource<SFNode<C> > &s, EventTarget<SFNode<D> > &t, bool destroy)
00090 {
00091 if(false) { C *p; checkDerivation<D>(p); }
00092 route(&s, &t, destroy);
00093 }
00094
00095 template<typename C, typename D>
00096 void route(EventSource<MFNode<C> > &s, EventTarget<MFNode<D> > &t, bool destroy)
00097 {
00098 if(false) { C *p; checkDerivation<D>(p); }
00099 route(&s, &t, destroy);
00100 }
00101
00102 void route(Field *s, Field *t, bool destroy);
00103 };
00104 }
00105 }
00106 }
00107
00108 #endif // ARCHON_X3D_PROXY_CONTEXT_H