File: gdcmFileStreamer.h

package info (click to toggle)
gdcm 2.4.4-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 32,912 kB
  • ctags: 52,166
  • sloc: cpp: 188,527; ansic: 124,526; xml: 41,799; sh: 7,162; python: 3,667; cs: 2,128; java: 1,344; lex: 1,290; tcl: 677; php: 128; makefile: 116
file content (103 lines) | stat: -rw-r--r-- 4,124 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#ifndef GDCMFILESTREAMER_H
#define GDCMFILESTREAMER_H

#include "gdcmSubject.h"
#include "gdcmSmartPointer.h"

namespace gdcm
{
class FileStreamerInternals;

class Tag;
class PrivateTag;
/**
 * \brief FileStreamer
 * This class let a user create a massive DICOM DataSet from a template DICOM
 * file, by appending chunks of data.
 *
 * This class support two mode of operation:
 * 1. Creating a single DataElement by appending chunk after chunk of data.
 *
 * 2. Creating a set of DataElement within the same group, using a private
 * creator for start. New DataElement are added any time the user defined
 * maximum size for data element is reached.
 *
 * \warning any existing DataElement is removed, pick carefully which
 * DataElement to add.
 */
class GDCM_EXPORT FileStreamer : public Subject
{
public:
  FileStreamer();
  ~FileStreamer();

  /// Set input DICOM template filename
  void SetTemplateFileName(const char *filename_native);

  // Decide to check template or not (default: false)
  /// Instead of simply blindly copying the input DICOM Template file, GDCM will
  /// be used to check the input file, and correct any issues recognized within
  /// the file. Only use if you do not have control over the input template
  /// file.
  void CheckTemplateFileName(bool check);

  /// Set output filename (target file)
  void SetOutputFileName(const char *filename_native);

  /// Decide to check the Data Element to be written (default: off)
  /// The implementation has default strategy for checking validity of DataElement.
  /// Currently it only support checking for the following tags:
  /// - (7fe0,0010) Pixel Data
  bool CheckDataElement( const Tag & t );

  /// Start Single Data Element Operation
  /// This will delete any existing Tag t. Need to call it only once.
  bool StartDataElement( const Tag & t );
  /// Append to previously started Tag t
  bool AppendToDataElement( const Tag & t, const char *array, size_t len );
  /// Stop appending to tag t. This will compute the proper attribute length.
  bool StopDataElement( const Tag & t );
  /// Add a hint on the final size of the dataelement. When optimally chosen,
  /// this reduce the number of file in-place copying. Should be called before
  /// StartDataElement
  bool ReserveDataElement( size_t len );

  /// Start Private Group (multiple DataElement) Operation. Each newly added
  /// DataElement will have a length lower than \param maxsizede .
  /// When not specified, maxsizede is set to maximum size allowed by DICOM (= 2^32).
  /// startoffset can be used to specify the very first element you want to
  /// start with (instead of the first possible). Value should be in [0x0, 0xff]
  /// This will find the first available private creator.
  bool StartGroupDataElement( const PrivateTag & pt, size_t maxsizede = 0, uint8_t startoffset = 0 );
  /// Append to previously started private creator
  bool AppendToGroupDataElement( const PrivateTag & pt, const char *array, size_t len );
  /// Stop appending to private creator
  bool StopGroupDataElement( const PrivateTag & pt );
  /// Optimisation: pre-allocate the number of dataelement within the private
  /// group (ndataelement <= 256). Should be called before StartGroupDataElement
  bool ReserveGroupDataElement( unsigned short ndataelement );

  /// for wrapped language: instantiate a reference counted object
  static SmartPointer<FileStreamer> New() { return new FileStreamer; }

private:
  bool InitializeCopy();
  FileStreamerInternals *Internals;
};

} // end namespace gdcm

#endif //GDCMFILESTREAMER_H