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 #ifdef __GNUG__
00028 # pragma implementation "GroupChunk.h"
00029 #endif
00030
00031 #include <StrMod/GroupChunk.h>
00032 #include <StrMod/StrChunkPtr.h>
00033 #include <StrMod/StrChunk.h>
00034 #include <StrMod/LinearExtent.h>
00035
00036
00037 namespace strmod {
00038 namespace strmod {
00039
00040 const STR_ClassIdent GroupChunk::identifier(20UL);
00041
00042
00043
00044
00045 GroupChunk::GroupChunk() : totalsize_(0)
00046 {
00047 }
00048
00049 GroupChunk::~GroupChunk()
00050 {
00051 ChunkList::iterator i;
00052 ChunkList::iterator end;
00053
00054 end = chnklist_.end();
00055 for (i = chnklist_.begin(); i != end; ++i) {
00056 StrChunk *ptr = *i;
00057
00058 *i = 0;
00059 if (ptr) {
00060 ptr->DelReference();
00061 if (ptr->NumReferences() <= 0) {
00062 delete ptr;
00063 }
00064 }
00065 }
00066 }
00067
00068 void GroupChunk::push_back(const StrChunkPtr &chnk)
00069 {
00070 StrChunk *ptr = chnk.GetPtr();
00071
00072 ptr->AddReference();
00073 chnklist_.push_back(ptr);
00074 totalsize_ += ptr->Length();
00075 }
00076
00077 void GroupChunk::push_front(const StrChunkPtr &chnk)
00078 {
00079 StrChunk *ptr = chnk.GetPtr();
00080
00081 ptr->AddReference();
00082 chnklist_.push_front(ptr);
00083 totalsize_ += ptr->Length();
00084 }
00085
00086 void GroupChunk::acceptVisitor(ChunkVisitor &visitor)
00087 throw(ChunkVisitor::halt_visitation)
00088 {
00089 for (ChunkList::const_iterator i = chnklist_.begin(),
00090 listend = chnklist_.end(); i != listend; ++i)
00091 {
00092 call_visitStrChunk(visitor, *i);
00093 }
00094 }
00095
00096 }
00097 }