# gdcmCSAHeaderDict.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2010 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015 #ifndef GDCMCSAHEADERDICT_H
    00016 #define GDCMCSAHEADERDICT_H
    00017
    00018 #include "gdcmTypes.h"
    00019 #include "gdcmTag.h"
    00020 #include "gdcmCSAHeaderDictEntry.h"
    00021
    00022 #include <iostream>
    00023 #include <iomanip>
    00024 #include <set>
    00025 #include <exception>
    00026
    00027 namespace gdcm
    00028 {
    00029
    00030 class GDCM_EXPORT CSAHeaderDictException : public std::exception {};
    00031
    00035 class GDCM_EXPORT CSAHeaderDict
    00036 {
    00037 public:
    00038   typedef std::set<CSAHeaderDictEntry> MapCSAHeaderDictEntry;
    00039   typedef MapCSAHeaderDictEntry::iterator Iterator;
    00040   typedef MapCSAHeaderDictEntry::const_iterator ConstIterator;
    00041   //static CSAHeaderDictEntry GroupLengthCSAHeaderDictEntry; // = CSAHeaderDictEntry("Group Length",VR::UL,VM::VM1);
    00042
    00043   CSAHeaderDict():CSAHeaderDictInternal() {
    00044     assert( CSAHeaderDictInternal.empty() );
    00045   }
    00046
    00047   friend std::ostream& operator<<(std::ostream& _os, const CSAHeaderDict &_val);
    00048
    00049   ConstIterator Begin() const { return CSAHeaderDictInternal.begin(); }
    00050   ConstIterator End() const { return CSAHeaderDictInternal.end(); }
    00051
    00052   bool IsEmpty() const { return CSAHeaderDictInternal.empty(); }
    00053   void AddCSAHeaderDictEntry(const CSAHeaderDictEntry &de)
    00054     {
    00055 #ifndef NDEBUG
    00056     MapCSAHeaderDictEntry::size_type s = CSAHeaderDictInternal.size();
    00057 #endif
    00058     CSAHeaderDictInternal.insert( de );
    00059     assert( s < CSAHeaderDictInternal.size() );
    00060     }
    00061
    00062   const CSAHeaderDictEntry &GetCSAHeaderDictEntry(const char *name) const
    00063     {
    00064     MapCSAHeaderDictEntry::const_iterator it = CSAHeaderDictInternal.find( name );
    00065     if( it != CSAHeaderDictInternal.end() )
    00066       {
    00067       return *it;
    00068       }
    00069     throw CSAHeaderDictException();
    00070     }
    00071
    00072 protected:
    00073   friend class Dicts;
    00074   void LoadDefault();
    00075
    00076 private:
    00077   CSAHeaderDict &operator=(const CSAHeaderDict &_val); // purposely not implemented
    00078   CSAHeaderDict(const CSAHeaderDict &_val); // purposely not implemented
    00079
    00080   MapCSAHeaderDictEntry CSAHeaderDictInternal;
    00081 };
    00082 //-----------------------------------------------------------------------------
    00083 inline std::ostream& operator<<(std::ostream& os, const CSAHeaderDict &val)
    00084 {
    00085   CSAHeaderDict::MapCSAHeaderDictEntry::const_iterator it = val.CSAHeaderDictInternal.begin();
    00086   for(;it != val.CSAHeaderDictInternal.end(); ++it)
    00087     {
    00088     const CSAHeaderDictEntry &de = *it;
    00089     os << de << '\n';
    00090     }
    00091
    00092
    00093   return os;
    00094 }
    00095
    00096
    00097 } // end namespace gdcm
    00098
    00099 #endif //GDCMCSAHEADERDICT_H