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/server/network.H> 00021 00022 #include <archon/x3d/sai/app_scene.H> 00023 00024 namespace Archon 00025 { 00026 namespace X3D 00027 { 00028 namespace SAI 00029 { 00030 using namespace Utilities; 00031 00032 void ApplicationScene::launch(Ref<GroupingNode> sock) 00033 throw(ForwardDestroyedException, x3d::sai::AlreadyLaunchedException, 00034 UnexpectedException) 00035 { 00036 Ref<Server> serv = server.getRef(); 00037 00038 Time time = serv->getNextTimeStamp(); 00039 Ref<ExecutionContext> applicationContainerContext = 00040 sock->context.getRef(); 00041 00042 Ref<ApplicationLink> applicationLink = 00043 new ApplicationLink(applicationContainerContext); 00044 applicationLink->setSubScene(Ref<SceneBase>(this)); 00045 00046 Ref<Transform> trans = new Transform(applicationContainerContext); 00047 trans->add(GroupingNode::childrenField, applicationLink, time); 00048 00049 Mutex::Lock l(launchMutex); 00050 if(socket) throw x3d::sai::AlreadyLaunchedException(); 00051 sock->add(GroupingNode::childrenField, trans, time); 00052 socket.reset(sock); 00053 transform.reset(trans); 00054 } 00055 00056 void ApplicationScene::withdraw() throw(UnexpectedException) 00057 { 00058 Mutex::Lock l(launchMutex); 00059 if(!socket) return; 00060 00061 try 00062 { 00063 Ref<Server> serv = server.getRef(); 00064 00065 Ref<GroupingNode> sock = socket.getRef(); 00066 Ref<Transform> trans = transform.getRef(); 00067 00068 Time time = serv->getNextTimeStamp(); 00069 sock->remove(GroupingNode::childrenField, trans, time); 00070 } 00071 catch(ForwardDestroyedException) {} 00072 00073 transform.reset(); 00074 socket.reset(); 00075 } 00076 } 00077 } 00078 }