GDCM 2.2.0

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

- File List
- File Members

gdcmPrivateTag.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 GDCMPRIVATETAG_H
    00015 #define GDCMPRIVATETAG_H
    00016
    00017 #include "gdcmTag.h"
    00018 #include "gdcmSystem.h" // FIXME
    00019
    00020 #include <iostream>
    00021 #include <iomanip>
    00022 #include <string>
    00023 #include <algorithm>
    00024
    00025 #include <string.h> // strlen
    00026 #include <ctype.h> // tolower
    00027
    00028 namespace gdcm
    00029 {
    00030
    00036 class GDCM_EXPORT PrivateTag : public Tag
    00037 {
    00038   friend std::ostream& operator<<(std::ostream &_os, const PrivateTag &_val);
    00039 public:
    00040   PrivateTag(uint16_t group = 0, uint16_t element = 0, const char *owner = ""):Tag(group,element),Owner(owner) {
    00041     std::transform(Owner.begin(), Owner.end(), Owner.begin(), ::tolower);
    00042     // truncate the high bits
    00043     SetElement( (uint8_t)element );
    00044
    00045     // TODO:
    00046     // by default the cstor create with 0x0,0x0 which is invalid...
    00047     //assert( GetElement() >= 0x0010 && GetElement() < 0x100 );
    00048   }
    00049
    00050   const char *GetOwner() const { return Owner.c_str(); }
    00051   void SetOwner(const char *owner) { Owner = owner; }
    00052
    00053   bool operator<(const PrivateTag &_val) const
    00054     {
    00055     const Tag & t1 = *this;
    00056     const Tag & t2 = _val;
    00057     if( t1 == t2 )
    00058       {
    00059       const char *s1 = Owner.c_str();
    00060       const char *s2 = _val.GetOwner();
    00061       assert( s1[strlen(s1)-1] != ' ' );
    00062       assert( s2[strlen(s2)-1] != ' ' );
    00063       bool res = strcmp(s1, s2) < 0;
    00064 #ifndef NDEBUG
    00065       if( *s1 && *s2 && gdcm::System::StrCaseCmp(s1,s2) == 0 && strcmp(s1,s2) != 0 )
    00066         {
    00067         // FIXME:
    00068         // Typically this should only happen with the "Philips MR Imaging DD 001" vs "PHILIPS MR IMAGING DD 001"
    00069         // or "Philips Imaging DD 001" vr "PHILIPS IMAGING DD 001"
    00070         //assert( strcmp(Owner.c_str(), _val.GetOwner()) == 0 );
    00071         //return true;
    00072         res = gdcm::System::StrCaseCmp(s1,s2) < 0;
    00073 assert(0);
    00074         }
    00075 #endif
    00076       return res;
    00077       }
    00078     else return t1 < t2;
    00079     }
    00080
    00081   bool ReadFromCommaSeparatedString(const char *str);
    00082
    00083 private:
    00084   // SIEMENS MED, GEMS_PETD_01 ...
    00085   std::string Owner;
    00086 };
    00087
    00088 inline std::ostream& operator<<(std::ostream &os, const PrivateTag &val)
    00089 {
    00090   //assert( !val.Owner.empty() );
    00091   os.setf( std::ios::right );
    00092   os << std::hex << '(' << std::setw( 4 ) << std::setfill( '0' )
    00093     << val[0] << ',' << std::setw( 2 ) << std::setfill( '0' )
    00094     << val[1] << ',';
    00095   os << val.Owner;
    00096   os << ')' << std::setfill( ' ' ) << std::dec;
    00097   return os;
    00098 }
    00099
    00100 } // end namespace gdcm
    00101
    00102 #endif //GDCMPRIVATETAG_H