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

EchoModule.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/EchoModule.cxx,v 1.11 2002/03/12 21:48:57 hopper Exp $ */
00020 
00021 #ifdef __GNUG__
00022 #pragma implementation "EchoModule.h"
00023 #endif
00024 
00025 // For log information, see ChangeLog
00026 
00027 // $Revision: 1.11 $
00028 
00029 
00030 #include "StrMod/EchoModule.h"
00031 
00032 namespace strmod {
00033 namespace strmod {
00034 
00035 const STR_ClassIdent EchoModule::identifier(3UL);
00036 const STR_ClassIdent EchoModule::EPlug::identifier(4UL);
00037 
00038 EchoModule::EchoModule() : plugcreated_(false), eplug_(*this)
00039 {
00040 }
00041 
00042 EchoModule::~EchoModule()
00043 {
00044 }
00045 
00046 bool EchoModule::deletePlug(Plug *plug)
00047 {
00048    if (i_OwnsPlug(plug))
00049    {
00050       plugcreated_ = false;
00051       plug->unPlug();
00052       return(true);
00053    }
00054    else
00055    {
00056       return(false);
00057    }
00058 }
00059 
00060 void EchoModule::plugDisconnected(Plug *plug)
00061 {
00062    assert(plug == &eplug_);
00063    assert(plugcreated_);
00064 
00065    setReadableFlagFor(&eplug_, false);
00066    setWriteableFlagFor(&eplug_, false);
00067    StreamModule::plugDisconnected(plug);
00068 }
00069 
00070 void EchoModule::EPlug::otherIsReadable()
00071 {
00072    Plug *other = pluggedInto();
00073 
00074    setReadable((other == NULL) ? false : getFlagsFrom(*other).canread_);
00075 }
00076 
00077 void EchoModule::EPlug::otherIsWriteable()
00078 {
00079    Plug *other = pluggedInto();
00080 
00081    setWriteable((other == NULL) ? false : getFlagsFrom(*other).canwrite_);
00082 }
00083 
00084 const StrChunkPtr EchoModule::EPlug::i_Read()
00085 {
00086    StrChunkPtr tmp = readOther();
00087    Plug *other = pluggedInto();
00088 
00089    if (other != NULL)
00090    {
00091       setReadable(getFlagsFrom(*other).canread_);
00092    }
00093    else
00094    {
00095       setReadable(false);
00096       setWriteable(false);
00097    }
00098    return(tmp);
00099 }
00100 
00101 void EchoModule::EPlug::i_Write(const StrChunkPtr &ptr)
00102 {
00103    writeOther(ptr);
00104 
00105    Plug *other = pluggedInto();
00106 
00107    if (other != NULL)
00108    {
00109       setWriteable(getFlagsFrom(*other).canwrite_);
00110    }
00111    else
00112    {
00113       setReadable(false);
00114       setWriteable(false);
00115    }
00116 }
00117 
00118 }  // End namespace strmod
00119 }  // End namespace strmod

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