00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef ARCHON_X3D_SAI_ROUTE_H
00020 #define ARCHON_X3D_SAI_ROUTE_H
00021 
00022 #include <archon/x3d/server/event.H>
00023 
00024 #include <archon/x3d/sai/session.H>
00025 
00026 namespace Archon
00027 {
00028   namespace X3D
00029   {
00030     namespace SAI
00031     {
00032       using namespace Utilities;
00033   
00037       struct ExternalRouteHead: virtual RefObjectBase
00038       {
00039         const BackRef<Session> session;
00040         const unsigned long cookie;
00041 
00042       protected:
00043         ExternalRouteHead(Ref<Session> session, unsigned long cookie):
00044           session(session), cookie(cookie) {}
00045 
00046         unsigned long getHeadCountNoLock() { return getUseCountNoLock(); }
00047       };
00048 
00049       struct ExternalRoute: RouteTail, ExternalRouteHead
00050       {
00055         struct AccessException: Exception
00056         {
00057           AccessException(string l): Exception(l) {}
00058         };
00059 
00060         void cascadeEvent(const Event *e) const;
00061 
00062         static void add(Ref<NodeBase> sourceNode, const FieldBase *sourceField,
00063                         Ref<Session> session, unsigned long cookie)
00064           throw(AccessException);
00065 
00066         static bool del(Ref<NodeBase> sourceNode, const FieldBase *sourceField,
00067                         Ref<Session> session, unsigned long cookie);
00068 
00069         void refDispose(Mutex::Lock &l);
00070 
00071         ~ExternalRoute();
00072 
00073       private:
00074         ExternalRoute(Ref<NodeBase> sourceNode, const FieldBase *sourceField,
00075                       Ref<Session> session, unsigned long cookie);
00076 
00077         bool match(const RouteTail *) const;
00078       };
00079     }
00080   }
00081 }
00082 
00083 #endif // ARCHON_X3D_SAI_ROUTE_H
00084