session.H

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 #ifndef ARCHON_X3D_SAI_SESSION_H
00021 #define ARCHON_X3D_SAI_SESSION_H
00022 
00023 #include <vector>
00024 #include <queue>
00025 
00026 #include <archon/util/logger.H>
00027 #include <archon/util/ref.H>
00028 #include <archon/util/mutex.H>
00029 
00030 #include <archon/x3d/server/load.H>
00031 
00032 #include <archon/x3d/sai/orb.H>
00033 #include <archon/x3d/sai/sai.H>
00034 #include <archon/x3d/sai/value.H>
00035 #include <archon/x3d/sai/change.H>
00036 #include <archon/x3d/sai/app_scene.H>
00037 
00038 namespace Archon
00039 {
00040   namespace X3D
00041   {
00042     namespace SAI
00043     {
00044       using namespace Utilities;
00045   
00046       struct Listener;
00047       struct ExternalRouteHead;
00048 
00049       struct Session: Porter, AbstractFileServer, Logger
00050       {
00051         Session(Ref<Listener> listener,
00052                 x3d::sai::Application_ptr);
00053       
00054         ~Session();
00055 
00061         x3d::sai::Session_ptr createServant(Time heartbeat);
00062 
00063         unsigned long node2id(Ref<NodeBase>);
00064         Ref<NodeBase> id2node(unsigned long) throw(IllegalNodeIdException);
00065 
00066         // Session (or Browser) services
00067         char *getServerName();
00068         CORBA::Double getCurrentFrameRate();
00069         CORBA::ULong createApplicationScene(const char *, CORBA::Boolean);
00070         CORBA::ULong loadApplicationScene(const char *, CORBA::Boolean);
00071         void launchApplicationScene(CORBA::ULong);
00072         void withdrawApplicationScene(CORBA::ULong);
00073         void beginUpdate();
00074         void endUpdate();
00075         void print(const char *);
00076         void setSynchronizedChangesEnabled(CORBA::Boolean);
00077         void disposeBatch(const x3d::sai::DisposeSeq &,
00078                           const x3d::sai::DisposeSeq &);
00079         void disposeSession();
00080 
00081         // ExecutionContext services
00082         char *getBaseUri(CORBA::ULong);
00083         CORBA::ULong getRootGroup(CORBA::ULong);
00084         void setRootGroup(CORBA::ULong, CORBA::ULong);
00085         CORBA::ULong createNode(CORBA::ULong, const char *);
00086         CORBA::ULong createNode(CORBA::ULong, CORBA::ULong);
00087         CORBA::ULong getNode(CORBA::ULong, const char *);
00088         void addRoute(CORBA::ULong, CORBA::ULong, CORBA::ULong,
00089                       CORBA::ULong, CORBA::ULong);
00090         void delRoute(CORBA::ULong, CORBA::ULong, CORBA::ULong,
00091                       CORBA::ULong, CORBA::ULong);
00092         CORBA::ULong createGroupFromStream(CORBA::ULong,
00093                                            x3d::sai::StreamReader_ptr);
00094         void disposeContext(CORBA::ULong);
00095 
00096         // Node services
00097         char *getNodeType(CORBA::ULong);
00098         CORBA::ULong getField(CORBA::ULong, const char *);
00099         void disposeNode(CORBA::ULong);
00100 
00101         // Field services
00102         CORBA::ULong getFieldType(CORBA::ULong, CORBA::ULong);
00103         char *getFieldName(CORBA::ULong, CORBA::ULong);
00104         CORBA::ULong getFieldAccessType(CORBA::ULong, CORBA::ULong);
00105         void registerFieldInterest(CORBA::ULong, CORBA::ULong,
00106                                    CORBA::ULong);
00107         void unRegisterFieldInterest(CORBA::ULong, CORBA::ULong,
00108                                      CORBA::ULong);
00109         x3d::sai::Value *getFieldValue(CORBA::ULong, CORBA::ULong);
00110         void setFieldValue(CORBA::ULong, CORBA::ULong,
00111                            const x3d::sai::Value &);
00112         x3d::sai::Value *getFieldValueAt(CORBA::ULong, CORBA::ULong,
00113                                          CORBA::ULong);
00114         void setFieldValueAt(CORBA::ULong, CORBA::ULong, CORBA::ULong,
00115                              const x3d::sai::Value &);
00116         void setFieldValueAdd(CORBA::ULong, CORBA::ULong,
00117                               const x3d::sai::Value &);
00118         void setFieldValueDel(CORBA::ULong, CORBA::ULong,
00119                               const x3d::sai::Value &);
00120         void disposeField(CORBA::ULong) {}
00121 
00122         void executeChanges();
00123 
00124         void handleChange(Ref<const ChangeBase>);
00125 
00126         void handleExternalEvent(const ValueBase *v, unsigned long cookie);
00127 
00128         void addRouteHead(Ref<const ExternalRouteHead>);
00129         void removeRouteHead(Ref<const ExternalRouteHead>);
00130       
00131         const BackRef<Listener> listener;
00132 
00133       private:
00134         void refForwardDestroy();
00135 
00136         Orb &orb;
00137 
00138         const x3d::sai::Application_var application;
00139 
00140 
00141         struct ExternalEvent;
00142         struct ExternalEventQueue;
00143 
00166         Ref<ExternalEventQueue> externalEventQueue;
00167 
00168         void pushEvents(const list<ExternalEvent> *);
00169       
00170 
00171         Mutex mutex;
00172 
00173         struct Servant;
00174         PortableServer::ObjectId_var servantId;
00175         bool active;
00176 
00183         x3d::sai::Session_ptr activate(Time heartbeat);
00184 
00188         void deactivate();
00189 
00194         RefMap<ExecutionContext> contextMap;
00195 
00200         RefMap<NodeBase> nodeMap;
00201 
00205         queue<Ref<const ChangeBase> > changeQueue;
00206 
00213         list<Ref<ApplicationScene> > launchedScenes;
00214 
00215         bool buffered;
00216         bool synchronizedChanges;
00217 
00218         // Overriding from X3D::AbstractFileServer
00219         Ref<Stream::Reader> request(string)
00220           throw(AbstractFileServer::RequestException);
00221 
00222         // Overriding from Utilities::Logger
00226         void log(string) throw();
00227 
00228         Mutex routeHeadsMutex;
00229         list<Ref<const ExternalRouteHead> > routeHeads;
00230       };
00231     }
00232   }
00233 }
00234 
00235 #endif // ARCHON_X3D_SAI_SESSION_H

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