dcmdata/include/dcmtk/dcmdata/dcpath.h

00001 /*
00002  *
00003  *  Copyright (C) 2008-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 declarations for accessing DICOM dataset structures (items,
00019  *           sequences and leaf elements via string-based path access.
00020  *
00021  *  Last Update:      $Author: joergr $
00022  *  Update Date:      $Date: 2010-10-14 13:15:41 $
00023  *  CVS/RCS Revision: $Revision: 1.10 $
00024  *  Status:           $State: Exp $
00025  *
00026  *  CVS/RCS Log at end of file
00027  *
00028  */
00029 
00030 #ifndef DCPATH_H
00031 #define DCPATH_H
00032 
00033 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00034 
00035 #include "dcmtk/dcmdata/dcdatset.h"
00036 
00037 
00045 class DcmPathNode
00046 {
00047 
00048 public:
00049 
00052   DcmPathNode() : m_obj(NULL), m_itemNo(0) {}
00053 
00061   DcmPathNode(DcmObject* obj, Uint32 itemNo)    : m_obj(obj), m_itemNo(itemNo) {}
00062 
00065   ~DcmPathNode() { }
00066 
00068   DcmObject* m_obj;
00069 
00071   Uint32 m_itemNo;
00072 
00073 private:
00074 
00077   DcmPathNode(const DcmPathNode& rhs);
00078 
00081   DcmPathNode& operator=(const DcmPathNode& arg);
00082 
00083 };
00084 
00085 
00094 class DcmPath
00095 {
00096 
00097 public:
00098 
00101   DcmPath();
00102 
00107   DcmPath(const OFList<DcmPathNode*>& currentPath);
00108 
00114   void append(DcmPathNode* node);
00115 
00120   void deleteBackNode();
00121 
00125   OFListIterator(DcmPathNode*) begin();
00126 
00130   DcmPathNode* back();
00131 
00135   OFListIterator(DcmPathNode*) end();
00136 
00140   Uint32 size() const;
00141 
00145   OFBool empty() const;
00146 
00151   OFString toString() const;
00152 
00158   OFBool containsGroup(const Uint16& groupNo) const;
00159 
00168   static OFCondition separatePathNodes(const OFString& path, OFList<OFString>& result);
00169 
00183   static OFCondition parseItemNoFromPath(OFString& path,                   // inout
00184                                          Uint32& itemNo,                   // out
00185                                          OFBool& wasWildcard);             // out
00186 
00196   static OFCondition parseTagFromPath(OFString& path,         // inout
00197                                       DcmTag& tag);           // out
00198 
00204   ~DcmPath();
00205 
00206 private:
00207 
00209   OFList<DcmPathNode*> m_path;
00210 
00213   DcmPath(const DcmPath& rhs);
00214 
00217   DcmPath& operator=(const DcmPath& arg);
00218 };
00219 
00220 
00221 class DcmPathProcessor
00222 {
00223 
00224 public:
00225 
00228   DcmPathProcessor();
00229 
00236   void setItemWildcardSupport(const OFBool& supported);
00237 
00238 
00247   void checkPrivateReservations(const OFBool& doChecking);
00248 
00287   OFCondition findOrCreatePath(DcmObject* obj,
00288                                const OFString& path,
00289                                OFBool createIfNecessary = OFFalse);
00290 
00315   OFCondition findOrDeletePath(DcmObject* obj,
00316                                const OFString& path,
00317                                Uint32& numDeleted);
00318 
00326   Uint32 getResults(OFList<DcmPath*>& searchResults);
00327 
00328 
00341   OFCondition applyPathWithValue(DcmDataset *dataset,
00342                                          const OFString& overrideKey);
00343 
00347   ~DcmPathProcessor();
00348 
00349 protected:
00350 
00384   OFCondition findOrCreateItemPath(DcmItem* item,
00385                                    OFString& path);
00386 
00419   OFCondition findOrCreateSequencePath(DcmSequenceOfItems* seq,
00420                                        OFString& path);
00421 
00433   static OFCondition deleteLastElemFromPath(DcmObject* objSearchedIn,
00434                                             DcmPath *path,
00435                                             DcmPathNode* toDelete);
00436 
00448   static OFCondition deleteLastItemFromPath(DcmObject* objSearchedIn,
00449                                             DcmPath *path,
00450                                             DcmPathNode* toDelete);
00451 
00461   OFCondition checkPrivateTagReservation(DcmItem *item,
00462                                          DcmTag& tag);
00469   static DcmTagKey calcPrivateReservationTag(const DcmTagKey &privateKey);
00470 
00479   void clear();
00480 
00481 private:
00482 
00484   OFList<DcmPathNode*> m_currentPath;
00485 
00487   OFList<DcmPath*> m_results;
00488 
00491   OFBool m_createIfNecessary;
00492 
00495   OFBool m_checkPrivateReservations;
00496 
00499   OFBool m_itemWildcardsEnabled;
00500 
00503   DcmPathProcessor(const DcmPathProcessor& rhs);
00504 
00507   DcmPathProcessor& operator=(const DcmPathProcessor& arg);
00508 
00509 };
00510 
00511 
00512 #endif // DCPATH_H
00513 
00514 /*
00515 ** CVS/RCS Log:
00516 ** $Log: dcpath.h,v $
00517 ** Revision 1.10  2010-10-14 13:15:41  joergr
00518 ** Updated copyright header. Added reference to COPYRIGHT file.
00519 **
00520 ** Revision 1.9  2010-08-09 13:02:56  joergr
00521 ** Updated data dictionary to 2009 edition of the DICOM standard. From now on,
00522 ** the official "keyword" is used for the attribute name which results in a
00523 ** number of minor changes (e.g. "PatientsName" is now called "PatientName").
00524 **
00525 ** Revision 1.8  2009-11-04 09:58:07  uli
00526 ** Switched to logging mechanism provided by the "new" oflog module
00527 **
00528 ** Revision 1.7  2009-09-29 12:55:17  uli
00529 ** Include only the needed headers in dcpath.h and dcpath.cc
00530 **
00531 ** Revision 1.6  2009-07-10 13:12:30  onken
00532 ** Added override key functionality used by tools like findscu to the more
00533 ** central DcmPathProcessor class.
00534 **
00535 ** Revision 1.5  2009-07-08 16:09:30  onken
00536 ** Cleaned up code for private reservation checking and added option for
00537 ** disabling item wildcards for searching/creating tag paths.
00538 **
00539 ** Revision 1.4  2009-01-15 16:04:06  onken
00540 ** Added options for handling of private tags and fixed bug for deleting
00541 ** tags on main level.
00542 **
00543 ** Revision 1.3  2009-01-12 12:37:45  onken
00544 ** Fixed iterators to also compile with STL classes being enabled.
00545 **
00546 ** Revision 1.2  2008-12-12 13:16:03  onken
00547 ** Fixed doxygen documentation.
00548 **
00549 ** Revision 1.1  2008-12-12 11:44:40  onken
00550 ** Moved path access functions to separate classes
00551 **
00552 */


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