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. | |
DcmDataset * | getDataset () |
Returns the dataset, that this MdfDatasetManager handles. | |
DcmFileFormat * | getFileFormat () |
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 | |
DcmFileFormat * | dfile |
will hold file to modify | |
DcmDataset * | dset |
will hold the dataset, that should be modified | |
OFBool | debug_option |
enable debug messages | |
Private Member Functions | |
MdfDatasetManager & | operator= (const MdfDatasetManager &) |
private undefined assignment operator | |
MdfDatasetManager (const MdfDatasetManager &) | |
private undefined copy constructor |
Therefore it allows the process of load->modify->save to provide this service.
Definition at line 48 of file mdfdsman.h.
MdfDatasetManager::MdfDatasetManager | ( | const OFBool | debug = OFFalse |
) |
Constructor, initializes member-variables.
debug | enables/disables debug-messages (off per default) |
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.
file_name | file to be loaded | |
readMode | read file with or without metaheader | |
xfer | try to read with this transfer syntax. Default=autodetect |
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.
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) |
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.
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 |
OFCondition MdfDatasetManager::deleteTag | ( | OFString | tag_path, | |
const OFBool & | all_tags | |||
) |
Deletes tag in dataset.
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 |
OFCondition MdfDatasetManager::generateNewStudyUID | ( | ) |
Generates new 'Study Instance UID' and inserts it into the dataset.
'Series Instance UID' and 'SOP Instance UID' are not affected.
OFCondition MdfDatasetManager::generateNewSeriesUID | ( | ) |
Generates new 'Series Instance UID' and inserts it into the dataset.
'SOP Instance UID' is not affected.
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::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.
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 |
OFCondition MdfDatasetManager::saveFile | ( | ) |
Saves current dataset back to file using original filename and original parameters like transfer syntax, padding etc.
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.
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.
OFString MdfDatasetManager::getFilename | ( | ) | const |
Returns filename of the file, that's loaded currently.
OFCondition MdfDatasetManager::startModify | ( | DcmElement * | elem, | |
const OFString & | value | |||
) | [protected] |
modifies element to a specific value
elem | element, that should be changed | |
value | the value, the element should be changed to |
OFCondition MdfDatasetManager::startInsert | ( | DcmItem * | item, | |
DcmTagKey & | search_key, | |||
const OFString & | value | |||
) | [protected] |
inserts tag into item with a specific value, overwrites existing tag
item | item, where tag is inserted | |
search_key | specifies tag to be inserted | |
value | value that should be inserted in item |
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.
key | tag to examine |
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
key | tag, whose group should be examined |
OFBool MdfDatasetManager::isPrivateTag | ( | const DcmTagKey & | tag_key | ) | [protected] |
Returns true, if given tag is a private tag (odd group number).
tag_key | tag key, that should be tested |
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)
tag_key | tag key, that should be tested |
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.
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 |
Calculates from given private tag the reservation tag, that would make a reservation for this private tag.
tag_key | tag key, whose reservation should be calculated |
OFBool MdfDatasetManager::isTagInDictionary | ( | const DcmTagKey & | search_key | ) | [protected] |
Returns true, if given tag key can be found in dictionary.
search_key | tag to lookup |
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
condition | message is printed, if condition is true | |
s1 | first message string | |
s2 | second message string | |
s2 | third message string |