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
00028
00029
00030
00031
00032
00033
00034
00035
#ifndef __DVCACHE_H
00036
#define __DVCACHE_H
00037
00038
#include "osconfig.h"
00039
00040
#include "oflist.h"
00041
#include "ofstring.h"
00042
#include "imagedb.h"
00043
00044
00045
00046
00047
00048
00051
enum DVPSInstanceType
00052 {
00054 DVPSI_image,
00056 DVPSI_presentationState,
00058 DVPSI_structuredReport,
00060 DVPSI_storedPrint,
00062 DVPSI_hardcopyGrayscale
00063 };
00064
00065
00066
00067
00068
00069
00075 class DVInstanceCache
00076 {
00077
00078
public:
00079
00082 struct ItemStruct
00083 {
00094 ItemStruct(
const OFString &uid,
00095
const int pos,
00096
const DVIFhierarchyStatus status,
00097
const DVPSInstanceType type,
00098
const int size,
00099
const OFString &filename)
00100 :
UID(uid),
00101
Pos(pos),
00102
Status(status),
00103
Type(type),
00104
ImageSize(size),
00105
Filename(filename),
00106
Checked(OFFalse),
00107
Description(),
00108
Label(),
00109
List()
00110 {}
00111
00113 OFString UID;
00115 int Pos;
00117 DVIFhierarchyStatus
Status;
00119 DVPSInstanceType
Type;
00121 int ImageSize;
00123 OFString Filename;
00125 OFBool
Checked;
00127 OFString Description;
00129 OFString Label;
00131 OFList<ItemStruct *> List;
00132 };
00133
00136 DVInstanceCache()
00137 :
List(),
00138 Iterator(),
00139 OldIterator()
00140 {
00141 Iterator = OldIterator =
List.
end();
00142 }
00143
00146 virtual ~DVInstanceCache()
00147 {
00148
clear();
00149 }
00150
00154 inline void clear()
00155 {
00156 Iterator =
List.
begin();
00157
OFListIterator(
ItemStruct *) last =
List.
end();
00158
while (Iterator != last)
00159 {
00160
delete (*Iterator);
00161 Iterator =
List.
erase(Iterator);
00162 }
00163
List.
clear();
00164 Iterator = OldIterator =
List.
end();
00165 }
00166
00171 inline OFBool
empty()
const
00172
{
00173
return List.
empty();
00174 }
00175
00180 inline Uint32
getCount()
const
00181
{
00182
return List.
size();
00183 }
00184
00191 inline OFBool
gotoItem(Uint32 idx)
00192 {
00193 OFBool result = OFFalse;
00194 Iterator =
List.
begin();
00195
OFListIterator(
ItemStruct *) last =
List.
end();
00196
while (Iterator != last)
00197 {
00198
if (idx == 0)
00199 {
00200 result = OFTrue;
00201
break;
00202 }
00203 idx--;
00204 ++Iterator;
00205 }
00206
return result;
00207 }
00208
00213 inline OFBool
gotoFirst()
00214 {
00215 OldIterator = Iterator;
00216 Iterator =
List.
begin();
00217
return (Iterator !=
List.
end());
00218 }
00219
00224 inline OFBool
gotoNext()
00225 {
00226
OFListIterator(
ItemStruct *) last =
List.
end();
00227
if (Iterator != last)
00228 Iterator++;
00229
return (Iterator != last);
00230 }
00231
00237 inline OFBool
reset()
00238 {
00239 OFBool result = OFFalse;
00240
OFListIterator(
ItemStruct *) last =
List.
end();
00241
if (OldIterator != last)
00242 {
00243 Iterator = OldIterator;
00244 OldIterator = last;
00245 result = OFTrue;
00246 }
00247
return result;
00248 }
00249
00256 inline OFBool
isElem(
const OFString &uid)
00257 {
00258 OFBool result = OFFalse;
00259 Iterator =
List.
begin();
00260
OFListIterator(
ItemStruct *) last =
List.
end();
00261
while (Iterator != last)
00262 {
00263
const ItemStruct *item = (*Iterator);
00264
if (item != NULL)
00265 {
00266
if (item->
UID == uid)
00267 {
00268 result = OFTrue;
00269
break;
00270 }
00271 }
00272 ++Iterator;
00273 }
00274
return result;
00275 }
00276
00281 inline int getPos()
const
00282
{
00283
const ItemStruct *item =
getItem();
00284
return (item != NULL) ? item->
Pos : 0;
00285 }
00286
00291 inline DVIFhierarchyStatus
getStatus()
const
00292
{
00293
const ItemStruct *item =
getItem();
00294
return (item != NULL) ? item->
Status : DVIF_objectIsNew;
00295 }
00296
00301 inline DVPSInstanceType
getType()
const
00302
{
00303
const ItemStruct *item =
getItem();
00304
return (item != NULL) ? item->
Type : DVPSI_image;
00305 }
00306
00311 inline int getImageSize()
const
00312
{
00313
const ItemStruct *item =
getItem();
00314
return (item != NULL) ? item->
ImageSize : 0;
00315 }
00316
00321 inline const char *
getFilename()
const
00322
{
00323
const ItemStruct *item =
getItem();
00324
return (item != NULL) ? item->
Filename.
c_str() : (
const char *)NULL;
00325 }
00326
00331 inline ItemStruct *
getItem()
const
00332
{
00333
return (Iterator !=
List.
end()) ? (*Iterator) : (
ItemStruct *)NULL;
00334 }
00335
00346 inline void addItem(
const OFString &uid,
00347
const int pos,
00348
const DVIFhierarchyStatus status,
00349
const DVPSInstanceType type,
00350
const int size,
00351
const OFString &filename)
00352 {
00353
ItemStruct *item =
new ItemStruct(uid, pos, status, type, size, filename);
00354
List.
push_back(item);
00355 Iterator = --
List.
end();
00356 }
00357
00362 inline DVIFhierarchyStatus
updateStatus()
00363 {
00364
OFListIterator(
ItemStruct *) first =
List.
begin();
00365
OFListIterator(
ItemStruct *) last =
List.
end();
00366
OFListIterator(
ItemStruct *) iter = first;
00367 DVIFhierarchyStatus status = DVIF_objectIsNew;
00368
while (iter != last)
00369 {
00370
ItemStruct *item = (*iter);
00371
if (item != NULL)
00372 {
00373
switch (item->
Status)
00374 {
00375
case DVIF_objectIsNew:
00376
if (status == DVIF_objectIsNotNew)
00377 status = DVIF_objectContainsNewSubobjects;
00378
break;
00379
case DVIF_objectIsNotNew:
00380
case DVIF_objectContainsNewSubobjects:
00381
if (iter == first)
00382 status = DVIF_objectIsNotNew;
00383
else if (status == DVIF_objectIsNew)
00384 status = DVIF_objectContainsNewSubobjects;
00385
break;
00386 }
00387 }
00388 ++iter;
00389 }
00390
return status;
00391 }
00392
00393
00394
protected:
00395
00397 OFList<ItemStruct *> List;
00399
OFListIterator(
ItemStruct *) Iterator;
00401 OFListIterator(
ItemStruct *) OldIterator;
00402 };
00403
00404
00405
00406
00407
00413 class
DVSeriesCache
00414 {
00415
00416
public:
00417
00420 struct ItemStruct
00421 {
00429 ItemStruct(
const OFString &uid,
00430
const DVIFhierarchyStatus status = DVIF_objectIsNew,
00431
const DVPSInstanceType type = DVPSI_image)
00432 : UID(uid),
00433 Status(status),
00434 Type(type),
00435 List()
00436 {}
00437
00439 OFString UID;
00441 DVIFhierarchyStatus Status;
00443 DVPSInstanceType Type;
00445 DVInstanceCache List;
00446 };
00447
00450 DVSeriesCache()
00451 : List(),
00452 Iterator(),
00453 OldIterator()
00454 {
00455 Iterator = OldIterator = List.
end();
00456 }
00457
00460 virtual ~DVSeriesCache()
00461 {
00462
clear();
00463 }
00464
00468 inline void clear()
00469 {
00470 Iterator = List.
begin();
00471
OFListIterator(
ItemStruct *) last = List.
end();
00472
while (Iterator != last)
00473 {
00474
delete (*Iterator);
00475 Iterator = List.
erase(Iterator);
00476 }
00477 List.
clear();
00478 Iterator = OldIterator = List.
end();
00479 }
00480
00485 inline OFBool
empty()
const
00486
{
00487
return List.
empty();
00488 }
00489
00494 inline Uint32
getCount()
const
00495
{
00496
return List.
size();
00497 }
00498
00505 inline OFBool
gotoItem(Uint32 idx)
00506 {
00507 OFBool result = OFFalse;
00508 Iterator = List.
begin();
00509
OFListIterator(
ItemStruct *) last = List.
end();
00510
while (Iterator != last)
00511 {
00512
if (idx == 0)
00513 {
00514 result = OFTrue;
00515
break;
00516 }
00517 idx--;
00518 ++Iterator;
00519 }
00520
return result;
00521 }
00522
00527 inline OFBool
gotoFirst()
00528 {
00529 OldIterator = Iterator;
00530 Iterator = List.
begin();
00531
return (Iterator != List.
end());
00532 }
00533
00538 inline OFBool
gotoNext()
00539 {
00540
OFListIterator(
ItemStruct *) last = List.
end();
00541
if (Iterator != last)
00542 Iterator++;
00543
return (Iterator != last);
00544 }
00545
00551 inline OFBool
reset()
00552 {
00553 OFBool result = OFFalse;
00554
OFListIterator(
ItemStruct *) last = List.
end();
00555
if (OldIterator != last)
00556 {
00557 Iterator = OldIterator;
00558 OldIterator = last;
00559 result = OFTrue;
00560 }
00561
return result;
00562 }
00563
00570 inline OFBool
isElem(
const OFString &uid)
00571 {
00572 OFBool result = OFFalse;
00573 Iterator = List.
begin();
00574
OFListIterator(
ItemStruct *) last = List.
end();
00575
while (Iterator != last)
00576 {
00577
const ItemStruct *item = (*Iterator);
00578
if (item != NULL)
00579 {
00580
if (item->
UID == uid)
00581 {
00582 result = OFTrue;
00583
break;
00584 }
00585 }
00586 ++Iterator;
00587 }
00588
return result;
00589 }
00590
00595 inline DVIFhierarchyStatus
getStatus()
const
00596
{
00597
const ItemStruct *item =
getItem();
00598
return (item != NULL) ? item->
Status : DVIF_objectIsNew;
00599 }
00600
00605 inline DVPSInstanceType
getType()
const
00606
{
00607
const ItemStruct *item =
getItem();
00608
return (item != NULL) ? item->
Type : DVPSI_image;
00609 }
00610
00615 inline ItemStruct *
getItem()
const
00616
{
00617
return (Iterator != List.
end()) ? (*Iterator) : (
ItemStruct *)NULL;
00618 }
00619
00626 inline void addItem(
const OFString &uid,
00627
const DVIFhierarchyStatus status = DVIF_objectIsNew)
00628 {
00629
ItemStruct *item =
new ItemStruct(uid, status);
00630 List.
push_back(item);
00631 Iterator = --List.
end();
00632 }
00633
00638 inline DVIFhierarchyStatus
updateStatus()
00639 {
00640
OFListIterator(
ItemStruct *) first = List.
begin();
00641
OFListIterator(
ItemStruct *) last = List.
end();
00642
OFListIterator(
ItemStruct *) iter = first;
00643 DVIFhierarchyStatus status = DVIF_objectIsNew;
00644
while (iter != last)
00645 {
00646
ItemStruct *item = (*iter);
00647
if (item != NULL)
00648 {
00649 item->
Status = item->
List.
updateStatus();
00650
switch (item->
Status)
00651 {
00652
case DVIF_objectIsNew:
00653
if (status == DVIF_objectIsNotNew)
00654 status = DVIF_objectContainsNewSubobjects;
00655
break;
00656
case DVIF_objectIsNotNew:
00657
if (iter == first)
00658 status = DVIF_objectIsNotNew;
00659
else if (status == DVIF_objectIsNew)
00660 status = DVIF_objectContainsNewSubobjects;
00661
break;
00662
case DVIF_objectContainsNewSubobjects:
00663 status = DVIF_objectContainsNewSubobjects;
00664
break;
00665 }
00666 }
00667 ++iter;
00668 }
00669
return status;
00670 }
00671
00672
00673
protected:
00674
00676 OFList<ItemStruct *> List;
00678
OFListIterator(
ItemStruct *) Iterator;
00680 OFListIterator(
ItemStruct *) OldIterator;
00681 };
00682
00683
00684
00685
00686
00692 class
DVStudyCache
00693 {
00694
00695
public:
00696
00699 struct ItemStruct
00700 {
00707 ItemStruct(
const OFString &uid,
00708
const DVIFhierarchyStatus status = DVIF_objectIsNew)
00709 : UID(uid),
00710 Status(status),
00711 List()
00712 {}
00713
00715 OFString UID;
00717 DVIFhierarchyStatus Status;
00719 DVSeriesCache List;
00720 };
00721
00724 DVStudyCache()
00725 : List(),
00726 Iterator()
00727 {
00728 Iterator = List.
end();
00729 }
00730
00733 virtual ~DVStudyCache()
00734 {
00735
clear();
00736 }
00737
00741 inline void clear()
00742 {
00743 Iterator = List.
begin();
00744
OFListIterator(
ItemStruct *) last = List.
end();
00745
while (Iterator != last)
00746 {
00747
delete (*Iterator);
00748 Iterator = List.
erase(Iterator);
00749 }
00750 List.
clear();
00751 Iterator = List.
end();
00752 }
00753
00758 inline OFBool
empty()
const
00759
{
00760
return List.
empty();
00761 }
00762
00767 inline Uint32
getCount()
const
00768
{
00769
return List.
size();
00770 }
00771
00778 inline OFBool
gotoItem(Uint32 idx)
00779 {
00780 OFBool result = OFFalse;
00781 Iterator = List.
begin();
00782
OFListIterator(
ItemStruct *) last = List.
end();
00783
while (Iterator != last)
00784 {
00785
if (idx == 0)
00786 {
00787 result = OFTrue;
00788
break;
00789 }
00790 idx--;
00791 ++Iterator;
00792 }
00793
return result;
00794 }
00795
00800 inline OFBool
gotoFirst()
00801 {
00802
00803 Iterator = List.
begin();
00804
return (Iterator != List.
end());
00805 }
00806
00811 inline OFBool
gotoNext()
00812 {
00813
OFListIterator(
ItemStruct *) last = List.
end();
00814
if (Iterator != last)
00815 Iterator++;
00816
return (Iterator != last);
00817 }
00818
00825 inline OFBool
isElem(
const OFString &uid)
00826 {
00827 OFBool result = OFFalse;
00828 Iterator = List.
begin();
00829
OFListIterator(
ItemStruct *) last = List.
end();
00830
while (Iterator != last)
00831 {
00832
const ItemStruct *item = (*Iterator);
00833
if (item != NULL)
00834 {
00835
if (item->
UID == uid)
00836 {
00837 result= OFTrue;
00838
break;
00839 }
00840 }
00841 ++Iterator;
00842 }
00843
return result;
00844 }
00845
00850 inline DVIFhierarchyStatus
getStatus()
const
00851
{
00852
const ItemStruct *item =
getItem();
00853
return (item != NULL) ? item->
Status : DVIF_objectIsNew;
00854 }
00855
00860 inline ItemStruct *
getItem()
const
00861
{
00862
return (Iterator != List.
end()) ? (*Iterator) : (
ItemStruct *)NULL;
00863 }
00864
00871 inline void addItem(
const OFString &uid,
00872
const DVIFhierarchyStatus status = DVIF_objectIsNew)
00873 {
00874
ItemStruct *item =
new ItemStruct(uid, status);
00875 List.
push_back(item);
00876 Iterator = --List.
end();
00877 }
00878
00883 inline void updateStatus()
00884 {
00885
OFListIterator(
ItemStruct *) iter = List.
begin();
00886
OFListIterator(
ItemStruct *) last = List.
end();
00887
while (iter != last)
00888 {
00889
ItemStruct *item = (*iter);
00890
if (item != NULL)
00891 item->
Status = item->
List.
updateStatus();
00892 ++iter;
00893 }
00894 }
00895
00896
00897
protected:
00898
00900 OFList<ItemStruct *> List;
00902
OFListIterator(
ItemStruct *) Iterator;
00903 };
00904
00905
00906 #endif
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965