00001 #ifndef _STR_StrChunk_H_ // -*-c++-*-
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __GNUG__
00022 #pragma interface
00023 #endif
00024
00025
00026
00027
00028
00029 #include <cassert>
00030 #include <cstddef>
00031
00032 #include <LCore/Object.h>
00033 #include <LCore/RefCounting.h>
00034
00035 #ifndef _STR_STR_ClassIdent_H_
00036 # include <StrMod/STR_ClassIdent.h>
00037 #endif
00038 #include <StrMod/ChunkVisitor.h>
00039
00040 #define _STR_StrChunk_H_
00041
00042 namespace strmod {
00043 namespace strmod {
00044
00045 class LinearExtent;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class StrChunk : public lcore::Object, public lcore::ReferenceCounting
00069 {
00070 friend class ChunkVisitor;
00071 public:
00072 class __iterator;
00073 friend class __iterator;
00074
00075 typedef __iterator const_iterator;
00076 static const STR_ClassIdent identifier;
00077
00078
00079 StrChunk() : ReferenceCounting(0), iter_storage(0) { }
00080
00081 virtual ~StrChunk() { }
00082
00083 inline virtual int AreYouA(const lcore::ClassIdent &cid) const;
00084
00085
00086 virtual unsigned int Length() const = 0;
00087
00088
00089
00090
00091
00092
00093
00094
00095 const_iterator begin();
00096 const_iterator end();
00097
00098
00099 protected:
00100
00101 virtual const lcore::ClassIdent *i_GetIdent() const { return(&identifier); }
00102
00103
00104 virtual void acceptVisitor(ChunkVisitor &visitor)
00105 throw(ChunkVisitor::halt_visitation) = 0;
00106
00107
00108
00109
00110
00111
00112 inline void call_visitStrChunk(ChunkVisitor &visitor,
00113 const StrChunkPtr &chunk)
00114 throw(ChunkVisitor::halt_visitation);
00115 inline void call_visitStrChunk(ChunkVisitor &visitor,
00116 const StrChunkPtr &chunk,
00117 const LinearExtent &used)
00118 throw(ChunkVisitor::halt_visitation);
00119 inline void call_visitDataBlock(ChunkVisitor &visitor,
00120 void *start, size_t len)
00121 throw(ChunkVisitor::halt_visitation);
00122
00123
00124 private:
00125 void *iter_storage;
00126 };
00127
00128
00129
00130 inline int StrChunk::AreYouA(const lcore::ClassIdent &cid) const
00131 {
00132 return((identifier == cid) || Object::AreYouA(cid));
00133 }
00134
00135 inline void StrChunk::call_visitStrChunk(ChunkVisitor &visitor,
00136 const StrChunkPtr &chunk)
00137 throw(ChunkVisitor::halt_visitation)
00138 {
00139 visitor.visitStrChunk(chunk);
00140 }
00141
00142 inline void StrChunk::call_visitStrChunk(ChunkVisitor &visitor,
00143 const StrChunkPtr &chunk,
00144 const LinearExtent &used)
00145 throw(ChunkVisitor::halt_visitation)
00146 {
00147 visitor.visitStrChunk(chunk, used);
00148 }
00149
00150 inline void StrChunk::call_visitDataBlock(ChunkVisitor &visitor,
00151 void *start, size_t len)
00152 throw(ChunkVisitor::halt_visitation)
00153 {
00154 visitor.visitDataBlock(start, len);
00155 }
00156
00157 }
00158 }
00159
00160 #endif