DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Private Member Functions | Private Attributes
DcmMetaInfo Class Reference

a class representing the DICOM file meta information header More...

+ Inheritance diagram for DcmMetaInfo:

List of all members.

Public Member Functions

 DcmMetaInfo ()
 default constructor
 DcmMetaInfo (const DcmMetaInfo &old)
 copy constructor
DcmMetaInfooperator= (const DcmMetaInfo &obj)
 assignment operator.
virtual ~DcmMetaInfo ()
 destructor
virtual DcmObjectclone () const
 clone method
virtual OFCondition copyFrom (const DcmObject &rhs)
 Virtual object copying.
virtual DcmEVR ident () const
 get type identifier
virtual void removeInvalidGroups ()
 remove all elements with an invalid group number, i.e.
E_TransferSyntax getOriginalXfer () const
 return the transfer syntax in which this dataset was originally read.
virtual void print (STD_NAMESPACE ostream &out, const size_t flags=0, const int level=0, const char *pixelFileName=NULL, size_t *pixelCounter=NULL)
 print meta information header to a stream
virtual void transferInit ()
 initialize the transfer state of this object.
virtual void transferEnd ()
 finalize the transfer state of this object.
virtual Uint32 calcElementLength (const E_TransferSyntax xfer, const E_EncodingType enctype)
 calculate the length of this DICOM element when encoded with the given transfer syntax and the given encoding type for sequences.
virtual OFCondition read (DcmInputStream &inStream, const E_TransferSyntax xfer=EXS_Unknown, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength)
 read object from a stream.
virtual OFCondition write (DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache)
 write meta information header to a stream
virtual OFCondition writeXML (STD_NAMESPACE ostream &out, const size_t flags=0)
 write object in XML format
virtual OFCondition loadFile (const OFFilename &fileName, const E_TransferSyntax readXfer=EXS_Unknown, const E_GrpLenEncoding groupLength=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength)
 load object from a DICOM file.

Private Member Functions

void setPreamble ()
 initialize the preamble buffer with 128 zero bytes followed by "DICM"
OFBool checkAndReadPreamble (DcmInputStream &inStream, E_TransferSyntax &newxfer)
 check if the next 132 bytes in the input stream are a preamble followed by the DICOM "magic word" DICM.
OFBool nextTagIsMeta (DcmInputStream &inStream)
 peeks into the input stream and checks whether the next element is group 0002, i.e.
OFCondition readGroupLength (DcmInputStream &inStream, const E_TransferSyntax xfer, const DcmTagKey &xtag, const E_GrpLenEncoding glenc, Uint32 &headerLen, Uint32 &bytesRead, const Uint32 maxReadLength=DCM_MaxReadLength)
 read meta-header group length element which is important because it tells us where to switch from meta-header transfer syntax to dataset transfer syntax.

Private Attributes

char filePreamble [DCM_PreambleLen+DCM_MagicLen]
 buffer for 132 byte DICOM file preamble
OFBool preambleUsed
 true if the preamble was read from stream
E_TransferState fPreambleTransferState
 transfer state of the preamble
E_TransferSyntax Xfer
 transfer syntax in which the meta-header was read

Detailed Description

a class representing the DICOM file meta information header


Constructor & Destructor Documentation

copy constructor

Parameters:
olditem to be copied

Member Function Documentation

virtual Uint32 DcmMetaInfo::calcElementLength ( const E_TransferSyntax  xfer,
const E_EncodingType  enctype 
) [virtual]

calculate the length of this DICOM element when encoded with the given transfer syntax and the given encoding type for sequences.

For elements, the length includes the length of the tag, length field, VR field and the value itself, for items and sequences it returns the length of the complete item or sequence including delimitation tags if applicable. Never returns undefined length.

Parameters:
xfertransfer syntax for length calculation
enctypesequence encoding type for length calculation
Returns:
length of DICOM element

Reimplemented from DcmItem.

OFBool DcmMetaInfo::checkAndReadPreamble ( DcmInputStream inStream,
E_TransferSyntax &  newxfer 
) [private]

check if the next 132 bytes in the input stream are a preamble followed by the DICOM "magic word" DICM.

If so, try to determine the transfer syntax of the meta-header and return in parameter newxfer. If not, reset stream to start position.

Parameters:
inStreaminput stream, should be at start position
newxferas input parameter contains the expected transfer syntax, as output parameter returns the real transfer syntax of the meta-header as determined heuristically
Returns:
true if meta-header found and read, false otherwise
virtual DcmObject* DcmMetaInfo::clone ( ) const [inline, virtual]

clone method

Returns:
deep copy of this object

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::copyFrom ( const DcmObject rhs) [virtual]

Virtual object copying.

This method can be used for DcmObject and derived classes to get a deep copy of an object. Internally the assignment operator is called if the given DcmObject parameter is of the same type as "this" object instance. If not, an error is returned. This function permits copying an object by value in a virtual way which therefore is different to just calling the assignment operator of DcmElement which could result in slicing the object.

Parameters:
rhs- [in] The instance to copy from. Has to be of the same class type as "this" object
Returns:
EC_Normal if copying was successful, error otherwise

Reimplemented from DcmItem.

E_TransferSyntax DcmMetaInfo::getOriginalXfer ( ) const

return the transfer syntax in which this dataset was originally read.

Returns:
transfer syntax in which this dataset was originally read, EXS_Unknown if the dataset was created in memory
virtual DcmEVR DcmMetaInfo::ident ( ) const [virtual]

get type identifier

Returns:
type identifier of this class (EVR_item)

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::loadFile ( const OFFilename fileName,
const E_TransferSyntax  readXfer = EXS_Unknown,
const E_GrpLenEncoding  groupLength = EGL_noChange,
const Uint32  maxReadLength = DCM_MaxReadLength 
) [virtual]

load object from a DICOM file.

If the file preamble is missing, an error is returned.

Parameters:
fileNamename of the file to load (may contain wide chars if support enabled). Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter.
readXfertransfer syntax used to read the data (auto detection if EXS_Unknown)
groupLengthflag, specifying how to handle the group length tags
maxReadLengthmaximum number of bytes to be read for an element value. Element values with a larger size are not loaded until their value is retrieved (with getXXX()) or loadAllDataElements() is called.
Returns:
status, EC_Normal if successful, an error code otherwise
OFBool DcmMetaInfo::nextTagIsMeta ( DcmInputStream inStream) [private]

peeks into the input stream and checks whether the next element is group 0002, i.e.

belongs to the meta-header

Returns:
true if next element is part of meta-header, false otherwise
DcmMetaInfo& DcmMetaInfo::operator= ( const DcmMetaInfo obj)

assignment operator.

Parameters:
themetainfo to be copied
virtual void DcmMetaInfo::print ( STD_NAMESPACE ostream &  out,
const size_t  flags = 0,
const int  level = 0,
const char *  pixelFileName = NULL,
size_t *  pixelCounter = NULL 
) [virtual]

print meta information header to a stream

Parameters:
outoutput stream
flagsoptional flag used to customize the output (see DCMTypes::PF_xxx)
levelcurrent level of nested items. Used for indentation.
pixelFileNamenot used
pixelCounternot used

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::read ( DcmInputStream inStream,
const E_TransferSyntax  xfer = EXS_Unknown,
const E_GrpLenEncoding  glenc = EGL_noChange,
const Uint32  maxReadLength = DCM_MaxReadLength 
) [virtual]

read object from a stream.

Parameters:
inStreamDICOM input stream
xfertransfer syntax to use when parsing
glenchandling of group length parameters
maxReadLengthattribute values larger than this value are skipped while parsing and read later upon first access if the stream type supports this.
Returns:
EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

OFCondition DcmMetaInfo::readGroupLength ( DcmInputStream inStream,
const E_TransferSyntax  xfer,
const DcmTagKey xtag,
const E_GrpLenEncoding  glenc,
Uint32 &  headerLen,
Uint32 &  bytesRead,
const Uint32  maxReadLength = DCM_MaxReadLength 
) [private]

read meta-header group length element which is important because it tells us where to switch from meta-header transfer syntax to dataset transfer syntax.

Insert element into dataset

Parameters:
inStreaminput stream
xfertransfer syntax of meta-header
xtagattribute tag for group length
glenchandling of group length encoding element in dataset
headerLenoutput parameter; length of meta-header as encoded in group length element
bytesReadoutput parameter; number of bytes read when reading group length (for counting the remaining number of meta-header bytes)
maxReadLengthmax read length for elements
Returns:
EC_Normal if successful, an error code otherwise
virtual void DcmMetaInfo::removeInvalidGroups ( ) [virtual]

remove all elements with an invalid group number, i.e.

everything but 0x0002

virtual void DcmMetaInfo::transferEnd ( ) [virtual]

finalize the transfer state of this object.

This method must be called when reading/writing this object from/to a stream has been completed.

Reimplemented from DcmItem.

virtual void DcmMetaInfo::transferInit ( ) [virtual]

initialize the transfer state of this object.

This method must be called before this object is written to a stream or read (parsed) from a stream.

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::write ( DcmOutputStream outStream,
const E_TransferSyntax  oxfer,
const E_EncodingType  enctype,
DcmWriteCache wcache 
) [virtual]

write meta information header to a stream

Parameters:
outStreamDICOM output stream
oxferoutput transfer syntax
enctypeencoding types (undefined or explicit length)
wcachepointer to write cache object, may be NULL
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::writeXML ( STD_NAMESPACE ostream &  out,
const size_t  flags = 0 
) [virtual]

write object in XML format

Parameters:
outoutput stream to which the XML document is written
flagsoptional flag used to customize the output (see DCMTypes::XF_xxx)
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.


The documentation for this class was generated from the following file:


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027