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

InfiniteModule.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/InfiniteModule.cxx,v 1.3 2001/09/23 22:40:41 hopper Exp $ */
00020 
00021 // For a log, see ./ChangeLog
00022 
00023 #ifdef __GNUG__
00024 #  pragma implementation "InfiniteModule.h"
00025 #endif
00026 
00027 #include "StrMod/InfiniteModule.h"
00028 #include "StrMod/PreAllocBuffer.h"
00029 #include <cstring>  // memset
00030 
00031 namespace strmod {
00032 namespace strmod {
00033 
00034 const STR_ClassIdent InfiniteModule::identifier(41UL);
00035 const STR_ClassIdent InfiniteModule::IPlug::identifier(42UL);
00036 
00037 InfiniteModule::InfiniteModule(const StrChunkPtr &chnk)
00038      : feed_(chnk), plug_created_(false), plug_(*this)
00039 {
00040 }
00041 
00042 InfiniteModule::InfiniteModule()
00043      : plug_created_(false), plug_(*this)
00044 {
00045    const int bufsize = 8192;
00046    PreAllocBuffer<bufsize> *buf = new PreAllocBuffer<bufsize>;
00047 
00048    buf->resize(bufsize);
00049    memset(buf->getVoidP(), '\0', bufsize);
00050    feed_ = buf;
00051 }
00052 
00053 InfiniteModule::~InfiniteModule()
00054 {
00055 }
00056 
00057 bool InfiniteModule::deletePlug(Plug *plug)
00058 {
00059    if ((&plug_ == plug) && plug_created_)
00060    {
00061       plug_created_ = false;
00062       plug_.unPlug();
00063       setReadableFlagFor(&plug_, false);
00064       setWriteableFlagFor(&plug_, false);
00065       return(true);
00066    }
00067    else
00068    {
00069       return(false);
00070    }
00071 }
00072 
00073 StreamModule::Plug *InfiniteModule::i_MakePlug(int side)
00074 {
00075    plug_created_ = true;
00076    setReadableFlagFor(&plug_, true);
00077    setWriteableFlagFor(&plug_, true);
00078    return(&plug_);
00079 }
00080 
00081 };  // End namespace strmod
00082 };  // End namespace strmod

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