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
00036 #ifndef DCOBJECT_H
00037 #define DCOBJECT_H
00038
00039 #include "dcmtk/config/osconfig.h"
00040
00041 #include "dcmtk/ofstd/ofconsol.h"
00042 #include "dcmtk/ofstd/ofglobal.h"
00043 #include "dcmtk/dcmdata/dcerror.h"
00044 #include "dcmtk/dcmdata/dctypes.h"
00045 #include "dcmtk/dcmdata/dcxfer.h"
00046 #include "dcmtk/dcmdata/dctag.h"
00047 #include "dcmtk/dcmdata/dclist.h"
00048 #include "dcmtk/dcmdata/dcstack.h"
00049
00050
00051
00052 class DcmOutputStream;
00053 class DcmInputStream;
00054
00055
00056
00057
00058
00059 const Uint32 DCM_MaxReadLength = 4096;
00060
00061
00062 const Uint32 DCM_TagInfoLength = 12;
00063
00064
00065 const Uint32 DCM_OptPrintLineLength = 70;
00066
00067
00068 const Uint32 DCM_OptPrintValueLength = 40;
00069
00070
00075 extern OFGlobal<OFBool> dcmEnableAutomaticInputDataCorrection;
00076
00086 extern OFGlobal<OFBool> dcmAcceptOddAttributeLength;
00087
00100 extern OFGlobal<OFBool> dcmEnableCP246Support;
00101
00110 extern OFGlobal<OFBool> dcmEnableOldSignatureFormat;
00111
00117 extern OFGlobal<OFBool> dcmAutoDetectDatasetXfer;
00118
00121 class DcmObject
00122 {
00123
00124 public:
00125
00131 DcmObject(const DcmTag &tag,
00132 const Uint32 len = 0);
00133
00137 DcmObject(const DcmObject &obj);
00138
00141 virtual ~DcmObject();
00142
00146 virtual DcmObject *clone() const = 0;
00147
00152 DcmObject &operator=(const DcmObject &obj);
00153
00157 virtual DcmEVR ident() const = 0;
00158
00159
00160
00161
00162
00163 inline DcmEVR getVR() const { return Tag.getEVR(); }
00164
00165 inline OFBool isaString() const { return Tag.getVR().isaString(); }
00166
00167 virtual OFBool isLeaf() const = 0;
00168
00176 virtual void print(ostream &out,
00177 const size_t flags = 0,
00178 const int level = 0,
00179 const char *pixelFileName = NULL,
00180 size_t *pixelCounter = NULL) = 0;
00181
00182 inline OFCondition error() const { return errorFlag; }
00183
00184 inline E_TransferState transferState() const { return fTransferState; }
00185 virtual void transferInit(void);
00186 virtual void transferEnd(void);
00187
00188 inline Uint16 getGTag() const { return Tag.getGTag(); }
00189 inline Uint16 getETag() const { return Tag.getETag(); }
00190 inline const DcmTag &getTag() const { return Tag; }
00191 inline void setGTag(Uint16 gtag) { Tag.setGroup(gtag); }
00192
00193 virtual OFCondition setVR(DcmEVR ) { return EC_IllegalCall; }
00194 virtual unsigned long getVM() = 0;
00195
00196
00197 virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00198 const E_EncodingType enctype) = 0;
00199
00200
00201 virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00202 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00203
00204 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00205 const E_TransferSyntax oldXfer) = 0;
00206
00207 virtual OFCondition read(DcmInputStream &inStream,
00208 const E_TransferSyntax ixfer,
00209 const E_GrpLenEncoding glenc = EGL_noChange,
00210 const Uint32 maxReadLength = DCM_MaxReadLength) = 0;
00211
00218 virtual OFCondition write(DcmOutputStream &outStream,
00219 const E_TransferSyntax oxfer,
00220 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00221
00227 virtual OFCondition writeXML(ostream &out,
00228 const size_t flags = 0);
00229
00236 virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00237 const E_TransferSyntax oxfer,
00238 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00239
00243 virtual OFBool isSignable() const;
00244
00248 virtual OFBool containsUnknownVR() const;
00249
00250 virtual OFCondition clear() = 0;
00251 virtual OFCondition verify(const OFBool autocorrect = OFFalse) = 0;
00252
00253 virtual DcmObject *nextInContainer(const DcmObject *obj);
00254
00255 virtual OFCondition nextObject(DcmStack &stack,
00256 const OFBool intoSub);
00257
00258 virtual OFCondition search(const DcmTagKey &xtag,
00259 DcmStack &resultStack,
00260 E_SearchMode mode = ESM_fromHere,
00261 OFBool searchIntoSub = OFTrue);
00262
00263 virtual OFCondition searchErrors(DcmStack &resultStack);
00264
00265 virtual OFCondition loadAllDataIntoMemory() = 0;
00266
00267
00268 protected:
00269
00276 void printNestingLevel(ostream &out,
00277 const size_t flags,
00278 const int level);
00279
00288 void printInfoLineStart(ostream &out,
00289 const size_t flags,
00290 const int level,
00291 DcmTag *tag = NULL);
00292
00302 void printInfoLineEnd(ostream &out,
00303 const size_t flags,
00304 const unsigned long printedLength = 0xffffffff ,
00305 DcmTag *tag = NULL);
00306
00316 virtual void printInfoLine(ostream &out,
00317 const size_t flags,
00318 const int level = 0,
00319 const char *info = NULL,
00320 DcmTag *tag = NULL);
00321
00322 static OFCondition writeTag(DcmOutputStream &outStream,
00323 const DcmTag &tag,
00324 const E_TransferSyntax oxfer);
00325
00326 virtual OFCondition writeTagAndLength(DcmOutputStream &outStream,
00327 const E_TransferSyntax oxfer,
00328 Uint32 &writtenBytes) const;
00329
00336 virtual Uint32 getTagAndLengthSize(const E_TransferSyntax oxfer) const;
00337
00338
00339 DcmTag Tag;
00340 Uint32 Length;
00341 E_TransferState fTransferState;
00342 OFCondition errorFlag;
00343
00344 Uint32 fTransferredBytes;
00345 };
00346
00347
00348 #endif // DCOBJECT_H
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451