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

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

List of all members.

Public Member Functions

 MdfDatasetManager ()
 Constructor, initializes member-variables.
 ~MdfDatasetManager ()
 Destructor.
OFCondition loadFile (const char *file_name, const E_FileReadMode readMode=ERM_autoDetect, const E_TransferSyntax xfer=EXS_Unknown, const OFBool createIfNecessary=OFFalse)
 Loads a file into dataset manager.
OFCondition modifyOrInsertPath (OFString tag_path, const OFString &value, const OFBool &only_modify, const OFBool update_metaheader=OFTrue, const OFBool ignore_missing_tags=OFFalse, const OFBool no_reservation_checks=OFFalse)
 Modifies/Inserts a path (with a specific value if desired).
OFCondition modifyOrInsertFromFile (OFString tag_path, const OFString &filename, const OFBool &only_modify, const OFBool update_metaheader=OFTrue, const OFBool ignore_missing_tags=OFFalse, const OFBool no_reservation_checks=OFFalse)
 Modifies/Inserts a path with a specific value read from file.
OFCondition modifyAllTags (OFString tag_path, const OFString &value, const OFBool update_metaheader, int &count, const OFBool ignore_missing_tags=OFFalse)
 Modifies all matching tags in dataset to a new value.
OFCondition deleteTag (OFString tag_path, const OFBool all_tags, const OFBool ignore_missing_tags)
 Deletes tag in dataset.
OFCondition deletePrivateData ()
 Deletes all private data from file, ie.
OFCondition generateAndInsertUID (const DcmTagKey &uidKey)
 Inserts new Study, Series or SOP Instance UID.
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.
void setModifyUNValues (OFBool modifyUNValues)
 Sets whether attributes with VR of UN should be modified or left alone.

Protected Member Functions

OFCondition startModify (DcmElement *elem, const OFString &value)
 modifies element to a specific value
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.
OFBool isTagInDictionary (const DcmTagKey &search_key)
 Returns true, if given tag key can be found in dictionary.

Private Member Functions

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

Private Attributes

OFString current_file
 name of file, that is loaded currently
DcmFileFormatdfile
 will hold file to modify
DcmDatasetdset
 will hold the dataset, that should be modified
OFBool ignore_un_modifies
 if enabled, no value modifications on attributes having VR of UN are not executed

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.


Member Function Documentation

Deletes all private data from file, ie.

all tags having odd group numbers.

Returns:
EC_Normal, if deletion was successful; error code otherwise
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:
keytag to examine
OFCondition MdfDatasetManager::deleteTag ( OFString  tag_path,
const OFBool  all_tags,
const OFBool  ignore_missing_tags 
)

Deletes tag in dataset.

Parameters:
tag_pathholds complete path to tag
all_tagsif true, tag is deleted at all levels of dataset, else only 1st level is accessed
ignore_missing_tagsif true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
Returns:
returns EC_normal if everything is ok, else an error

Inserts new Study, Series or SOP Instance UID.

If SOP Instance UID is generated, the related tag in the metaheader is deleted, too so that the new UID is also applied there when saving to disk later.

Parameters:
uidkey[in] The Instance UID to insert (study, series or sop instance UID key permitted).
Returns:
EC_Normal, if insertion was successful, error otherwise

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

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

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

Returns:
returns filename and "" if no file is loaded.
OFBool MdfDatasetManager::isTagInDictionary ( const DcmTagKey search_key) [protected]

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

Parameters:
search_keytag 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,
const OFBool  createIfNecessary = OFFalse 
)

Loads a file into dataset manager.

Parameters:
file_namefile to be loaded
readModeread file with or without metaheader. Default=autodetect
xfertry to read with this transfer syntax. Default=autodetect
createIfNecessaryIf true, the file is created if it does not exist
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,
const OFBool  ignore_missing_tags = OFFalse 
)

Modifies all matching tags in dataset to a new value.

Parameters:
tag_pathdenotes, which tag to modify
valuedenotes new value of tag
update_metaheaderif true, metaheader uids are updated, if related dataset uids are changed, (default=true)
countreturns holds the number of tags, that were affected
ignore_missing_tagsif true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
Returns:
returns EC_normal if everything is ok, else an error
OFCondition MdfDatasetManager::modifyOrInsertFromFile ( OFString  tag_path,
const OFString filename,
const OFBool &  only_modify,
const OFBool  update_metaheader = OFTrue,
const OFBool  ignore_missing_tags = OFFalse,
const OFBool  no_reservation_checks = OFFalse 
)

Modifies/Inserts a path with a specific value read from file.

Parameters:
tag_pathpath to item/element
filenamename of the file from which the value should be read
only_modifyif true, only existing tags are processed. If false, any not existing tag is inserted
update_metaheaderupdates metaheader UIDs, if related UIDs in dataset are changed (default=true)
ignore_missing_tagsif true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
no_reservation_checksif true, any missing private reservation tags are ignored when inserting private tags. Only makes sense w/o only_modify
Returns:
returns EC_normal if everything is ok, else an error
OFCondition MdfDatasetManager::modifyOrInsertPath ( OFString  tag_path,
const OFString value,
const OFBool &  only_modify,
const OFBool  update_metaheader = OFTrue,
const OFBool  ignore_missing_tags = OFFalse,
const OFBool  no_reservation_checks = OFFalse 
)

Modifies/Inserts a path (with a specific value if desired).

Parameters:
tag_pathpath to item/element
valuedenotes new value of tag
only_modifyif true, only existing tags are processed. If false, any not existing tag is inserted
update_metaheaderupdates metaheader UIDs, if related UIDs in dataset are changed (default=true)
ignore_missing_tagsif true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
no_reservation_checksif true, any missing private reservation tags are ignored when inserting private tags. Only makes sense w/o only_modify
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_namefilename to save to
opt_xfertransfer syntax to save to (EXS_Unknown: dont change)
opt_enctypewrite with explicit or implicit length encoding
opt_glencoption to set group lenghth calculation mode
opt_padencsets padding option
opt_filepadpad file to a multiple of this options value
opt_itempadpad item to a multiple of this options value
opt_datasetif true:ony write only dataset, else write fileformat
Returns:
returns EC_normal if everything is ok, else an error

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
void MdfDatasetManager::setModifyUNValues ( OFBool  modifyUNValues)

Sets whether attributes with VR of UN should be modified or left alone.

Parameters:
modifyUNValues[in] If set, UN values will be modified (default)
OFCondition MdfDatasetManager::startModify ( DcmElement elem,
const OFString value 
) [protected]

modifies element to a specific value

Parameters:
elemelement, that should be changed
valuethe 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 Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027