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
00037 #ifndef DCOBJECT_H
00038 #define DCOBJECT_H
00039
00040 #include "osconfig.h"
00041
00042 #include "ofconsol.h"
00043 #include "ofglobal.h"
00044 #include "dcerror.h"
00045 #include "dctypes.h"
00046 #include "dcxfer.h"
00047 #include "dctag.h"
00048 #include "dclist.h"
00049 #include "dcstack.h"
00050
00051
00052
00053 class DcmOutputStream;
00054 class DcmInputStream;
00055
00056
00057
00058
00059
00060 const Uint32 DCM_MaxReadLength = 4096;
00061
00062
00063 const Uint32 DCM_TagInfoLength = 12;
00064
00065
00066 const Uint32 DCM_OptPrintLineLength = 70;
00067
00068
00069 const Uint32 DCM_OptPrintValueLength = 40;
00070
00071
00072
00073
00074
00075
00076 extern OFGlobal<OFBool> dcmEnableAutomaticInputDataCorrection;
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 extern OFGlobal<OFBool> dcmAcceptOddAttributeLength;
00090
00091
00094 class DcmObject
00095 {
00096
00097 public:
00098
00104 DcmObject(const DcmTag &tag,
00105 const Uint32 len = 0);
00106
00110 DcmObject(const DcmObject &obj);
00111
00114 virtual ~DcmObject();
00115
00120 DcmObject &operator=(const DcmObject &obj);
00121
00125 virtual DcmEVR ident() const = 0;
00126
00127
00128
00129
00130
00131 inline DcmEVR getVR() const { return Tag.getEVR(); }
00132
00133 inline OFBool isaString() const { return Tag.getVR().isaString(); }
00134
00135 virtual OFBool isLeaf() const = 0;
00136
00144 virtual void print(ostream &out,
00145 const size_t flags = 0,
00146 const int level = 0,
00147 const char *pixelFileName = NULL,
00148 size_t *pixelCounter = NULL) = 0;
00149
00150 inline OFCondition error() const { return errorFlag; }
00151
00152 inline E_TransferState transferState() const { return fTransferState; }
00153 virtual void transferInit(void);
00154 virtual void transferEnd(void);
00155
00156 inline Uint16 getGTag() const { return Tag.getGTag(); }
00157 inline Uint16 getETag() const { return Tag.getETag(); }
00158 inline const DcmTag &getTag() const { return Tag; }
00159 inline void setGTag(Uint16 gtag) { Tag.setGroup(gtag); }
00160
00161 virtual OFCondition setVR(DcmEVR ) { return EC_IllegalCall; }
00162 virtual unsigned long getVM() = 0;
00163
00164
00165 virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00166 const E_EncodingType enctype) = 0;
00167
00168
00169 virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00170 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00171
00172 virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00173 const E_TransferSyntax oldXfer) = 0;
00174
00175 virtual OFCondition read(DcmInputStream &inStream,
00176 const E_TransferSyntax ixfer,
00177 const E_GrpLenEncoding glenc = EGL_noChange,
00178 const Uint32 maxReadLength = DCM_MaxReadLength) = 0;
00179
00186 virtual OFCondition write(DcmOutputStream &outStream,
00187 const E_TransferSyntax oxfer,
00188 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00189
00195 virtual OFCondition writeXML(ostream &out,
00196 const size_t flags = 0);
00197
00204 virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00205 const E_TransferSyntax oxfer,
00206 const E_EncodingType enctype = EET_UndefinedLength) = 0;
00207
00211 virtual OFBool isSignable() const;
00212
00216 virtual OFBool containsUnknownVR() const;
00217
00218 virtual OFCondition clear() = 0;
00219 virtual OFCondition verify(const OFBool autocorrect = OFFalse) = 0;
00220
00221 virtual DcmObject *nextInContainer(const DcmObject *obj);
00222
00223 virtual OFCondition nextObject(DcmStack &stack,
00224 const OFBool intoSub);
00225
00226 virtual OFCondition search(const DcmTagKey &xtag,
00227 DcmStack &resultStack,
00228 E_SearchMode mode = ESM_fromHere,
00229 OFBool searchIntoSub = OFTrue);
00230
00231 virtual OFCondition searchErrors(DcmStack &resultStack);
00232
00233 virtual OFCondition loadAllDataIntoMemory() = 0;
00234
00235
00236 protected:
00237
00244 void printNestingLevel(ostream &out,
00245 const size_t flags,
00246 const int level);
00247
00256 void printInfoLineStart(ostream &out,
00257 const size_t flags,
00258 const int level,
00259 DcmTag *tag = NULL);
00260
00270 void printInfoLineEnd(ostream &out,
00271 const size_t flags,
00272 const unsigned long printedLength = 0xffffffff ,
00273 DcmTag *tag = NULL);
00274
00284 virtual void printInfoLine(ostream &out,
00285 const size_t flags,
00286 const int level = 0,
00287 const char *info = NULL,
00288 DcmTag *tag = NULL);
00289
00290 static OFCondition writeTag(DcmOutputStream &outStream,
00291 const DcmTag &tag,
00292 const E_TransferSyntax oxfer);
00293
00294 virtual OFCondition writeTagAndLength(DcmOutputStream &outStream,
00295 const E_TransferSyntax oxfer,
00296 Uint32 &writtenBytes) const;
00297
00304 virtual Uint32 getTagAndLengthSize(const E_TransferSyntax oxfer) const;
00305
00306
00307 DcmTag Tag;
00308 Uint32 Length;
00309 E_TransferState fTransferState;
00310 OFCondition errorFlag;
00311
00312 Uint32 fTransferredBytes;
00313 };
00314
00315
00316 #endif // DCOBJECT_H
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
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