00001 #ifndef _STR_PassThrough_H_ // -*-c++-*- 00002 00003 /* 00004 * Copyright 1991-2002 Eric M. Hopper <hopper@omnifarious.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published 00008 * by the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifdef __GNUG__ 00022 # pragma interface 00023 #endif 00024 00025 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrMod/PassThrough.h,v 1.6 2002/08/29 00:58:04 hopper Exp $ */ 00026 00027 // For a log, see ../Changelog 00028 // 00029 // Revision 1.1 1996/09/02 23:26:48 hopper 00030 // Added PassThrough class to use when you needed a StreamProcessor that 00031 // did nothing except buffer one Chunk worth of data. 00032 // 00033 00034 #include <StrMod/StreamProcessor.h> 00035 #include <cassert> 00036 00037 #define _STR_PassThrough_H_ 00038 00039 namespace strmod { 00040 namespace strmod { 00041 00042 /** \class PassThrough PassThrough.h StrMod/PassThrough.h 00043 * This is a StreamProcessor that does nothing. 00044 * 00045 * Oftentimes, when using a ProcessorModule, you will want no processing to be 00046 * done in one direction or the other. That's what PassThrough StreamProcessor 00047 * is for. 00048 */ 00049 class PassThrough : public StreamProcessor 00050 { 00051 public: 00052 static const STR_ClassIdent identifier; 00053 00054 //! Doesn't do anything, so doesn't need much in its constructor. 00055 PassThrough() { } 00056 // Derived class destructor doesn't do anything base class one doesn't do. 00057 00058 inline virtual int AreYouA(const lcore::ClassIdent &cid) const; 00059 00060 protected: 00061 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; } 00062 00063 inline virtual void processIncoming(); 00064 00065 private: 00066 PassThrough(const PassThrough &b); 00067 }; 00068 00069 //-----------------------------inline functions-------------------------------- 00070 00071 inline int PassThrough::AreYouA(const lcore::ClassIdent &cid) const 00072 { 00073 return((identifier == cid) || StreamProcessor::AreYouA(cid)); 00074 } 00075 00076 inline void PassThrough::processIncoming() 00077 { 00078 assert(!outgoing_); 00079 outgoing_ = incoming_; 00080 outgoing_ready_ = true; 00081 incoming_.ReleasePtr(); 00082 } 00083 00084 }; // namespace strmod 00085 }; // namespace strmod 00086 00087 #endif
1.3-rc1