00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <archon/x3d/proxy/context.H>
00021
00022 #include <archon/x3d/proxy/node.autogen.H>
00023
00024 namespace Archon
00025 {
00026 namespace X3D
00027 {
00028 namespace Proxy
00029 {
00030 Uri ExecutionContext::getBaseUri() const
00031 {
00032 CORBA::String_var u = session->session->getBaseUri(id);
00033 try
00034 {
00035 return Uri(string(u));
00036 }
00037 catch(Uri::SyntaxException &)
00038 {
00039 ARCHON_THROW1(Session::ProtocolException, "Got invalid URI");
00040 }
00041 }
00042
00043 Ref<Group> ExecutionContext::getRootGroup() const
00044 {
00045 Ref<NodeBase> n =
00046 session->id2node(session->session->getRootGroup(id));
00047 if(!n) return 0;
00048 Group *g = dynamic_cast<Group *>(n.get());
00049 if(!g) ARCHON_THROW1(Session::ProtocolException,
00050 "Context root group was not a Group");
00051 return g;
00052 }
00053
00054 void ExecutionContext::setRootGroup(Ref<Group> g)
00055 {
00056 session->session->setRootGroup(id, g->id);
00057 }
00058
00059 Ref<Node> ExecutionContext::getNamedNode(string name) const
00060 {
00061 Ref<NodeBase> n =
00062 session->id2node(session->session->getNode(id, name.c_str()));
00063 if(!n) return 0;
00064 Node *m = dynamic_cast<Node *>(n.get());
00065 if(!m) ARCHON_THROW1(Session::ProtocolException,
00066 "Named node was not a Node");
00067 return m;
00068 }
00069
00070 void ExecutionContext::route(Field *s, Field *t, bool destroy)
00071 {
00072 if(destroy)
00073 session->session->delRoute(id,
00074 s->self->id, s->id,
00075 t->self->id, t->id);
00076 else
00077 session->session->addRoute(id,
00078 s->self->id, s->id,
00079 t->self->id, t->id);
00080 }
00081 }
00082 }
00083 }