00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __GNUG__
00022 #pragma implementation "EchoModule.h"
00023 #endif
00024
00025
00026
00027
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 }
00119 }