DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Protected Member Functions | Private Attributes | Friends
DcmDirectoryRecord Class Reference

a class representing a directory record dataset in a DICOMDIR. More...

+ Inheritance diagram for DcmDirectoryRecord:

List of all members.

Public Member Functions

 DcmDirectoryRecord ()
 default constructor
 DcmDirectoryRecord (const DcmTag &tag, const Uint32 len)
 constructor
 DcmDirectoryRecord (const E_DirRecType recordType, const char *referencedFileID, const char *sourceFileName, DcmFileFormat *fileFormat=NULL)
 constructor
 DcmDirectoryRecord (const char *recordTypeName, const char *referencedFileID, const char *sourceFileName, DcmFileFormat *fileFormat=NULL)
 constructor
 DcmDirectoryRecord (const DcmDirectoryRecord &oldDirRec)
 copy constructor
DcmDirectoryRecordoperator= (const DcmDirectoryRecord &obj)
 assignment operator
virtual ~DcmDirectoryRecord ()
 destructor
virtual DcmObjectclone () const
 clone method
virtual OFCondition copyFrom (const DcmObject &rhs)
 Virtual object copying.
virtual DcmEVR ident () const
 return identifier for this class.
OFCondition error () const
 returns current status flag
virtual OFCondition convertCharacterSet (const OFString &fromCharset, const OFString &toCharset, const OFBool transliterate=OFFalse, const OFBool updateCharset=OFFalse)
 convert all element values that are contained in this record and that are affected by SpecificCharacterSet from the given source character set to the given destination character set.
virtual OFCondition convertCharacterSet (const OFString &toCharset, const OFBool transliterate=OFFalse, const OFBool ignoreCharset=OFFalse)
 convert all element values that are contained in this record and that are affected by SpecificCharacterSet to the given destination character set.
virtual OFCondition convertCharacterSet (DcmSpecificCharacterSet &converter)
 convert all element values that are contained in this record and that are affected by SpecificCharacterSet from the currently selected source character set to the currently selected destination character set.
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 all elements of the item to a stream
virtual OFCondition read (DcmInputStream &inStream, const E_TransferSyntax xfer, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength)
 This function reads the information of all attributes which are captured in the input stream and captures this information in elementList.
virtual OFCondition writeXML (STD_NAMESPACE ostream &out, const size_t flags=0)
 write object in XML format
virtual OFCondition verify (const OFBool autocorrect=OFFalse)
 check the currently stored element value
virtual OFCondition search (const DcmTagKey &xtag, DcmStack &resultStack, E_SearchMode mode=ESM_fromHere, OFBool searchIntoSub=OFTrue)
 a complex, stack-based, hierarchical search method.
virtual E_DirRecType getRecordType ()
 get record type of this directory record
virtual DcmDirectoryRecordgetReferencedMRDR ()
 if this directory record references an MRDR (multi-reference directory record), return pointer to the MRDR referenced by this object.
virtual OFCondition assignToMRDR (DcmDirectoryRecord *mrdr)
 create a reference from this record to an MRDR
virtual OFCondition assignToSOPFile (const char *referencedFileID, const char *sourceFileName)
 open a DICOM file and make this directory record into adirectory record for that DICOM file.
virtual unsigned long cardSub () const
 return number of directory records that are child record of this one
virtual OFCondition insertSub (DcmDirectoryRecord *dirRec, unsigned long where=DCM_EndOfListIndex, OFBool before=OFFalse)
 insert a child directory record
virtual OFCondition insertSubAtCurrentPos (DcmDirectoryRecord *dirRec, OFBool before=OFFalse)
 insert new directory child record at the current position.
virtual DcmDirectoryRecordgetSub (const unsigned long num)
 access child directory record.
virtual DcmDirectoryRecordnextSub (const DcmDirectoryRecord *dirRec)
 get next directory child record starting at a given record
virtual DcmDirectoryRecordremoveSub (const unsigned long num)
 remove child directory record.
virtual DcmDirectoryRecordremoveSub (DcmDirectoryRecord *dirRec)
 remove child directory record.
virtual OFCondition deleteSubAndPurgeFile (const unsigned long num)
 remove child directory record and delete file referenced by that record, if any
virtual OFCondition deleteSubAndPurgeFile (DcmDirectoryRecord *dirRec)
 remove child directory record and delete file referenced by that record, if any
virtual OFCondition clearSub ()
 revert the list of child directory records to default constructed (empty) state
virtual void setRecordsOriginFile (const char *fname)
 store the filename from which this directory record was read from
virtual const char * getRecordsOriginFile ()
 get the filename from which this directory record was read from, NULL if not set
Uint32 getFileOffset () const
 get the offset in file of this directory record

Protected Member Functions

E_DirRecType recordNameToType (const char *recordTypeName)
char * buildFileName (const char *origName, char *destName)
OFCondition checkHierarchy (const E_DirRecType upperRecord, const E_DirRecType lowerRecord)
OFCondition setRecordType (E_DirRecType newType)
E_DirRecType lookForRecordType ()
OFCondition setReferencedFileID (const char *referencedFileID)
const char * lookForReferencedFileID ()
DcmDirectoryRecordlookForReferencedMRDR ()
const char * getReferencedFileName ()
OFCondition setRecordInUseFlag (const Uint16 newFlag)
Uint16 lookForRecordInUseFlag ()
Uint32 setFileOffset (Uint32 position)
OFCondition setNumberOfReferences (Uint32 newRefNum)
Uint32 lookForNumberOfReferences ()
Uint32 increaseRefNum ()
Uint32 decreaseRefNum ()
OFCondition fillElementsAndReadSOP (const char *referencedFileID, const char *sourceFileName, DcmFileFormat *fileFormat=NULL)
 Load all necessary info for this directory record.
OFCondition masterInsertSub (DcmDirectoryRecord *dirRec, const unsigned long where=DCM_EndOfListIndex)
OFCondition purgeReferencedFile ()
virtual OFBool checkForSpecificCharacterSet () const
 mode specifying whether the SpecificCharacterSet (0008,0005) element should be checked by convertCharacterSet() or not

Private Attributes

char * recordsOriginFile
 string in which the filename (path) of the file from which this directory record was read is kept
DcmSequenceOfItemslowerLevelList
 list of child directory records, kept in a sequence of items
E_DirRecType DirRecordType
 directory record type of this record
DcmDirectoryRecordreferencedMRDR
 pointer to multi-referenced directory record (MRDR) if this record refers to one, NULL otherwise
Uint32 numberOfReferences
 number of other directory records referring to this one; used for MRDR records
Uint32 offsetInFile
 byte offset at which the start of this directory record resides in the file from which it was read

Friends

class DcmDicomDir

Detailed Description

a class representing a directory record dataset in a DICOMDIR.


Constructor & Destructor Documentation

DcmDirectoryRecord::DcmDirectoryRecord ( const DcmTag tag,
const Uint32  len 
)

constructor

Parameters:
tagattribute tag
lenlength of the attribute value
DcmDirectoryRecord::DcmDirectoryRecord ( const E_DirRecType  recordType,
const char *  referencedFileID,
const char *  sourceFileName,
DcmFileFormat fileFormat = NULL 
)

constructor

Parameters:
recordTyperecord type
referencedFileIDreferenced file ID in DICOM format
sourceFileNamepath to referenced file in operating system specific format
fileFormatfileFormat for sourceFileName, can be NULL
DcmDirectoryRecord::DcmDirectoryRecord ( const char *  recordTypeName,
const char *  referencedFileID,
const char *  sourceFileName,
DcmFileFormat fileFormat = NULL 
)

constructor

Parameters:
recordTypeNamerecord type as string
referencedFileIDreferenced file ID in DICOM format
sourceFileNamepath to referenced file in operating system specific format
fileFormatfileFormat for sourceFileName, can be NULL

copy constructor

Parameters:
oldDirRecelement to be copied

Member Function Documentation

create a reference from this record to an MRDR

Parameters:
mrdrpointer to MRDR
Returns:
EC_Normal upon success, an error code otherwise
virtual OFCondition DcmDirectoryRecord::assignToSOPFile ( const char *  referencedFileID,
const char *  sourceFileName 
) [virtual]

open a DICOM file and make this directory record into adirectory record for that DICOM file.

The most relevant record keys (SOP Class UID, SOP instance UID, Transfer Syntax UID) are inserted into the directory record.

Parameters:
referencedFileIDreferenced file ID in DICOM format
sourceFileNamepath to file in operating system specific format
Returns:
EC_Normal upon success, an error code otherwise
virtual OFBool DcmDirectoryRecord::checkForSpecificCharacterSet ( ) const [inline, protected, virtual]

mode specifying whether the SpecificCharacterSet (0008,0005) element should be checked by convertCharacterSet() or not

Returns:
always returns OFTrue, i.e. SpecificCharacterSet should be checked

Reimplemented from DcmItem.

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

clone method

Returns:
deep copy of this object

Reimplemented from DcmItem.

virtual OFCondition DcmDirectoryRecord::convertCharacterSet ( const OFString fromCharset,
const OFString toCharset,
const OFBool  transliterate = OFFalse,
const OFBool  updateCharset = OFFalse 
) [virtual]

convert all element values that are contained in this record and that are affected by SpecificCharacterSet from the given source character set to the given destination character set.

The defined terms for a particular character set can be found in the DICOM standard, e.g. "ISO_IR 100" for ISO 8859-1 (Latin 1) or "ISO_IR 192" for Unicode in UTF-8. An empty string denotes the default character repertoire, which is ASCII (7-bit). If multiple values are given for 'fromCharset' (separated by a backslash) code extension techniques are used and escape sequences may be encountered in the source string to switch between the specified character sets.

Parameters:
fromCharsetname of the source character set(s) used for the conversion
toCharsetname of the destination character set used for the conversion. Only a single value is permitted (i.e. no code extensions).
transliteratemode specifying whether a character that cannot be represented in the destination character encoding is approximated through one or more characters that look similar to the original one
updateCharsetif OFTrue, the SpecificCharacterSet (0008,0005) element is updated, i.e. the current value is either replaced or a new element is inserted or the existing element is deleted. If OFFalse the SpecificCharacterSet element remains unchanged.
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual OFCondition DcmDirectoryRecord::convertCharacterSet ( const OFString toCharset,
const OFBool  transliterate = OFFalse,
const OFBool  ignoreCharset = OFFalse 
) [virtual]

convert all element values that are contained in this record and that are affected by SpecificCharacterSet to the given destination character set.

If not disabled, the source character set is determined automatically from the value of the SpecificCharacterSet (0008,0005) element. The defined terms for the destination character set can be found in the DICOM standard, e.g. "ISO_IR 100" for ISO 8859-1 (Latin 1) or "ISO_IR 192" for Unicode in UTF-8. An empty string denotes the default character repertoire, which is ASCII (7-bit).

Parameters:
toCharsetname of the destination character set used for the conversion. Only a single value is permitted (i.e. no code extensions).
transliteratemode specifying whether a character that cannot be represented in the destination character encoding is approximated through one or more characters that look similar to the original one
ignoreCharsetif OFTrue, the value of SpecificCharacterSet is ignored. Also see checkForSpecificCharacterSet().
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

convert all element values that are contained in this record and that are affected by SpecificCharacterSet from the currently selected source character set to the currently selected destination character set.

Since the Basic Directory IOD, which specifies the structure and content of a DICOMDIR, does not contain the SpecificCharacterSet (0008,0005) element in the main dataset but in each directory record, this method also checks for this element and creates a new character set converter for the contained data elements (if needed).

Parameters:
convertercharacter set converter to be used to convert the element values
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual OFCondition DcmDirectoryRecord::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 OFCondition DcmDirectoryRecord::deleteSubAndPurgeFile ( const unsigned long  num) [virtual]

remove child directory record and delete file referenced by that record, if any

Parameters:
numindex number of element, must be < cardSub()
Returns:
status, EC_Normal upon success, an error code otherwise

remove child directory record and delete file referenced by that record, if any

Parameters:
dirRecpointer to element to be removed from list
Returns:
status, EC_Normal upon success, an error code otherwise
OFCondition DcmDirectoryRecord::fillElementsAndReadSOP ( const char *  referencedFileID,
const char *  sourceFileName,
DcmFileFormat fileFormat = NULL 
) [protected]

Load all necessary info for this directory record.

Parameters:
referencedFileIDfile ID that is being referenced, may be NULL
sourceFileNamefilename for the DICOM file, may be NULL
fileFormatIf not NULL, then this should be the result of loading sourceFileName. May only be non-NULL if sourceFileName isn't NULL.

if this directory record references an MRDR (multi-reference directory record), return pointer to the MRDR referenced by this object.

Returns:
pointer to MRDR referenced by this object or NULL of no MRDR referenced
virtual DcmDirectoryRecord* DcmDirectoryRecord::getSub ( const unsigned long  num) [virtual]

access child directory record.

Returns a pointer to the object maintained as a child, not a copy.

Parameters:
numindex, must be < cardSub()
Returns:
pointer to child directory record or NULL if not found
virtual DcmEVR DcmDirectoryRecord::ident ( ) const [virtual]

return identifier for this class.

Every class derived from this class returns a unique value of type enum DcmEVR for this call. This is used as a "poor man's RTTI" to correctly identify instances derived from this class even on compilers not supporting RTTI.

Returns:
type identifier of this class

Reimplemented from DcmItem.

virtual OFCondition DcmDirectoryRecord::insertSub ( DcmDirectoryRecord dirRec,
unsigned long  where = DCM_EndOfListIndex,
OFBool  before = OFFalse 
) [virtual]

insert a child directory record

Parameters:
dirRecdirectory record to be inserted. Must be allocated on heap, ownership is transferred to this object
whereindex where to insert object
beforeflag indicating whether to insert the record before or after the element identified by where
Returns:
EC_Normal upon success, an error code otherwise
virtual OFCondition DcmDirectoryRecord::insertSubAtCurrentPos ( DcmDirectoryRecord dirRec,
OFBool  before = OFFalse 
) [virtual]

insert new directory child record at the current position.

The current position is stored internally in the 'lowerLevelList' member variable.

Parameters:
dirRecnew child record to be inserted
beforeflag indicating whether to insert the record before (OFFalse) or after (OFTrue) the current position
Returns:
status, EC_Normal upon success, an error code otherwise
virtual DcmDirectoryRecord* DcmDirectoryRecord::nextSub ( const DcmDirectoryRecord dirRec) [virtual]

get next directory child record starting at a given record

Parameters:
dirRecrecord to start from (goto first record if NULL)
Returns:
pointer to next record if successful, NULL otherwise
DcmDirectoryRecord& DcmDirectoryRecord::operator= ( const DcmDirectoryRecord obj)

assignment operator

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

print all elements of the item 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 DcmDirectoryRecord::read ( DcmInputStream inStream,
const E_TransferSyntax  xfer,
const E_GrpLenEncoding  glenc = EGL_noChange,
const Uint32  maxReadLength = DCM_MaxReadLength 
) [virtual]

This function reads the information of all attributes which are captured in the input stream and captures this information in elementList.

Each attribute is represented as an element in this list. If not all information for an attribute could be read from the stream, the function returns EC_StreamNotifyClient.

Parameters:
inStreamThe stream which contains the information.
xferThe transfer syntax which was used to encode the information in inStream.
glencEncoding type for group length; specifies what will be done with group length tags.
maxReadLengthMaximum read length for reading an attribute value.
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual DcmDirectoryRecord* DcmDirectoryRecord::removeSub ( const unsigned long  num) [virtual]

remove child directory record.

If found, the record is not deleted but returned to the caller who is responsible for further management of the DcmDirectoryRecord object.

Parameters:
numindex number of element, must be < cardSub()
Returns:
pointer to DcmDirectoryRecord if found, NULL otherwise

remove child directory record.

If found, the record is not deleted but returned to the caller who is responsible for further management of the DcmDirectoryRecord object.

Parameters:
dirRecpointer to element to be removed from list
Returns:
pointer to element if found, NULL otherwise
virtual OFCondition DcmDirectoryRecord::search ( const DcmTagKey xtag,
DcmStack resultStack,
E_SearchMode  mode = ESM_fromHere,
OFBool  searchIntoSub = OFTrue 
) [virtual]

a complex, stack-based, hierarchical search method.

It allows for a search for a DICOM object with a given attribute within a given container, hierarchically, from a starting position identified through a cursor stack.

Parameters:
xtagthe DICOM attribute tag we are searching for
resultStackDepending on the search mode (see below), this parameter either serves as an input and output parameter, or as an output parameter only (the latter being the default). When used as an input parameter, the cursor stack defines the start position for the search within a hierarchical DICOM dataset. Upon successful return, the stack contains the position of the element found, in the form of a pointer to each dataset, sequence, item and element from the main dataset down to the found element.
modesearch mode, controls how the search stack is handled. In the default mode, ESM_fromHere, the stack is ignored on input, and the search starts in the object for which this method is called. In the other modes, the stack is used both as an input and an output parameter and defines the starting point for the search.
searchIntoSubif true, the search will be performed hierarchically descending into the sequences and items of the dataset. If false, only the current container (sequence or item) will be traversed.
Returns:
EC_Normal if found, EC_TagNotFound if not found, an error code is something went wrong.

Reimplemented from DcmItem.

virtual void DcmDirectoryRecord::setRecordsOriginFile ( const char *  fname) [virtual]

store the filename from which this directory record was read from

Parameters:
fnamefilename, must not be NULL
virtual OFCondition DcmDirectoryRecord::verify ( const OFBool  autocorrect = OFFalse) [virtual]

check the currently stored element value

Parameters:
autocorrectcorrect value length if OFTrue
Returns:
status, EC_Normal if value length is correct, an error code otherwise

Reimplemented from DcmItem.

virtual OFCondition DcmDirectoryRecord::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