00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ELST_H
00021 #define ELST_H
00022
00023 #include <stdio.h>
00024 #include "host.h"
00025 #include "serialis.h"
00026 #include "lsterr.h"
00027
00028 class ELIST_ITERATOR;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 class DLLSYM ELIST_LINK
00085 {
00086 friend class ELIST_ITERATOR;
00087 friend class ELIST;
00088
00089 ELIST_LINK *next;
00090
00091 public:
00092 ELIST_LINK() {
00093 next = NULL;
00094 }
00095
00096
00097 ELIST_LINK(
00098 const ELIST_LINK &) {
00099 next = NULL;
00100 }
00101
00102 void operator= (
00103 const ELIST_LINK &) {
00104 next = NULL;
00105 }
00106
00107 void serialise_asc(
00108 FILE *f);
00109 void de_serialise_asc(
00110 FILE *f);
00111
00112
00113
00114
00115
00116
00117 };
00118
00119
00120
00121
00122
00123
00124
00125 class DLLSYM ELIST
00126 {
00127 friend class ELIST_ITERATOR;
00128
00129 ELIST_LINK *last;
00130
00131 ELIST_LINK *First() {
00132 return last ? last->next : NULL;
00133 }
00134
00135 public:
00136 ELIST() {
00137 last = NULL;
00138 }
00139
00140 virtual ~ELIST() {
00141
00142 }
00143
00144 void internal_clear (
00145
00146 void (*zapper) (ELIST_LINK *));
00147
00148 bool empty() {
00149 return !last;
00150 }
00151
00152 bool singleton() {
00153 return last ? (last == last->next) : FALSE;
00154 }
00155
00156 void shallow_copy(
00157 ELIST *from_list) {
00158 last = from_list->last;
00159 }
00160
00161
00162 void internal_deep_copy (ELIST_LINK * (*copier) (ELIST_LINK *),
00163 const ELIST * list);
00164
00165 void assign_to_sublist(
00166 ELIST_ITERATOR *start_it,
00167 ELIST_ITERATOR *end_it);
00168
00169 inT32 length();
00170
00171 void sort (
00172 int comparator (
00173 const void *, const void *));
00174
00175
00176
00177
00178
00179
00180 void add_sorted(int comparator(const void*, const void*),
00181 ELIST_LINK* new_link);
00182
00183 void internal_dump (
00184 FILE * f,
00185 void element_serialiser (
00186 FILE *, ELIST_LINK *));
00187
00188 void internal_de_dump (
00189 FILE * f,
00190
00191 ELIST_LINK * element_de_serialiser (
00192 FILE *));
00193
00194 void prep_serialise();
00195
00196
00197
00198
00199
00200
00201 };
00202
00203
00204
00205
00206
00207
00208
00209 class DLLSYM ELIST_ITERATOR
00210 {
00211 friend void ELIST::assign_to_sublist(ELIST_ITERATOR *, ELIST_ITERATOR *);
00212
00213 ELIST *list;
00214 ELIST_LINK *prev;
00215 ELIST_LINK *current;
00216 ELIST_LINK *next;
00217 bool ex_current_was_last;
00218
00219 bool ex_current_was_cycle_pt;
00220
00221 ELIST_LINK *cycle_pt;
00222
00223 bool started_cycling;
00224
00225
00226 ELIST_LINK *extract_sublist(
00227 ELIST_ITERATOR *other_it);
00228
00229 public:
00230 ELIST_ITERATOR() {
00231 list = NULL;
00232 }
00233
00234 ELIST_ITERATOR(
00235 ELIST *list_to_iterate);
00236
00237 void set_to_list(
00238 ELIST *list_to_iterate);
00239
00240 void add_after_then_move(
00241 ELIST_LINK *new_link);
00242
00243 void add_after_stay_put(
00244 ELIST_LINK *new_link);
00245
00246 void add_before_then_move(
00247 ELIST_LINK *new_link);
00248
00249 void add_before_stay_put(
00250 ELIST_LINK *new_link);
00251
00252 void add_list_after(
00253 ELIST *list_to_add);
00254
00255 void add_list_before(
00256 ELIST *list_to_add);
00257
00258 ELIST_LINK *data() {
00259 #ifndef NDEBUG
00260 if (!list)
00261 NO_LIST.error ("ELIST_ITERATOR::data", ABORT, NULL);
00262 if (!current)
00263 NULL_DATA.error ("ELIST_ITERATOR::data", ABORT, NULL);
00264 #endif
00265 return current;
00266 }
00267
00268 ELIST_LINK *data_relative(
00269 inT8 offset);
00270
00271 ELIST_LINK *forward();
00272
00273 ELIST_LINK *extract();
00274
00275 ELIST_LINK *move_to_first();
00276
00277 ELIST_LINK *move_to_last();
00278
00279 void mark_cycle_pt();
00280
00281 bool empty() {
00282 #ifndef NDEBUG
00283 if (!list)
00284 NO_LIST.error ("ELIST_ITERATOR::empty", ABORT, NULL);
00285 #endif
00286 return list->empty ();
00287 }
00288
00289 bool current_extracted() {
00290 return !current;
00291 }
00292
00293 bool at_first();
00294
00295 bool at_last();
00296
00297 bool cycled_list();
00298
00299 void add_to_end(
00300 ELIST_LINK *new_link);
00301
00302 void exchange(
00303 ELIST_ITERATOR *other_it);
00304
00305 inT32 length();
00306
00307 void sort (
00308 int comparator (
00309 const void *, const void *));
00310
00311 };
00312
00313
00314
00315
00316
00317
00318
00319
00320 inline void ELIST_ITERATOR::set_to_list(
00321 ELIST *list_to_iterate) {
00322 #ifndef NDEBUG
00323 if (!this)
00324 NULL_OBJECT.error ("ELIST_ITERATOR::set_to_list", ABORT, NULL);
00325 if (!list_to_iterate)
00326 BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT,
00327 "list_to_iterate is NULL");
00328 #endif
00329
00330 list = list_to_iterate;
00331 prev = list->last;
00332 current = list->First ();
00333 next = current ? current->next : NULL;
00334 cycle_pt = NULL;
00335 started_cycling = FALSE;
00336 ex_current_was_last = FALSE;
00337 ex_current_was_cycle_pt = FALSE;
00338 }
00339
00340
00341
00342
00343
00344
00345
00346
00347 inline ELIST_ITERATOR::ELIST_ITERATOR(ELIST *list_to_iterate) {
00348 set_to_list(list_to_iterate);
00349 }
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 inline void ELIST_ITERATOR::add_after_then_move(
00360 ELIST_LINK *new_element) {
00361 #ifndef NDEBUG
00362 if (!this)
00363 NULL_OBJECT.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
00364 if (!list)
00365 NO_LIST.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
00366 if (!new_element)
00367 BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_then_move", ABORT,
00368 "new_element is NULL");
00369 if (new_element->next)
00370 STILL_LINKED.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
00371 #endif
00372
00373 if (list->empty ()) {
00374 new_element->next = new_element;
00375 list->last = new_element;
00376 prev = next = new_element;
00377 }
00378 else {
00379 new_element->next = next;
00380
00381 if (current) {
00382 current->next = new_element;
00383 prev = current;
00384 if (current == list->last)
00385 list->last = new_element;
00386 }
00387 else {
00388 prev->next = new_element;
00389 if (ex_current_was_last)
00390 list->last = new_element;
00391 if (ex_current_was_cycle_pt)
00392 cycle_pt = new_element;
00393 }
00394 }
00395 current = new_element;
00396 }
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406 inline void ELIST_ITERATOR::add_after_stay_put(
00407 ELIST_LINK *new_element) {
00408 #ifndef NDEBUG
00409 if (!this)
00410 NULL_OBJECT.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
00411 if (!list)
00412 NO_LIST.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
00413 if (!new_element)
00414 BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_stay_put", ABORT,
00415 "new_element is NULL");
00416 if (new_element->next)
00417 STILL_LINKED.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
00418 #endif
00419
00420 if (list->empty ()) {
00421 new_element->next = new_element;
00422 list->last = new_element;
00423 prev = next = new_element;
00424 ex_current_was_last = FALSE;
00425 current = NULL;
00426 }
00427 else {
00428 new_element->next = next;
00429
00430 if (current) {
00431 current->next = new_element;
00432 if (prev == current)
00433 prev = new_element;
00434 if (current == list->last)
00435 list->last = new_element;
00436 }
00437 else {
00438 prev->next = new_element;
00439 if (ex_current_was_last) {
00440 list->last = new_element;
00441 ex_current_was_last = FALSE;
00442 }
00443 }
00444 next = new_element;
00445 }
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 inline void ELIST_ITERATOR::add_before_then_move(
00457 ELIST_LINK *new_element) {
00458 #ifndef NDEBUG
00459 if (!this)
00460 NULL_OBJECT.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
00461 if (!list)
00462 NO_LIST.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
00463 if (!new_element)
00464 BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_then_move", ABORT,
00465 "new_element is NULL");
00466 if (new_element->next)
00467 STILL_LINKED.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
00468 #endif
00469
00470 if (list->empty ()) {
00471 new_element->next = new_element;
00472 list->last = new_element;
00473 prev = next = new_element;
00474 }
00475 else {
00476 prev->next = new_element;
00477 if (current) {
00478 new_element->next = current;
00479 next = current;
00480 }
00481 else {
00482 new_element->next = next;
00483 if (ex_current_was_last)
00484 list->last = new_element;
00485 if (ex_current_was_cycle_pt)
00486 cycle_pt = new_element;
00487 }
00488 }
00489 current = new_element;
00490 }
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 inline void ELIST_ITERATOR::add_before_stay_put(
00501 ELIST_LINK *new_element) {
00502 #ifndef NDEBUG
00503 if (!this)
00504 NULL_OBJECT.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
00505 if (!list)
00506 NO_LIST.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
00507 if (!new_element)
00508 BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_stay_put", ABORT,
00509 "new_element is NULL");
00510 if (new_element->next)
00511 STILL_LINKED.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
00512 #endif
00513
00514 if (list->empty ()) {
00515 new_element->next = new_element;
00516 list->last = new_element;
00517 prev = next = new_element;
00518 ex_current_was_last = TRUE;
00519 current = NULL;
00520 }
00521 else {
00522 prev->next = new_element;
00523 if (current) {
00524 new_element->next = current;
00525 if (next == current)
00526 next = new_element;
00527 }
00528 else {
00529 new_element->next = next;
00530 if (ex_current_was_last)
00531 list->last = new_element;
00532 }
00533 prev = new_element;
00534 }
00535 }
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545 inline void ELIST_ITERATOR::add_list_after(ELIST *list_to_add) {
00546 #ifndef NDEBUG
00547 if (!this)
00548 NULL_OBJECT.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);
00549 if (!list)
00550 NO_LIST.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);
00551 if (!list_to_add)
00552 BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_after", ABORT,
00553 "list_to_add is NULL");
00554 #endif
00555
00556 if (!list_to_add->empty ()) {
00557 if (list->empty ()) {
00558 list->last = list_to_add->last;
00559 prev = list->last;
00560 next = list->First ();
00561 ex_current_was_last = TRUE;
00562 current = NULL;
00563 }
00564 else {
00565 if (current) {
00566 current->next = list_to_add->First ();
00567 if (current == list->last)
00568 list->last = list_to_add->last;
00569 list_to_add->last->next = next;
00570 next = current->next;
00571 }
00572 else {
00573 prev->next = list_to_add->First ();
00574 if (ex_current_was_last) {
00575 list->last = list_to_add->last;
00576 ex_current_was_last = FALSE;
00577 }
00578 list_to_add->last->next = next;
00579 next = prev->next;
00580 }
00581 }
00582 list_to_add->last = NULL;
00583 }
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 inline void ELIST_ITERATOR::add_list_before(ELIST *list_to_add) {
00596 #ifndef NDEBUG
00597 if (!this)
00598 NULL_OBJECT.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL);
00599 if (!list)
00600 NO_LIST.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL);
00601 if (!list_to_add)
00602 BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_before", ABORT,
00603 "list_to_add is NULL");
00604 #endif
00605
00606 if (!list_to_add->empty ()) {
00607 if (list->empty ()) {
00608 list->last = list_to_add->last;
00609 prev = list->last;
00610 current = list->First ();
00611 next = current->next;
00612 ex_current_was_last = FALSE;
00613 }
00614 else {
00615 prev->next = list_to_add->First ();
00616 if (current) {
00617 list_to_add->last->next = current;
00618 }
00619 else {
00620 list_to_add->last->next = next;
00621 if (ex_current_was_last)
00622 list->last = list_to_add->last;
00623 if (ex_current_was_cycle_pt)
00624 cycle_pt = prev->next;
00625 }
00626 current = prev->next;
00627 next = current->next;
00628 }
00629 list_to_add->last = NULL;
00630 }
00631 }
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643 inline ELIST_LINK *ELIST_ITERATOR::extract() {
00644 ELIST_LINK *extracted_link;
00645
00646 #ifndef NDEBUG
00647 if (!this)
00648 NULL_OBJECT.error ("ELIST_ITERATOR::extract", ABORT, NULL);
00649 if (!list)
00650 NO_LIST.error ("ELIST_ITERATOR::extract", ABORT, NULL);
00651 if (!current)
00652
00653 NULL_CURRENT.error ("ELIST_ITERATOR::extract",
00654 ABORT, NULL);
00655 #endif
00656
00657 if (list->singleton()) {
00658
00659 prev = next = list->last = NULL;
00660 } else {
00661 prev->next = next;
00662
00663 if (current == list->last) {
00664 list->last = prev;
00665 ex_current_was_last = TRUE;
00666 } else {
00667 ex_current_was_last = FALSE;
00668 }
00669 }
00670
00671 ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE;
00672 extracted_link = current;
00673 extracted_link->next = NULL;
00674 current = NULL;
00675 return extracted_link;
00676 }
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686 inline ELIST_LINK *ELIST_ITERATOR::move_to_first() {
00687 #ifndef NDEBUG
00688 if (!this)
00689 NULL_OBJECT.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL);
00690 if (!list)
00691 NO_LIST.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL);
00692 #endif
00693
00694 current = list->First ();
00695 prev = list->last;
00696 next = current ? current->next : NULL;
00697 return current;
00698 }
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712 inline void ELIST_ITERATOR::mark_cycle_pt() {
00713 #ifndef NDEBUG
00714 if (!this)
00715 NULL_OBJECT.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
00716 if (!list)
00717 NO_LIST.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
00718 #endif
00719
00720 if (current)
00721 cycle_pt = current;
00722 else
00723 ex_current_was_cycle_pt = TRUE;
00724 started_cycling = FALSE;
00725 }
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735 inline bool ELIST_ITERATOR::at_first() {
00736 #ifndef NDEBUG
00737 if (!this)
00738 NULL_OBJECT.error ("ELIST_ITERATOR::at_first", ABORT, NULL);
00739 if (!list)
00740 NO_LIST.error ("ELIST_ITERATOR::at_first", ABORT, NULL);
00741 #endif
00742
00743
00744 return ((list->empty ()) || (current == list->First ()) || ((current == NULL) &&
00745 (prev == list->last) &&
00746 !ex_current_was_last));
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757 inline bool ELIST_ITERATOR::at_last() {
00758 #ifndef NDEBUG
00759 if (!this)
00760 NULL_OBJECT.error ("ELIST_ITERATOR::at_last", ABORT, NULL);
00761 if (!list)
00762 NO_LIST.error ("ELIST_ITERATOR::at_last", ABORT, NULL);
00763 #endif
00764
00765
00766 return ((list->empty ()) || (current == list->last) || ((current == NULL) &&
00767 (prev == list->last) &&
00768 ex_current_was_last));
00769 }
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779 inline bool ELIST_ITERATOR::cycled_list() {
00780 #ifndef NDEBUG
00781 if (!this)
00782 NULL_OBJECT.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL);
00783 if (!list)
00784 NO_LIST.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL);
00785 #endif
00786
00787 return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
00788
00789 }
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 inline inT32 ELIST_ITERATOR::length() {
00800 #ifndef NDEBUG
00801 if (!this)
00802 NULL_OBJECT.error ("ELIST_ITERATOR::length", ABORT, NULL);
00803 if (!list)
00804 NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL);
00805 #endif
00806
00807 return list->length ();
00808 }
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 inline void
00819 ELIST_ITERATOR::sort (
00820 int comparator (
00821 const void *, const void *)) {
00822 #ifndef NDEBUG
00823 if (!this)
00824 NULL_OBJECT.error ("ELIST_ITERATOR::sort", ABORT, NULL);
00825 if (!list)
00826 NO_LIST.error ("ELIST_ITERATOR::sort", ABORT, NULL);
00827 #endif
00828
00829 list->sort (comparator);
00830 move_to_first();
00831 }
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844 inline void ELIST_ITERATOR::add_to_end(
00845 ELIST_LINK *new_element) {
00846 #ifndef NDEBUG
00847 if (!this)
00848 NULL_OBJECT.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
00849 if (!list)
00850 NO_LIST.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
00851 if (!new_element)
00852 BAD_PARAMETER.error ("ELIST_ITERATOR::add_to_end", ABORT,
00853 "new_element is NULL");
00854 if (new_element->next)
00855 STILL_LINKED.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
00856 #endif
00857
00858 if (this->at_last ()) {
00859 this->add_after_stay_put (new_element);
00860 }
00861 else {
00862 if (this->at_first ()) {
00863 this->add_before_stay_put (new_element);
00864 list->last = new_element;
00865 }
00866 else {
00867 new_element->next = list->last->next;
00868 list->last->next = new_element;
00869 list->last = new_element;
00870 }
00871 }
00872 }
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885 #define QUOTE_IT( parm ) #parm
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 #define ELISTIZEH_A(CLASSNAME) \
00925 \
00926 extern DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link);
00927
00928 #define ELISTIZEH_B(CLASSNAME) \
00929 \
00930
00931
00932
00933
00934
00935 \
00936 \
00937 class DLLSYM CLASSNAME##_LIST : public ELIST \
00938 { \
00939 public: \
00940 CLASSNAME##_LIST():ELIST() {}\
00941 \
00942 \
00943 CLASSNAME##_LIST( \
00944 const CLASSNAME##_LIST&) \
00945 { DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_LIST ), \
00946 ABORT, NULL ); } \
00947 \
00948 void clear() \
00949 { ELIST::internal_clear( &CLASSNAME##_zapper ); } \
00950 \
00951 ~CLASSNAME##_LIST() \
00952 { clear(); } \
00953 \
00954 \
00955 void deep_copy(const CLASSNAME##_LIST* src_list, \
00956 CLASSNAME* (*copier)(const CLASSNAME*)); \
00957 \
00958 void operator=( \
00959 const CLASSNAME##_LIST&) \
00960 { DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_LIST ), \
00961 ABORT, NULL ); }
00962
00963 #define ELISTIZEH_C( CLASSNAME ) \
00964 }; \
00965 \
00966 \
00967 \
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 \
00978 \
00979 class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR \
00980 { \
00981 public: \
00982 CLASSNAME##_IT():ELIST_ITERATOR(){} \
00983 \
00984 CLASSNAME##_IT( \
00985 CLASSNAME##_LIST* list):ELIST_ITERATOR(list){} \
00986 \
00987 CLASSNAME* data() \
00988 { return (CLASSNAME*) ELIST_ITERATOR::data(); } \
00989 \
00990 CLASSNAME* data_relative( \
00991 inT8 offset) \
00992 { return (CLASSNAME*) ELIST_ITERATOR::data_relative( offset ); } \
00993 \
00994 CLASSNAME* forward() \
00995 { return (CLASSNAME*) ELIST_ITERATOR::forward(); } \
00996 \
00997 CLASSNAME* extract() \
00998 { return (CLASSNAME*) ELIST_ITERATOR::extract(); } \
00999 \
01000 CLASSNAME* move_to_first() \
01001 { return (CLASSNAME*) ELIST_ITERATOR::move_to_first(); } \
01002 \
01003 CLASSNAME* move_to_last() \
01004 { return (CLASSNAME*) ELIST_ITERATOR::move_to_last(); } \
01005 };
01006
01007 #define ELISTIZEH( CLASSNAME ) \
01008 \
01009 ELISTIZEH_A( CLASSNAME ) \
01010 \
01011 ELISTIZEH_B( CLASSNAME ) \
01012 \
01013 ELISTIZEH_C( CLASSNAME )
01014
01015 #define ELISTIZEH_S( CLASSNAME ) \
01016 \
01017 ELISTIZEH_A( CLASSNAME ) \
01018 \
01019 extern DLLSYM void CLASSNAME##_serialiser( \
01020 FILE* f, \
01021 ELIST_LINK* element); \
01022 \
01023 extern DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser( \
01024 FILE* f); \
01025 \
01026 ELISTIZEH_B( CLASSNAME ) \
01027 \
01028 void dump( \
01029 FILE* f) \
01030 { ELIST::internal_dump( f, &CLASSNAME##_serialiser );} \
01031 \
01032 void de_dump( \
01033 FILE* f) \
01034 { ELIST::internal_de_dump( f, &CLASSNAME##_de_serialiser );} \
01035 \
01036 void serialise_asc( \
01037 FILE* f); \
01038 void de_serialise_asc( \
01039 FILE* f); \
01040 \
01041 make_serialise( CLASSNAME##_LIST ) \
01042 \
01043 ELISTIZEH_C( CLASSNAME )
01044
01045
01046
01047
01048
01049
01050 #define ELISTIZE(CLASSNAME) \
01051 \
01052
01053
01054
01055
01056
01057
01058
01059 \
01060 \
01061 DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link) { \
01062 delete reinterpret_cast<CLASSNAME*>(link); \
01063 } \
01064 \
01065 \
01066 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST* src_list, \
01067 CLASSNAME* (*copier)(const CLASSNAME*)) { \
01068 \
01069 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST*>(src_list)); \
01070 CLASSNAME##_IT to_it(this); \
01071 \
01072 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \
01073 to_it.add_after_then_move((*copier)(from_it.data())); \
01074 }
01075
01076 #define ELISTIZE_S(CLASSNAME) \
01077 \
01078 ELISTIZE(CLASSNAME) \
01079 \
01080 void CLASSNAME##_LIST::serialise_asc(FILE* f) { \
01081 CLASSNAME##_IT it(this); \
01082 \
01083 serialise_INT32(f, length()); \
01084 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) \
01085 it.data()->serialise_asc(f); \
01086 } \
01087 \
01088 void CLASSNAME##_LIST::de_serialise_asc(FILE* f) { \
01089 inT32 len; \
01090 CLASSNAME##_IT it; \
01091 CLASSNAME* new_elt = NULL; \
01092 \
01093 len = de_serialise_INT32(f); \
01094 it.set_to_list(this); \
01095 for (; len > 0; len--) { \
01096 new_elt = new CLASSNAME; \
01097 new_elt->de_serialise_asc(f); \
01098 it.add_to_end(new_elt); \
01099 } \
01100 return; \
01101 } \
01102 \
01103 \
01104
01105
01106
01107
01108
01109
01110 \
01111 \
01112 DLLSYM void CLASSNAME##_serialiser(FILE* f, ELIST_LINK* element) { \
01113 reinterpret_cast<CLASSNAME*>(element)->serialise(f); \
01114 } \
01115 \
01116 \
01117 \
01118
01119
01120
01121
01122
01123
01124 \
01125 \
01126 DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser(FILE* f) { \
01127 return (ELIST_LINK*) CLASSNAME::de_serialise(f); \
01128 }
01129 #endif