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/remotestreamsite.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 _REMOTESTREAMSITE_HH_
00024 #define _REMOTESTREAMSITE_HH_
00025 
00026 /** @file
00027     Defines RemoteStreamSite.
00028 */
00029 
00030 #include <vos/corelibs/vos/vosdefs.hh>
00031 #include <vos/corelibs/vos/remotesite.hh>
00032 
00033 namespace VOS
00034 {
00035     class MessageBlock;
00036     class message;
00037 
00038 /** @class RemoteStreamSite remotestreamsite.hh vos/corelibs/vos/remotestreamsite.hh
00039  * A simulated remote site using a file for input instead of a
00040     network socket.
00041  */
00042 class VOS_API RemoteStreamSite : public virtual RemoteSite
00043 {
00044 protected:
00045     FILE* readingFILE;
00046     FILE* writingFILE;
00047     bool pretendIsLocal;
00048     bool isScript;
00049 
00050     MessageBlock* partialMessage;
00051 
00052     virtual int readStream(char* data, unsigned int datasize);
00053     virtual int writeStream(const char* data, unsigned int datasize);
00054 public:
00055     RemoteStreamSite(FILE* readfd, FILE* writefd);
00056     virtual ~RemoteStreamSite();
00057 
00058     /** @throw SiteConnectionError */
00059     virtual void sendMessage(Message* m);
00060     virtual void sendMessage(MessageBlock* mb);
00061     virtual void handleDisconnection();
00062     virtual void flushIncomingBuffers();
00063     virtual void flushOutgoingBuffers(const char* data = 0, unsigned int sz = 0) {};
00064 
00065     virtual bool isLocal() { return pretendIsLocal; }
00066     virtual bool isRemote() { return !pretendIsLocal; }
00067 
00068     virtual bool isConnected();
00069 
00070     /** Runs a script file (a session of VOS messages.)  The reason
00071         why this is in RemoteStreamSite is because it works by
00072         creating a temporary "fake" site from which the messages will
00073         originate.
00074 
00075         @param filename The script file to load.  If the filename ends
00076         in ".gz", it will be automatically decompressed with gzip!
00077         @param ls the local site which will receive the script messages
00078         @param lastmessage an optional final message that will be sent to the local site
00079         right before the script is completed.
00080         @note If you are opening a gzipped file, "gunzip" is called
00081         using popen() which calls the shell.  This means that
00082         untrusted filenames should not be passed into this function!
00083         @return true if the script loaded successfully, false if there
00084         was an error.  Does @em not report syntax errors in the script, however.
00085      */
00086     static bool runScript(const string& filename, LocalSite& ls, Message* lastmessage=0);
00087 };
00088 }
00089 
00090 #endif

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