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)
 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.

Definition at line 49 of file mdfdsman.h.


Member Function Documentation

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. Default=autodetect
xfer try to read with this transfer syntax. Default=autodetect
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_path path to item/element
value denotes new value of tag
only_modify if true, only existing tags are processed. If false, any not existing tag is inserted
update_metaheader updates metaheader UIDs, if related UIDs in dataset are changed (default=true)
ignore_missing_tags if true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
no_reservation_checks if 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::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_path path to item/element
filename name of the file from which the value should be read
only_modify if true, only existing tags are processed. If false, any not existing tag is inserted
update_metaheader updates metaheader UIDs, if related UIDs in dataset are changed (default=true)
ignore_missing_tags if true, tags that could not be found while modifying (only_modify must be true) are handled as non-errors
no_reservation_checks if 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::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_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
ignore_missing_tags if 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::deleteTag ( OFString  tag_path,
const OFBool  all_tags,
const OFBool  ignore_missing_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 1st level is accessed
ignore_missing_tags if 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::deletePrivateData (  ) 

Deletes all private data from file, ie.

all tags having odd group numbers.

Returns:
EC_Normal, if deletion was successful; error code otherwise

OFCondition MdfDatasetManager::generateAndInsertUID ( const DcmTagKey uidKey  ) 

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

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::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

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.

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:
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

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

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


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