MeVisLab Toolbox Reference
DCMTree_TagId.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef DCM_TREE_TAG_ID_H
14#define DCM_TREE_TAG_ID_H
15
16#ifdef _MSC_VER
17 #pragma warning (push)
18 #pragma warning (disable : 4350)
19#endif
20
21#include <istream>
22#include <ostream>
23
24#include <string>
25
26#include "DCMTree_Lib.h"
28
29#ifdef _MSC_VER
30 #pragma warning (pop)
31#endif
32
33
34namespace DCMTree
35{
40 {
41 public:
44
46 TagId (RawTagId rawid);
47
49 TagId (const TagId &other);
50
52 TagId (unsigned short groupid,unsigned short elementid);
53
60 TagId (std::string tidstr);
61
63 ~TagId() override;
64
65 // Helpers
66 static TagIdPtr create(RawTagId rawid);
67 static TagIdPtr create(const TagId &other);
68 static TagIdPtr create(unsigned short groupid,unsigned short elementid);
69 static TagIdPtr create(std::string tidstr);
70
72 TagId &operator= (const TagId &other);
73
75 bool operator==(const TagId &other) const;
76
78 bool operator!=(const TagId &other) const;
79
81 bool operator>(const TagId &other) const;
82
84 bool operator<(const TagId &other) const;
85
87 bool operator>=(const TagId &other) const;
88
90 bool operator<=(const TagId &other) const;
91
93 operator RawTagId() const;
94
96 operator RawTagId&();
97
99 unsigned short groupId() const;
100
102 unsigned short elementId() const;
103
105 bool isPrivate() const;
106
108 bool isPrivateCreator() const;
109
114 RawTagId privateTag( unsigned short slot ) const;
115
118
121
123 std::string toString() const;
124
128 void fromStream (std::istream &in);
129
133 void toStream (std::ostream &out) const;
134
135 void serializeX (DCMTree_Serialization::Sink &sink) const override;
137
141 static inline bool isPrivateTag( RawTagId id );
142
143 private:
144 RawTagId _id;
145 };
146
148 {
149 return (id & 0x10000) != 0;
150 }
151
152 inline std::ostream &operator << (std::ostream &out,const TagId &t)
153 {
154 t.toStream (out);
155 return out;
156 }
157
158 inline std::istream &operator >> (std::istream &in,TagId &t)
159 {
160 t.fromStream (in);
161 return in;
162 }
163}
164
165#endif
166
#define DCMTREE_EXPORT
Class to wrap a tag ID.
RawTagId rawId() const
Returns the raw value .
std::string toString() const
Converts this to a string of the form (groupid, elementid).
static bool isPrivateTag(RawTagId id)
Returns true if the given tag ID belongs to a private tag.
TagId()
Constructor - sets the ID to (0000,0000)
bool operator>(const TagId &other) const
is-bigger-than operator
TagId(std::string tidstr)
Constructor that creates a new instance by conversion from the given string.
static TagIdPtr create(const TagId &other)
RawTagId & rawId()
Returns the raw value.
bool operator>=(const TagId &other) const
if-bigger-than-or-equal operator
bool operator<=(const TagId &other) const
if-smaller-than-or-equal operator
bool isPrivate() const
Checks whether this ID identifies a private tag (groupid is odd)
unsigned short elementId() const
Returns the lower word of the ID -> element-identifier.
TagId(unsigned short groupid, unsigned short elementid)
Constructor that creates a new instance with ID (groupid,elementid)
static TagIdPtr create(unsigned short groupid, unsigned short elementid)
unsigned short groupId() const
Returns the upper word of the ID -> group-identifier.
RawTagId privateTag(unsigned short slot) const
Returns the tag ID of the corresponding private tag with the given slot.
void deserializeX(DCMTree_Serialization::Source &source) override
Overwrites data of this object with data from source.
bool isPrivateCreator() const
Checks whether this ID identifies a private creator tag.
~TagId() override
Destructor.
void fromStream(std::istream &in)
Extracts this instance from the given stream.
TagId(const TagId &other)
Copy Constructor.
bool operator!=(const TagId &other) const
is-not-equal operator
void toStream(std::ostream &out) const
Copies this instance recursively into the given stream.
void serializeX(DCMTree_Serialization::Sink &sink) const override
Writes data of this object to sink.
TagId(RawTagId rawid)
Constructor - initialize to the given value.
static TagIdPtr create(RawTagId rawid)
bool operator<(const TagId &other) const
is-less-than operator
bool operator==(const TagId &other) const
is-equal operator
static TagIdPtr create(std::string tidstr)
Interface that provides a method to deserialize an object.
Interface that provides a method to serialize an object.
Interface of a data sink for the serialization of objects.
Interface of a data source for the deserialization of objects.
Class to dump a DCMTree DICOM message into a human-readable file.
std::ostream & operator<<(std::ostream &out, const Message &m)
boost::shared_ptr< TagId > TagIdPtr
std::istream & operator>>(std::istream &in, Message &m)
unsigned int RawTagId