Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/corelibs/vos/remotesite.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001-2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <tetron@interreality.org>
00022 */
00023 #ifndef _REMOTESITE_HH_
00024 #define _REMOTESITE_HH_
00025 
00026 /** @file
00027     Defines RemoteSite.
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 /** @class RemoteSite remotesite.hh vos/corelibs/vos/remotesite.hh
00041  *
00042  *  This class manages a connection to a remote site and the
00043  *  objects bound to that site.
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     /** Get the local site this remote site is peered with.
00076         @throws NoLocalPeerError if there is no local peer
00077         (which probably means the application has not created a local site yet!)
00078         @return the local site to which this remote site is peered.
00079         NOTE YOU MUST CALL release() WHEN DONE OR USE A rREF() BLOCK */
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 //    static void extendMetaObjectV(RemoteMetaObject* root, va_list ap);
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     /** Save an incoming message -- used by LocalVobject::waitFor */
00138     virtual void catchIncomingMessage(const string& nonce);
00139 
00140     /** Stop watching for that nonce */
00141     virtual void clearCaughtMessage(const string& nonce);
00142 
00143     /** Is a waited-for message still being downloaded? */
00144     virtual bool messageInProgress(const string& nonce);
00145 
00146     /** Is a waited-for message ready to be retrieved? */
00147     virtual bool messageReady(const string& nonce);
00148 
00149     /** Get a waited-for message nonce.  You need to call
00150         clearCaughtMessage() to stop waiting for that nonce.
00151         @return the message (or possible 0!), note that you should use vRef to release it!
00152     */
00153     virtual Message* retrieveCaughtMessage(const string& nonce);
00154 
00155     /** The anti-spoof ID we sent to this site. */
00156     void setAntiSpoofID(const string& s) { antispoofid = s; }
00157 
00158     /** The anti-spoof ID we sent to this site. */
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

Generated on Tue Aug 12 03:55:41 2003 for Interreality Project - VOS by doxygen 1.3.2