MeVisLab Toolbox Reference
DCMTree_Value.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 // Values are stored binary internaly, i.e.,
14 // there is no implicit conversion taking place.
15 // Data is converted if desired by DCMTree::Tag
16 
17 #ifndef DCM_TREE_VALUE_H
18 #define DCM_TREE_VALUE_H
19 
20 #ifdef _MSC_VER
21  #pragma warning (push)
22  #pragma warning (disable : 4350)
23 #endif
24 
25 #include <vector>
26 
27 #include <istream>
28 #include <ostream>
29 
30 #include <boost/shared_array.hpp>
31 
32 #ifdef _MSC_VER
33  #pragma warning (pop)
34 #endif
35 
36 
37 #include "DCMTree_Lib.h"
38 #include "DCMTree_Defines.h"
39 
40 
41 namespace DCMTree
42 {
45  {
46  public:
48  {
49  SDM_makeCopy, // Copy the data into the value
50  SDM_takeOwnership // The value takes the ownership of the data
51  };
52 
53  public:
55  Value();
56 
60  Value (const unsigned int &size);
61 
67  Value (const unsigned int &size,const unsigned char *data);
68 
73  Value (const Value &other);
74 
75  Value(Value &&) noexcept = default;
76  Value& operator =(Value &&other) noexcept = default;
77 
79  ~Value() override;
80 
85  Value &operator =(const Value &other);
86 
90  bool operator ==(const Value &other) const;
91 
95  bool operator !=(const Value &other) const;
96 
100  void purge();
101 
105  unsigned int size() const;
106 
110  const unsigned char *data() const;
111 
115  unsigned char *data();
116 
120  boost::shared_array<unsigned char> sharedData() const;
121 
125  void setSize (const unsigned int &size);
126 
131  void setData (const unsigned int &size,const unsigned char *data);
132 
139  void setData (const unsigned int &size, unsigned char *data,
140  SetDataMode setDataMode = SDM_makeCopy);
141 
145  void setData (const std::string &value);
146 
150  bool isNull() const;
151 
155  void fromStream (std::istream &in);
156 
160  void toStream (std::ostream &out) const;
161 
162  void serializeX (DCMTree_Serialization::Sink &sink) const override;
163  void deserializeX (DCMTree_Serialization::Source &source) override;
164 
165  private:
169  void allocate (const unsigned int &size);
170 
171  boost::shared_array<unsigned char> _data;
172  unsigned int _size;
173  unsigned int _buffersize;
174  };
175 
176  typedef std::vector<Value> ValueVector;
177 
178  inline std::ostream &operator << (std::ostream &out,const Value &v)
179  {
180  v.toStream (out);
181  return out;
182  }
183 
184  inline std::istream &operator >> (std::istream &in,Value &v)
185  {
186  v.fromStream (in);
187  return in;
188  }
189 }
190 
191 #endif
192 
193 
#define DCMTREE_EXPORT
Class to store tag values.
Definition: DCMTree_Value.h:45
Value()
Constructor.
Value(const Value &other)
Makes a deep copy of other to this.
Value(Value &&) noexcept=default
void toStream(std::ostream &out) const
Copies this instance recursively into the given stream.
Value(const unsigned int &size)
Creates a value with the given size in bytes.
Value(const unsigned int &size, const unsigned char *data)
Creates a value with the given size in bytes and memcpy data to it.
void fromStream(std::istream &in)
Extracts this instance from the given stream.
Interface that provides a method to deserialize an object.
Interface that provides a method to serialize an object.
void serializeX(Sink &sink, const DCMTree::TransferSyntax &syntax)
void deserializeX(Source &source, DCMTree::TransferSyntax &syntax)
DCMTREE_EXPORT void fromStream(std::istream &in, std::string &val, size_t maxSize=0)
Helper functions to read data out of a stream.
DCMTREE_EXPORT void toStream(std::ostream &out, const std::string &val)
Helper functions to write data into a stream.
Class to dump a DCMTree DICOM message into a human-readable file.
std::istream & operator>>(std::istream &in, Message &m)
std::vector< Value > ValueVector
Forward declaration for the boost::mutex class.
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.
boost::log::sinks::sink Sink