GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmCSAHeaderDict.h
Go to the documentation of this file.

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