00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _REMOTESITE_HH_
00024 #define _REMOTESITE_HH_
00025
00026
00027
00028
00029
00030 #include <vos/corelibs/vos/vosdefs.hh>
00031 #include <vos/corelibs/vos/site.hh>
00032 #include <vos/corelibs/vos/remotemetaobject.hh>
00033 #include <vos/corelibs/vos/listener.hh>
00034 #include <vos/corelibs/vos/localsite.hh>
00035
00036 #include <map>
00037
00038 namespace VOS
00039 {
00040
00041
00042
00043
00044
00045 class VOS_API RemoteSite : public virtual Site, public virtual RemoteMetaObject,
00046 public virtual VOS::ChildChangeListener,
00047 public virtual VOS::ParentChangeListener,
00048 public virtual VOS::TypeChangeListener
00049 {
00050 private:
00051 typedef multimap<string, metaobject_extender_t>::iterator MI;
00052 static multimap<string, metaobject_extender_t> remoteObjectExtensionTable;
00053 string antispoofid;
00054 public:
00055 class SiteConnectionError : public RemoteError {
00056 public:
00057 SiteConnectionError(const string& s) : RemoteError(s) { }
00058 };
00059 class NoLocalPeerError : public RemoteError {
00060 public:
00061 NoLocalPeerError(const string& s) : RemoteError(s) { }
00062 };
00063 protected:
00064 LocalSite* localpeer;
00065 bool disconnected;
00066 set<Vobject*> childlockSet;
00067 set<Vobject*> parentlockSet;
00068 set<Vobject*> typelockSet;
00069 map<string, pair<bool, Message*> > waitingFor;
00070
00071 RemoteSite();
00072 public:
00073 virtual ~RemoteSite();
00074
00075
00076
00077
00078
00079
00080 virtual LocalSite& getLocalPeer() throw (NoLocalPeerError);
00081
00082 virtual void flushIncomingBuffers() = 0;
00083 virtual void flushOutgoingBuffers(const char* data = 0, unsigned int sz = 0) = 0;
00084
00085 void setChild(int position, const string& contextual_name, Vobject* child)
00086 throw (AccessControlError, TimeoutError);
00087 virtual void setURL(const URL& u);
00088 virtual Site& getSite() { return Site::getSite(); }
00089
00090 virtual void excise();
00091 virtual void release();
00092
00093 virtual void sendMessage(Message* m) = 0;
00094 virtual void sendMessage(MessageBlock* m) = 0;
00095 virtual void sendUpdateMessage(Message* m);
00096
00097 virtual void lockChildNotifyOutgoing(Vobject* v);
00098 virtual void unlockChildNotifyOutgoing(Vobject* v, const string& nonce);
00099 virtual void lockParentNotifyOutgoing(Vobject* v);
00100 virtual void unlockParentNotifyOutgoing(Vobject* v, const string& nonce);
00101 virtual void lockTypeNotifyOutgoing(Vobject* v);
00102 virtual void unlockTypeNotifyOutgoing(Vobject* v, const string& nonce);
00103
00104 virtual void notifyChildInserted(VobjectEvent& e);
00105 virtual void notifyChildReplaced(VobjectEvent& e);
00106 virtual void notifyChildRemoved(VobjectEvent& e);
00107 virtual void notifyParentInserted(VobjectEvent& e);
00108 virtual void notifyParentRemoved(VobjectEvent& e);
00109 virtual void notifyTypeInserted(VobjectEvent& e);
00110 virtual void notifyTypeRemoved(VobjectEvent& e);
00111
00112 static void extendMetaObject(RemoteMetaObject* root, const char* type);
00113
00114
00115
00116 virtual MetaObject* createMetaObject(const char* name, const char* first, ...);
00117 virtual MetaObject* createMetaObject(const char* name, const deque<string>& typelist);
00118
00119 #if 0
00120 virtual MetaObject* createMetaObject();
00121 virtual MetaObject* createMetaObjectT(const char* first, ...);
00122 virtual MetaObject* createMetaObjectV(va_list ap);
00123 virtual MetaObject* createMetaObject(const deque<string>& typelist);
00124
00125 virtual MetaObject* createMetaObjectV(const string& name, va_list ap);
00126 #endif
00127
00128 static void addRemoteObjectExtension(const char* type, metaobject_extender_t newmethod);
00129 static void removeRemoteObjectExtension(const char* type, metaobject_extender_t oldmethod);
00130 static void printExtensionTable(ostream& stream = std::cerr);
00131
00132 virtual void addNotification(NotifyEvent* ev);
00133 virtual void flushNotifications();
00134 virtual void lockNotificationFlush();
00135 virtual void unlockNotificationFlush();
00136
00137
00138 virtual void catchIncomingMessage(const string& nonce);
00139
00140
00141 virtual void clearCaughtMessage(const string& nonce);
00142
00143
00144 virtual bool messageInProgress(const string& nonce);
00145
00146
00147 virtual bool messageReady(const string& nonce);
00148
00149
00150
00151
00152
00153 virtual Message* retrieveCaughtMessage(const string& nonce);
00154
00155
00156 void setAntiSpoofID(const string& s) { antispoofid = s; }
00157
00158
00159 const string& getAntiSpoofID() { return antispoofid; }
00160
00161 virtual bool isConnected() = 0;
00162
00163 friend void Site::doSitePeering(LocalSite* localsite, RemoteSite* remotesite, bool isspooftest, bool waitforhello);
00164 };
00165 }
00166
00167 #endif