00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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 };
00092 };