# gdcmGroupDict.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
    00016 #ifndef GDCMGROUPDICT_H
    00017 #define GDCMGROUPDICT_H
    00018
    00019 #include "gdcmTypes.h"
    00020
    00021 #include <assert.h>
    00022 #include <vector>
    00023 #include <string>
    00024 #include <iostream>
    00025 #include <iomanip>
    00026
    00027 namespace gdcm
    00028 {
    00034 class GDCM_EXPORT GroupDict
    00035 {
    00036 public:
    00037   typedef std::vector<std::string> GroupStringVector;
    00038   GroupDict() { FillDefaultGroupName(); }
    00039   ~GroupDict() {}
    00040
    00041   friend std::ostream& operator<<(std::ostream& _os, const GroupDict &_val);
    00042
    00043   size_t Size() const
    00044     {
    00045     assert( Names.size() == Abbreviations.size() );
    00046     return Names.size(); }
    00047
    00048   std::string const &GetAbbreviation(uint16_t num) const;
    00049
    00050   std::string const &GetName(uint16_t num) const;
    00051
    00052 protected:
    00053   void Add(std::string const &abbreviation, std::string const &name);
    00054   void Insert(uint16_t num, std::string const &abbreviation, std::string const &name);
    00055
    00056 private:
    00057   // Generated implementation, see gdcmDefaultGroupNames
    00058   void FillDefaultGroupName();
    00059
    00060   GroupDict &operator=(const GroupDict &_val); // purposely not implemented
    00061   GroupDict(const GroupDict &_val); // purposely not implemented
    00062
    00063   GroupStringVector Abbreviations;
    00064   GroupStringVector Names;
    00065 };
    00066 //-----------------------------------------------------------------------------
    00067 inline std::ostream& operator<<(std::ostream& _os, const GroupDict &_val)
    00068 {
    00069   size_t size = _val.Size();
    00070   for(size_t i=0; i<size; ++i)
    00071     {
    00072     _os << std::hex << std::setw(4) << std::setfill( '0' ) << i << ","
    00073       << _val.GetAbbreviation(i) << "," << _val.GetName(i) << "\n";
    00074     }
    00075   return _os;
    00076 }
    00077
    00078 } // end namespace gdcm
    00079
    00080 #endif //GDCMGROUPDICT_H