00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_PROXY_SESSION_H
00021 #define ARCHON_X3D_PROXY_SESSION_H
00022
00023 #include <archon/util/logger.H>
00024 #include <archon/util/ref.H>
00025 #include <archon/util/uri.H>
00026
00027 #include <archon/x3d/proxy/config.autogen.H>
00028 #include <archon/x3d/proxy/exception.H>
00029 #include <archon/x3d/proxy/orb.H>
00030 #include <archon/x3d/proxy/disposer.H>
00031 #include <archon/x3d/proxy/type.H>
00032 #include <archon/x3d/proxy/value.H>
00033
00034 namespace Archon
00035 {
00036 namespace X3D
00037 {
00038 namespace Proxy
00039 {
00040 using namespace std;
00041 using namespace Utilities;
00042
00043 struct Application;
00044 struct ExecutionContext;
00045 struct NodeBase;
00046 struct EventHandlerBase;
00047
00048 struct Session: virtual BackRefObjectBase, private Porter
00049 {
00054 struct ConnectionException: Exception
00055 {
00056 ConnectionException(string l, string m): Exception(l, m) {}
00057 };
00058
00059 static Ref<Session> create(string serverName,
00060 int corbaEndpointPort = -1,
00061 Logger * = Logger::get())
00062 throw(ConnectionException);
00063
00064 void beginUpdate();
00065 void endUpdate();
00066
00071 struct SupportException: UnexpectedException
00072 {
00073 SupportException(string l, string m): UnexpectedException(l, m) {}
00074 };
00075
00079 struct ProtocolException: UnexpectedException
00080 {
00081 ProtocolException(string l, string m): UnexpectedException(l, m) {}
00082 };
00083
00084 private:
00085 Session(string serverName, int corbaEndpointPort, Logger *)
00086 throw(ConnectionException);
00087
00088 void refForwardDestroy();
00089
00090 Logger *logger;
00091
00092 x3d::sai::Server_var server;
00093 x3d::sai::Session_var session;
00094
00095
00096 template<typename F> friend struct EventHandler;
00097
00098 friend struct ExecutionContext;
00099 void destroyContext(ExecutionContext *);
00100
00101 Mutex contextMapMutex;
00105 vector<ExecutionContext *> contextMap;
00106 Ref<ExecutionContext> id2context(unsigned long, bool isApplication);
00107 unsigned long context2id(Ref<ExecutionContext>);
00108
00109
00110 friend struct NodeBase;
00111 Ref<NodeBase> createNode(ExecutionContext *, unsigned long nodeTypeIndex);
00112 void destroyNode(NodeBase *);
00113
00114 Mutex nodeMapMutex;
00135 vector<NodeBase *> nodeMap;
00136 Ref<NodeBase> id2node(unsigned long) throw(IllegalNodeIdException);
00137 unsigned long node2id(Ref<NodeBase>);
00138
00139 void registerFieldInterest(unsigned long ni, unsigned long fi,
00140 EventHandlerBase *, bool destroy);
00141
00142 friend struct Application;
00143 Ref<Application> createApplication(const Uri &baseUri);
00144 Ref<Application> loadApplication(const Uri &uri);
00145
00146
00147 NodeLink nodeLinks[numberOfNodeTypes];
00148 Array<unsigned long> nodeTypeMap;
00149
00150 unsigned long nodeTypeIdBits;
00151 unsigned long nodeTypeIdMask;
00152 unsigned long nodeTypeIdRoof;
00153
00154
00155
00156 Mutex eventHandlersMutex;
00157 vector<Ref<EventHandlerBase> > eventHandlers;
00158
00159 Orb orb;
00160
00161 bool active;
00162 void activate();
00163
00164 struct Servant;
00165 PortableServer::ObjectId_var servantId;
00166
00167
00168 void handleEvent(const x3d::sai::EventSeq &);
00169 x3d::sai::StreamReader_ptr requestFile(const char *);
00170 void log(const char *);
00171
00172 x3d::sai::Server_ptr getServerReference(string name)
00173 throw(ConnectionException);
00174
00175 struct StreamReaderServant;
00176
00177 Ref<Disposer> disposer;
00178 };
00179 }
00180 }
00181 }
00182
00183 #endif