dcmdata/apps/mdfdsman.h

00001 /*
00002  *
00003  *  Copyright (C) 2003-2010, OFFIS e.V.
00004  *  All rights reserved.  See COPYRIGHT file for details.
00005  *
00006  *  This software and supporting documentation were developed by
00007  *
00008  *    OFFIS e.V.
00009  *    R&D Division Health
00010  *    Escherweg 2
00011  *    D-26121 Oldenburg, Germany
00012  *
00013  *
00014  *  Module:  dcmdata
00015  *
00016  *  Author:  Michael Onken
00017  *
00018  *  Purpose: Class for modifying DICOM files
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:17:52 $
00022  *  CVS/RCS Revision: $Revision: 1.22 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 #ifndef MDFDSMAN_H
00030 #define MDFDSMAN_H
00031 
00032 #include "dcmtk/config/osconfig.h"   // make sure OS specific configuration is included first
00033 
00034 #include "dcmtk/ofstd/ofcond.h"
00035 #include "dcmtk/dcmdata/dctagkey.h"
00036 #include "dcmtk/dcmdata/dcxfer.h"
00037 
00038 
00039 // forward declarations
00040 class DcmDataset;
00041 class DcmFileFormat;
00042 class DcmElement;
00043 
00044 
00049 class MdfDatasetManager
00050 {
00051 public:
00052 
00055     MdfDatasetManager();
00056 
00059     ~MdfDatasetManager();
00060 
00067     OFCondition loadFile(const char *file_name,
00068                          const E_FileReadMode readMode = ERM_autoDetect,
00069                          const E_TransferSyntax xfer = EXS_Unknown);
00070 
00086     OFCondition modifyOrInsertPath(OFString tag_path,
00087                                    const OFString &value,
00088                                    const OFBool &only_modify,
00089                                    const OFBool update_metaheader = OFTrue,
00090                                    const OFBool ignore_missing_tags = OFFalse,
00091                                    const OFBool no_reservation_checks = OFFalse);
00092 
00108     OFCondition modifyOrInsertFromFile(OFString tag_path,
00109                                        const OFString &filename,
00110                                        const OFBool &only_modify,
00111                                        const OFBool update_metaheader = OFTrue,
00112                                        const OFBool ignore_missing_tags = OFFalse,
00113                                        const OFBool no_reservation_checks = OFFalse);
00114 
00126     OFCondition modifyAllTags(OFString tag_path,
00127                               const OFString &value,
00128                               const OFBool update_metaheader,
00129                               int &count,
00130                               const OFBool ignore_missing_tags = OFFalse);
00131 
00141     OFCondition deleteTag(OFString tag_path,
00142                           const OFBool all_tags,
00143                           const OFBool ignore_missing_tags);
00144 
00149     OFCondition deletePrivateData();
00150 
00158     OFCondition generateAndInsertUID(const DcmTagKey &uidKey);
00159 
00172     OFCondition saveFile(const char *file_name,
00173                          E_TransferSyntax opt_xfer = EXS_Unknown,
00174                          E_EncodingType opt_enctype = EET_UndefinedLength,
00175                          E_GrpLenEncoding opt_glenc = EGL_recalcGL,
00176                          E_PaddingEncoding opt_padenc = EPD_noChange,
00177                          OFCmdUnsignedInt opt_filepad = 0,
00178                          OFCmdUnsignedInt opt_itempad = 0,
00179                          OFBool opt_dataset = OFFalse);
00180 
00185     OFCondition saveFile();
00186 
00193     DcmDataset* getDataset();
00194 
00195 
00202     DcmFileFormat* getFileFormat();
00203 
00207     OFString getFilename() const;
00208 
00213     void setModifyUNValues(OFBool modifyUNValues);
00214 
00215 protected:
00216 
00222     OFCondition startModify(DcmElement *elem,
00223                             const OFString &value);
00224 
00231     void deleteRelatedMetaheaderTag(const DcmTagKey &key);
00232 
00237     OFBool isTagInDictionary(const DcmTagKey &search_key);
00238 
00239 private:
00240 
00242     OFString current_file;
00243 
00245     DcmFileFormat *dfile;
00246 
00248     DcmDataset *dset;
00249 
00252     OFBool ignore_un_modifies;
00253 
00256     MdfDatasetManager &operator=(const MdfDatasetManager &);
00257 
00260     MdfDatasetManager(const MdfDatasetManager &);
00261 };
00262 
00263 #endif // MDFDSMAN_H
00264 
00265 
00266 /*
00267 ** CVS/RCS Log:
00268 ** $Log: mdfdsman.h,v $
00269 ** Revision 1.22  2010-10-14 13:17:52  joergr
00270 ** Updated copyright header. Added reference to COPYRIGHT file.
00271 **
00272 ** Revision 1.21  2010-05-20 15:44:55  joergr
00273 ** Added support for reading the value of insert/modify statements from a file.
00274 ** Removed some unnecessary include directives.
00275 **
00276 ** Revision 1.20  2009-11-04 09:58:06  uli
00277 ** Switched to logging mechanism provided by the "new" oflog module
00278 **
00279 ** Revision 1.19  2009-01-15 16:11:55  onken
00280 ** Reworked dcmodify to work with the new DcmPath classes for supporting
00281 ** wildcard paths and automatic insertion of missing attributes and items.
00282 ** Added options for private tag handling and modification of UN values and
00283 ** for ignoring errors resulting from missing tags during modify and erase
00284 ** operations. Further cleanups.
00285 **
00286 ** Revision 1.18  2008-07-11 08:37:45  joergr
00287 ** Fixed typo in API documentation.
00288 **
00289 ** Revision 1.17  2006/11/23 15:32:58  onken
00290 ** Made member variables private (before: protected)
00291 **
00292 ** Revision 1.16  2005/12/08 15:46:50  meichel
00293 ** Updated Makefiles to correctly install header files
00294 **
00295 ** Revision 1.15  2005/12/02 09:21:47  joergr
00296 ** Added new file read mode that makes it possible to distinguish between DICOM
00297 ** files, datasets and other non-DICOM files.  For this reason, the last
00298 ** parameter of method loadFile() changed from OFBool to E_FileReadMode.
00299 **
00300 ** Revision 1.14  2005/11/30 16:41:41  onken
00301 ** Added standard parameter values for saveFile()
00302 **
00303 ** Revision 1.13  2005/11/14 15:00:14  joergr
00304 ** Made method getFilename() const.
00305 **
00306 ** Revision 1.12  2004/11/05 17:17:24  onken
00307 ** Added input and output options for dcmodify. minor code enhancements.
00308 **
00309 ** Revision 1.11  2004/10/22 16:53:26  onken
00310 ** - fixed ignore-errors-option
00311 ** - major enhancements for supporting private tags
00312 ** - removed '0 Errors' output
00313 ** - modifications to groups 0000,0001,0002,0003,0005 and 0007 are blocked,
00314 **   removing tags with group 0001,0003,0005 and 0007 is still possible
00315 ** - UID options:
00316 **   - generate new study, series and instance UIDs
00317 **   - When changing UIDs in dataset, related metaheader tags are updated
00318 **     automatically
00319 ** - minor code improvements
00320 **
00321 ** Revision 1.10  2004/05/14 12:08:36  onken
00322 ** Additional documentation added.
00323 **
00324 ** Revision 1.9  2004/04/19 14:45:07  onken
00325 ** Restructured code to avoid default parameter values for "complex types" like
00326 ** OFString. Required for Sun CC 2.0.1.
00327 **
00328 ** Revision 1.8  2003/12/17 17:07:22  onken
00329 ** MdfDatasetManager now remembers loaded filename. Additional save function
00330 ** added.
00331 **
00332 ** Revision 1.7  2003/12/10 16:19:20  onken
00333 ** Changed API of MdfDatasetManager, so that its transparent for user, whether
00334 ** he wants to modify itemtags or tags at 1. level.
00335 **
00336 ** Complete rewrite of MdfConsoleEngine. It doesn't support a batchfile any more,
00337 ** but now a user can give different modify-options at the same time on
00338 ** commandline. Other purifications and simplifications were made.
00339 **
00340 ** Revision 1.6  2003/11/11 10:55:51  onken
00341 ** - debug-mechanism doesn't use debug(..) any more
00342 ** - comments purified
00343 ** - headers adjustet to debug-modifications
00344 **
00345 ** Revision 1.5  2003/10/13 14:46:50  onken
00346 ** startModify(...) simplified (uses only putString to put element-values),
00347 ** this also allows now inserting and modifying of elements with VRM>1.
00348 ** Method getDataset() added.
00349 **
00350 ** Revision 1.4  2003/10/01 14:04:03  onken
00351 ** Corrected doxygen-information in headerfiles
00352 **
00353 ** Revision 1.3  2003/09/19 12:41:11  onken
00354 ** major bugfixes, new code structure, better error-handling, corrections for "dcmtk-coding-style",Handling of VR's corrected
00355 **
00356 ** Revision 1.2  2003/07/09 12:13:13  meichel
00357 ** Included dcmodify in MSVC build system, updated headers
00358 **
00359 ** Revision 1.1  2003/06/26 09:17:18  onken
00360 ** Added commandline-application dcmodify.
00361 **
00362 **
00363 */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1