context.C

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
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 }

Generated on Sun Jul 30 22:55:43 2006 for Archon by  doxygen 1.4.4