36 template <
class T2>
void StoreMemberOn(T2 &item, Storage & storage);
46 Node *mpNext,*mpPrevious;
53 const T& Value(
void)
const{
return mValue; }
54 T& Value(
void) {
return mValue; }
55 Node *Next(
void) {
return mpNext; }
56 Node *Previous(
void) {
return mpPrevious; }
66 mpFirst = mpLast = mpCurrent = 0;
86 for(i=0;i<src.
Size();i++)
95 mpFirst = mpLast = mpCurrent = 0;
106 Node* next = mpCurrent->mpNext;
132 CLAM_ASSERT(mpCurrent,
"Trying to access non-exixting current pointer");
133 return mpCurrent->Value();
138 CLAM_ASSERT(mSize>=0,
"Trying to access empty list");
139 return mpFirst->Value();
144 CLAM_ASSERT(mSize>=0,
"Trying to access empty list");
145 return mpLast->Value();
150 CLAM_ASSERT(mpCurrent,
"Trying to access non-exixting current pointer");
151 return mpCurrent->Value();
156 CLAM_ASSERT(mSize>=0,
"Trying to access empty list");
157 return mpFirst->Value();
162 CLAM_ASSERT(mSize>=0,
"Trying to access empty list");
163 return mpLast->Value();
173 mCurrentIndex=mSize-1;
177 CLAM_ASSERT(mCurrentIndex<mSize-1,
"Current element is already last one");
178 mpCurrent=mpCurrent->mpNext;
183 CLAM_ASSERT(mCurrentIndex>0,
"Current element is already first one");
184 mpCurrent=mpCurrent->mpPrevious;
190 return (mpCurrent==mpLast);
195 return mCurrentIndex==mSize;
200 return (mpCurrent==mpFirst);
208 Node* GetNodeAt(
TIndex i);
209 void LinkNode(Node* pA,Node* pB);
210 void AddNode(Node* pA);
211 void InsertNode(Node* pA);
212 void InsertNode(Node* pWhere, Node* pWhat);
214 void DeleteNode(Node* pNode);
216 Node *mpFirst,*mpLast;
217 mutable Node* mpCurrent;
218 mutable TIndex mCurrentIndex;
230 for (
int i=0; i<mSize; i++)
233 (IsStorableAsLeaf*)0,
244 while (LoadMemberFrom( (IsStorableAsLeaf *)0, &(
Last()), storage));
251 storage.
Store(adapter);
254 const char* className = item->GetClassName();
255 const char* label = className? className :
"Element";
256 XMLComponentAdapter adapter(*item, label,
true);
257 storage.Store(adapter);
260 CLAM_ASSERT(
false,
"Trying to Store an object that is not neither a streamable nor a Component");
263 bool LoadMemberFrom(
StaticTrue* asLeave,
void * item, Storage & storage) {
264 XMLAdapter<T> adapter(*(T*)item);
265 return storage.Load(adapter);
267 bool LoadMemberFrom(
StaticFalse* asLeave, Component * item, Storage & storage) {
268 const char* className = item->GetClassName();
269 const char* label = className? className :
"Element";
270 XMLComponentAdapter adapter(*item, label,
true);
271 return storage.Load(adapter);
273 bool LoadMemberFrom(
StaticFalse* asLeave,
void * item, Storage & storage) {
274 CLAM_ASSERT(
false,
"Trying to Load an object that is not neither a streamable nor a Component");
286 AddNode(
new Node(value));
287 mCurrentIndex=mSize-1;
297 CLAM_ASSERT(i<mSize,
"Trying to access non-existing element");
299 mpCurrent=GetNodeAt(i);
300 DeleteNode(mpCurrent);
310 DeleteNode(mpCurrent);
316 template <
class T>
inline void List<T>::DeleteNode(Node* pNode)
322 mpCurrent=pNode->Previous();
327 mpCurrent=pNode->Next();
330 if(pNode!=mpLast&&pNode!=mpFirst)
332 pNode->mpPrevious->mpNext=pNode->Next();
333 pNode->mpNext->mpPrevious=pNode->Previous();
339 mpFirst=pNode->mpNext;
341 mpFirst->mpPrevious=0;;
345 mpLast=pNode->mpPrevious;
353 if(mSize==0) mCurrentIndex=-1;
362 CLAM_ASSERT(i<=mSize,
"Trying to insert out of bounds");
364 InsertNode(GetNodeAt(i),
new Node(value));
375 InsertNode(mpCurrent,pNewNode);
381 template <
class T>
inline void List<T>::InsertNode(Node* pWhere,Node* pNewNode)
383 CLAM_ASSERT(pNewNode,
"Not a valid Nodeent to insert");
386 if(pWhere!=mpFirst) pWhere->mpPrevious->mpNext=pNewNode;
387 pNewNode->mpPrevious=pWhere->mpPrevious;
388 pWhere->mpPrevious=pNewNode;
389 pNewNode->mpNext=pWhere;
391 if(pWhere==mpFirst) mpFirst=pNewNode;
401 CLAM_ASSERT(i<mSize,
"Trying to access non-existing element");
414 Extract(value,mCurrentIndex);
426 template <
class T>
inline void List<T>::AddNode(Node* pNode)
430 if (mpLast) LinkNode(mpLast,pNode);
431 else mpFirst = mpCurrent = pNode;
435 mCurrentIndex=mSize-1;
456 return ((Node*)mpFirst)->mValue;
460 mCurrentIndex=mSize-1;
464 return ((Node*)mpLast)->mValue;
466 if (mCurrentIndex<i) {
467 if (i<((mCurrentIndex+mSize)>>1)) {
470 mpCurrent = mpCurrent->Next();
471 }
while (mCurrentIndex<i);
473 mCurrentIndex = mSize-1;
475 while (mCurrentIndex>i) {
477 mpCurrent = mpCurrent->Previous();
480 }
else if (mCurrentIndex>i)
482 if (i>(mCurrentIndex>>1)) {
485 mpCurrent = mpCurrent->Previous();
486 }
while (mCurrentIndex>i);
490 while (mCurrentIndex<i) {
492 mpCurrent = mpCurrent->Next();
498 return ((Node*)mpCurrent)->mValue;
513 return ((Node*)mpFirst)->mValue;
517 mCurrentIndex=mSize-1;
521 return ((Node*)mpLast)->mValue;
523 if (mCurrentIndex<i) {
524 if (i<((mCurrentIndex+mSize)>>1)) {
527 mpCurrent = mpCurrent->Next();
528 }
while (mCurrentIndex<i);
530 mCurrentIndex = mSize-1;
532 while (mCurrentIndex>i) {
534 mpCurrent = mpCurrent->Previous();
537 }
else if (mCurrentIndex>i)
539 if (i>(mCurrentIndex>>1)) {
542 mpCurrent = mpCurrent->Previous();
543 }
while (mCurrentIndex>i);
547 while (mCurrentIndex<i) {
549 mpCurrent = mpCurrent->Next();
555 return ((Node*)mpCurrent)->mValue;
573 mCurrentIndex=mSize-1;
578 if (mCurrentIndex<i) {
579 if (i<((mCurrentIndex+mSize)>>1)) {
582 mpCurrent = mpCurrent->Next();
583 }
while (mCurrentIndex<i);
585 mCurrentIndex = mSize-1;
587 while (mCurrentIndex>i) {
589 mpCurrent = mpCurrent->Previous();
592 }
else if (mCurrentIndex>i)
594 if (i>(mCurrentIndex>>1)) {
597 mpCurrent = mpCurrent->Previous();
598 }
while (mCurrentIndex>i);
602 while (mCurrentIndex<i) {
604 mpCurrent = mpCurrent->Next();
618 if (mpFirst->mpPrevious || mpLast->mpNext ||
619 mSize<0 || (mCurrentIndex<0) || (mpCurrent==0)
624 Node* pTmp=mpCurrent;
625 for(i=mCurrentIndex;i>=0;i--)
627 CLAM_ASSERT(pTmp->mpPrevious || i==0,
"Current pointer not consistent");
628 pTmp=pTmp->mpPrevious;