Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ProcessorModule.cxx

00001 /*
00002  * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org>
00003  * 
00004  *     This program is free software; you can redistribute it and/or modify it
00005  *     under the terms of the GNU Lesser General Public License as published
00006  *     by the Free Software Foundation; either version 2 of the License, or
00007  *     (at your option) any later version.
00008  * 
00009  *     This program is distributed in the hope that it will be useful, but
00010  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *     Lesser General Public License for more details.
00013  * 
00014  *     You should have received a copy of the GNU Lesser General Public
00015  *     License along with this program; if not, write to the Free Software
00016  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 /* $Header: /home/hopper/src/cvs/C++/StrMod/ProcessorModule.cxx,v 1.6 2001/09/23 22:40:41 hopper Exp $ */
00020 
00021 // For a log, see ChangeLog
00022 //
00023 // Revision 1.2  1996/09/03 01:58:25  hopper
00024 // Commented out all kinds of debugging stuff.
00025 //
00026 // Revision 1.1  1996/09/02 23:31:12  hopper
00027 // Added class that would turn two StreamProcessors into a StreamModule
00028 // that used one StreamProcessor for the data flowing in each direction.
00029 //
00030 
00031 #ifdef __GNUG__
00032 #  pragma implementation "ProcessorModule.h"
00033 #endif
00034 
00035 #include "StrMod/ProcessorModule.h"
00036 #include "StrMod/StreamProcessor.h"
00037 #include "StrMod/StrChunkPtr.h"
00038 #include <cassert>
00039 // #include <iostream>
00040 
00041 namespace strmod {
00042 namespace strmod {
00043 
00044 const STR_ClassIdent ProcessorModule::identifier(29UL);
00045 const STR_ClassIdent ProcessorModule::PMPlug::identifier(30UL);
00046 
00047 bool ProcessorModule::deletePlug(Plug *plug)
00048 {
00049    if ((plug == &side_) && pulled_.side)
00050    {
00051       side_.unPlug();
00052       pulled_.side = false;
00053       return(true);
00054    }
00055    else if (plug == &otherside_ && pulled_.otherside)
00056    {
00057       otherside_.unPlug();
00058       pulled_.otherside = false;
00059       return(true);
00060    }
00061    return(false);
00062 }
00063 
00064 ProcessorModule::PMPlug::~PMPlug()
00065 {
00066    if (getParent().pulled_.owns)
00067    {
00068       delete &readproc_;
00069    }
00070 }
00071 
00072 const StrChunkPtr ProcessorModule::PMPlug::i_Read()
00073 {
00074    assert(getFlagsFrom(*this).canread_);
00075    assert(readproc_.canReadFrom());
00076    StrChunkPtr tmp = readproc_.readFrom();
00077    getParent().setWriteableFlagFor(&sibling_, readproc_.canWriteTo());
00078    setReadable(readproc_.canReadFrom());
00079    return(tmp);
00080 }
00081 
00082 void ProcessorModule::PMPlug::i_Write(const StrChunkPtr &chnk)
00083 {
00084    assert(getFlagsFrom(*this).canwrite_);
00085    assert(writeproc_.canWriteTo());
00086    writeproc_.writeTo(chnk);
00087    getParent().setReadableFlagFor(&sibling_, writeproc_.canReadFrom());
00088    setWriteable(writeproc_.canWriteTo());
00089 }
00090 
00091 };  // End namespace strmod
00092 };  // End namespace strmod

Generated on Wed Jan 29 00:32:44 2003 for libNet by doxygen1.3-rc1