DcmMetaInfo Class Reference

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

Inheritance diagram for DcmMetaInfo:

DcmItem DcmObject 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 char *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

Definition at line 53 of file dcmetinf.h.


Constructor & Destructor Documentation

DcmMetaInfo::DcmMetaInfo ( const DcmMetaInfo old  ) 

copy constructor

Parameters:
old item to be copied


Member Function Documentation

DcmMetaInfo& DcmMetaInfo::operator= ( const DcmMetaInfo obj  ) 

assignment operator.

Parameters:
the metainfo to be copied

virtual DcmObject* DcmMetaInfo::clone (  )  const [inline, virtual]

clone method

Returns:
deep copy of this object

Reimplemented from DcmItem.

Definition at line 80 of file dcmetinf.h.

References DcmMetaInfo().

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.

virtual DcmEVR DcmMetaInfo::ident (  )  const [virtual]

get type identifier

Returns:
type identifier of this class (EVR_item)

Reimplemented from DcmItem.

virtual void DcmMetaInfo::removeInvalidGroups (  )  [virtual]

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

everything but 0x0002

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 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:
out output stream
flags optional flag used to customize the output (see DCMTypes::PF_xxx)
level current level of nested items. Used for indentation.
pixelFileName not used
pixelCounter not used

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 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 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:
xfer transfer syntax for length calculation
enctype sequence encoding type for length calculation
Returns:
length of DICOM element

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:
inStream DICOM input stream
xfer transfer syntax to use when parsing
glenc handling of group length parameters
maxReadLength attribute 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.

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:
outStream DICOM output stream
oxfer output transfer syntax
enctype encoding types (undefined or explicit length)
wcache pointer 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:
out output stream to which the XML document is written
flags optional flag used to customize the output (see DCMTypes::XF_xxx)
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual OFCondition DcmMetaInfo::loadFile ( const char *  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

Parameters:
fileName name of the file to load
readXfer transfer syntax used to read the data (auto detection if EXS_Unknown)
groupLength flag, specifying how to handle the group length tags
maxReadLength maximum 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::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:
inStream input stream, should be at start position
newxfer as 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

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

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:
inStream input stream
xfer transfer syntax of meta-header
xtag attribute tag for group length
glenc handling of group length encoding element in dataset
headerLen output parameter; length of meta-header as encoded in group length element
bytesRead output parameter; number of bytes read when reading group length (for counting the remaining number of meta-header bytes)
maxReadLength max read length for elements
Returns:
EC_Normal if successful, an error code otherwise


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


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1