]> Creatis software - gdcm.git/blob - src/gdcmVR.h
* Some classes inherit now from gdcm::RefCounter
[gdcm.git] / src / gdcmVR.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmVR.h,v $
5   Language:  C++
6   Date:      $Date: 2005/10/25 14:52:35 $
7   Version:   $Revision: 1.25 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef GDCMVR_H
20 #define GDCMVR_H
21
22 #include "gdcmRefCounter.h"
23 #include "gdcmVRKey.h"
24
25 #include <map>
26 #include <string>
27 #include <iostream>
28
29 namespace gdcm 
30 {
31
32 //-----------------------------------------------------------------------------
33 typedef std::string VRAtr;
34 /// Value Representation Hash Table
35 typedef std::map<VRKey, VRAtr> VRHT;
36
37 //-----------------------------------------------------------------------------
38 /**
39  * \brief Container for dicom Value Representation Hash Table
40  * \note   This is a singleton
41  */
42 class GDCM_EXPORT VR : public RefCounter
43 {
44    gdcmTypeMacro(VR);
45
46 public:
47    static VR *New() {return new VR();}
48
49    void Print(std::ostream &os = std::cout);
50
51    /// \brief   Get the count for an element
52    int Count(VRKey const &key) { return vr.count(key); };
53
54    bool IsVROfBinaryRepresentable(VRKey const &tested);
55    bool IsVROfStringRepresentable(VRKey const &tested);
56
57    /// \brief   Simple predicate that checks whether the given argument
58    ///          corresponds to the Value Representation of a \ref SeqEntry
59    bool IsVROfSequence(VRKey const &tested) { return tested == "SQ"; }
60
61 // Remove inline optimization for VS6
62 #if defined(_MSC_VER) && (_MSC_VER == 1200)
63    bool IsValidVR(VRKey const &key);
64 #else
65 /// \brief checks is a supposed-to-be VR is a 'legal' one.
66    bool IsValidVR(VRKey const &key) { return vr.find(key) != vr.end(); }
67 #endif
68
69    unsigned short GetAtomicElementLength(VRKey const &tested);
70
71 protected:
72    VR();
73    ~VR();
74
75 private:
76    VRHT vr;
77 };
78 } // end namespace gdcm
79
80 //-----------------------------------------------------------------------------
81 #endif