MdfDatasetManager Class Reference

This class encapsulates data structures and operations for modifying Dicom files. More...

List of all members.

Public Member Functions

 MdfDatasetManager (const OFBool debug=OFFalse)
 Constructor, initializes member-variables.
 ~MdfDatasetManager ()
 Destructor.
OFCondition loadFile (const char *file_name, const E_FileReadMode readMode=ERM_autoDetect, const E_TransferSyntax xfer=EXS_Unknown)
 Loads a file into dataset manager.
OFCondition modifyOrInsertTag (OFString tag_path, const OFString &value, const OFBool &only_modify, const OFBool update_metaheader=OFTrue)
 Modifies/Inserts a tag with a specific value.
OFCondition modifyAllTags (OFString tag_path, const OFString &value, const OFBool update_metaheader, int &count)
 Modifies all matching tags in dataset to a new value.
OFCondition deleteTag (OFString tag_path, const OFBool &all_tags)
 Deletes tag in dataset.
OFCondition generateNewStudyUID ()
 Generates new 'Study Instance UID' and inserts it into the dataset.
OFCondition generateNewSeriesUID ()
 Generates new 'Series Instance UID' and inserts it into the dataset.
OFCondition generateNewInstanceUID ()
 Generates new 'SOP Instance UID' and inserts it into the dataset.
OFCondition saveFile (const char *file_name, E_TransferSyntax opt_xfer=EXS_Unknown, E_EncodingType opt_enctype=EET_UndefinedLength, E_GrpLenEncoding opt_glenc=EGL_recalcGL, E_PaddingEncoding opt_padenc=EPD_noChange, OFCmdUnsignedInt opt_filepad=0, OFCmdUnsignedInt opt_itempad=0, OFBool opt_dataset=OFFalse)
 Saves current dataset back to a file.
OFCondition saveFile ()
 Saves current dataset back to file using original filename and original parameters like transfer syntax, padding etc.
DcmDatasetgetDataset ()
 Returns the dataset, that this MdfDatasetManager handles.
DcmFileFormatgetFileFormat ()
 Returns the DcmFileFormat, that this MdfDatasetManager handles.
OFString getFilename () const
 Returns filename of the file, that's loaded currently.

Protected Member Functions

OFCondition startModify (DcmElement *elem, const OFString &value)
 modifies element to a specific value
OFCondition startInsert (DcmItem *item, DcmTagKey &search_key, const OFString &value)
 inserts tag into item with a specific value, overwrites existing tag
void deleteRelatedMetaheaderTag (const DcmTagKey &key)
 If key is the tag for SOPInstanceUID or SOPClassUID, then this function removes the related MediaStorage UIDs from the metaheader.
OFCondition hasValidGroupNumber (const DcmTagKey &key)
 Checks whether group number is 0,1,2,3,5 or 7.
OFBool isPrivateTag (const DcmTagKey &tag_key)
 Returns true, if given tag is a private tag (odd group number).
OFBool isPrivateReservationTag (const DcmTagKey &tag_key)
 Returns true, if given tag is a private reservation tag.
OFBool hasPrivateReservationContext (const DcmTagKey &tag_key, DcmItem *item, OFString &priv_creator)
 Returns true, if given tag is reserved in given item.
DcmTagKey calcPrivateReservationTag (const DcmTagKey &tag_key)
 Calculates from given private tag the reservation tag, that would make a reservation for this private tag.
OFBool isTagInDictionary (const DcmTagKey &search_key)
 Returns true, if given tag key can be found in dictionary.
void debugMsg (const OFBool &condition, const OFString &s1, const OFString &s2, const OFString &s3)
 The function handles three strings, that are directly printed after another.

Protected Attributes

OFString act_file
 name of file, that is loaded currently
DcmFileFormatdfile
 will hold file to modify
DcmDatasetdset
 will hold the dataset, that should be modified
OFBool debug_option
 enable debug messages

Private Member Functions

MdfDatasetManageroperator= (const MdfDatasetManager &)
 private undefined assignment operator
 MdfDatasetManager (const MdfDatasetManager &)
 private undefined copy constructor


Detailed Description

This class encapsulates data structures and operations for modifying Dicom files.

Therefore it allows the process of load->modify->save to provide this service.

Definition at line 48 of file mdfdsman.h.


Constructor & Destructor Documentation

MdfDatasetManager::MdfDatasetManager const OFBool  debug = OFFalse  ) 
 

Constructor, initializes member-variables.

Parameters:
debug enables/disables debug-messages (off per default)


Member Function Documentation

DcmTagKey MdfDatasetManager::calcPrivateReservationTag const DcmTagKey tag_key  )  [protected]
 

Calculates from given private tag the reservation tag, that would make a reservation for this private tag.

Parameters:
tag_key tag key, whose reservation should be calculated
Returns:
the tag key, that would reserve given private tag

void MdfDatasetManager::debugMsg const OFBool &  condition,
const OFString s1,
const OFString s2,
const OFString s3
[protected]
 

The function handles three strings, that are directly printed after another.

The whole message is then terminated by

Parameters:
condition message is printed, if condition is true
s1 first message string
s2 second message string
s2 third message string

void MdfDatasetManager::deleteRelatedMetaheaderTag const DcmTagKey key  )  [protected]
 

If key is the tag for SOPInstanceUID or SOPClassUID, then this function removes the related MediaStorage UIDs from the metaheader.

The metaheader is then updated automagically when the file is saved back to disk.

Parameters:
key tag to examine

OFCondition MdfDatasetManager::deleteTag OFString  tag_path,
const OFBool &  all_tags
 

Deletes tag in dataset.

Parameters:
tag_path holds complete path to tag
all_tags If true, tag is deleted at all levels of dataset, else only 1. level is accessed
Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::generateNewInstanceUID  ) 
 

Generates new 'SOP Instance UID' and inserts it into the dataset.

The related metaheader tag ('Media Storage SOP Instance UID') is deleted from metaheader, so that it gets created correctly, if the file is saved to disk.

OFCondition MdfDatasetManager::generateNewSeriesUID  ) 
 

Generates new 'Series Instance UID' and inserts it into the dataset.

'SOP Instance UID' is not affected.

OFCondition MdfDatasetManager::generateNewStudyUID  ) 
 

Generates new 'Study Instance UID' and inserts it into the dataset.

'Series Instance UID' and 'SOP Instance UID' are not affected.

DcmDataset* MdfDatasetManager::getDataset  ) 
 

Returns the dataset, that this MdfDatasetManager handles.

You should use the returned object with care to avoid sideeffects with other class methods, that modify this object, too.

Returns:
returns the dataset, this MdfDatasetManager manages and NULL, if no dataset is loaded

DcmFileFormat* MdfDatasetManager::getFileFormat  ) 
 

Returns the DcmFileFormat, that this MdfDatasetManager handles.

You should use the returned object with care to avoid sideeffects with other class methods, that modify this object, too.

Returns:
returns the DcmFileFormat, this MdfDatasetManager manages and NULL, if no file is loaded

OFString MdfDatasetManager::getFilename  )  const
 

Returns filename of the file, that's loaded currently.

Returns:
returns filename and "" if no file is loaded.

OFBool MdfDatasetManager::hasPrivateReservationContext const DcmTagKey tag_key,
DcmItem item,
OFString priv_creator
[protected]
 

Returns true, if given tag is reserved in given item.

The private creator string is returned, too.

Parameters:
tag_key tag key, that should be checked
item this item is searched for the reservation
priv_creator OUT:private creator string of reservation, if found
Returns:
OFTrue if tag has a matching reservation, else OFFalse

OFCondition MdfDatasetManager::hasValidGroupNumber const DcmTagKey key  )  [protected]
 

Checks whether group number is 0,1,2,3,5 or 7.

Then an error is returned, because these groups are illegal or shouldn't be modified

Parameters:
key tag, whose group should be examined
Returns:
OFCondition with OF_ok if group is ok, else OF_error and an error message are returned

OFBool MdfDatasetManager::isPrivateReservationTag const DcmTagKey tag_key  )  [protected]
 

Returns true, if given tag is a private reservation tag.

Thats is the case, if tag has the form gggg,00ee (10<ee<FF)

Parameters:
tag_key tag key, that should be tested
Returns:
OFTrue if tag is a private reservation tag, else OFFalse

OFBool MdfDatasetManager::isPrivateTag const DcmTagKey tag_key  )  [protected]
 

Returns true, if given tag is a private tag (odd group number).

Parameters:
tag_key tag key, that should be tested
Returns:
OFTrue if tag is private, else OFFalse

OFBool MdfDatasetManager::isTagInDictionary const DcmTagKey search_key  )  [protected]
 

Returns true, if given tag key can be found in dictionary.

Parameters:
search_key tag to lookup
Returns:
OFTrue if tag could be found, else OFFalse

OFCondition MdfDatasetManager::loadFile const char *  file_name,
const E_FileReadMode  readMode = ERM_autoDetect,
const E_TransferSyntax  xfer = EXS_Unknown
 

Loads a file into dataset manager.

Parameters:
file_name file to be loaded
readMode read file with or without metaheader
xfer try to read with this transfer syntax. Default=autodetect
Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::modifyAllTags OFString  tag_path,
const OFString value,
const OFBool  update_metaheader,
int &  count
 

Modifies all matching tags in dataset to a new value.

Parameters:
tag_path denotes, which tag to modify
value denotes new value of tag
update_metaheader if true, metaheader uids are updated, if related dataset uids are changed, (default=true)
count returns holds the number of tags, that were affected
Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::modifyOrInsertTag OFString  tag_path,
const OFString value,
const OFBool &  only_modify,
const OFBool  update_metaheader = OFTrue
 

Modifies/Inserts a tag with a specific value.

Parameters:
tag_path holds complete path to tag
value denotes new value of tag
only_modify if true, only existing tags are processed. If false, not existing tag is inserted
update_metaheader updates metaheader UIDs, if related UIDs in dataset are changed (default=true)
Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::saveFile  ) 
 

Saves current dataset back to file using original filename and original parameters like transfer syntax, padding etc.

Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::saveFile const char *  file_name,
E_TransferSyntax  opt_xfer = EXS_Unknown,
E_EncodingType  opt_enctype = EET_UndefinedLength,
E_GrpLenEncoding  opt_glenc = EGL_recalcGL,
E_PaddingEncoding  opt_padenc = EPD_noChange,
OFCmdUnsignedInt  opt_filepad = 0,
OFCmdUnsignedInt  opt_itempad = 0,
OFBool  opt_dataset = OFFalse
 

Saves current dataset back to a file.

Caution: After saving MdfDatasetManager keeps working on old filename.

Parameters:
file_name filename to save to
opt_xfer transfer syntax to save to (EXS_Unknown: dont change)
opt_enctype write with explicit or implicit length encoding
opt_glenc option to set group lenghth calculation mode
opt_padenc sets padding option
opt_filepad pad file to a multiple of this options value
opt_itempad pad item to a multiple of this options value
opt_dataset if true:ony write only dataset, else write fileformat
Returns:
returns EC_normal if everything is ok, else an error

OFCondition MdfDatasetManager::startInsert DcmItem item,
DcmTagKey search_key,
const OFString value
[protected]
 

inserts tag into item with a specific value, overwrites existing tag

Parameters:
item item, where tag is inserted
search_key specifies tag to be inserted
value value that should be inserted in item
Returns:
returns an error code as OFCondition, if an error occurs

OFCondition MdfDatasetManager::startModify DcmElement elem,
const OFString value
[protected]
 

modifies element to a specific value

Parameters:
elem element, that should be changed
value the value, the element should be changed to
Returns:
OFCondition, which returns an error code if an error occurs


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


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5