00001 /* 00002 * UnixPipe.h 00003 * 00004 * Smalltalk like class library for C++ 00005 * Accessor to unix pipe. Header. 00006 * 00007 * Copyright (c) 2006 Milan Cermak 00008 */ 00009 /* 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 #ifndef __UNIXPIPE_H 00025 #define __UNIXPIPE_H 00026 00027 #include <stlib/IOAccessor.h> 00028 #include <stlib/ByteArray.h> 00029 #include <stlib/ExternalReadStream.h> 00030 #include <stlib/ExternalWriteStream.h> 00031 #include <stlib/FileAccessor.h> 00032 #include <stlib/String.h> 00033 00034 namespace OS { 00035 00036 class UnixPipe : public Core::IOAccessor 00037 { 00038 protected: 00039 Core::FileAccessor *input; 00040 Core::FileAccessor *output; 00041 00042 protected: 00043 UnixPipe(Core::FileAccessor *in, Core::FileAccessor *out); 00044 00045 public: 00046 /* Class-accessing protocol */ 00047 virtual String *className(void) const; 00048 00049 /* Instance creation protocol */ 00050 static UnixPipe *openPair(void); 00051 00052 /* Initialize-release protocol */ 00053 virtual void close(void); 00054 virtual void closeInput(void); 00055 virtual void closeOutput(void); 00056 00057 /* Accessing protocol */ 00058 virtual Core::FileAccessor *inputAccessor(void); 00059 virtual Core::FileAccessor *outputAccessor(void); 00060 00061 /* Data transfer protocol */ 00062 virtual int readInto(ByteArray *buffer) 00063 { return IOAccessor::readInto(buffer); } 00064 virtual int readInto(ByteArray *buffer, long startIndex, long count); 00065 00066 virtual int writeFrom(ByteArray *buffer) 00067 { return IOAccessor::writeFrom(buffer); } 00068 virtual int writeFrom(ByteArray *buffer, long startIndex, long count); 00069 00070 /* Positioning protocol */ 00071 virtual void seekTo(long position); 00072 00073 /* Stream creation protocol */ 00074 virtual ExternalReadStream *readStream(void); 00075 virtual ExternalWriteStream *writeStream(void); 00076 }; 00077 00078 }; 00079 00080 #endif /* __UNIXPIPE_H */