File: vtkXMLDataWriterHelper.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 544,220 kB
  • sloc: cpp: 3,374,605; ansic: 1,332,409; python: 150,381; xml: 122,166; sql: 65,887; sh: 7,317; javascript: 5,262; yacc: 4,417; java: 3,977; perl: 2,363; lex: 1,929; f90: 1,397; makefile: 170; objc: 153; tcl: 59; pascal: 50; fortran: 29
file content (100 lines) | stat: -rw-r--r-- 3,172 bytes parent folder | download | duplicates (3)
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
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class vtkXMLDataWriterHelper
 * @brief helper for vtkXMLWriter2 and subclasses
 *
 * vtkXMLDataWriterHelper is intended to be a helper class used by vtkXMLWriter2
 * and subclasses to use to write the XML to a file. Currently, this is simply a
 * subclass of vtkXMLWriter with some minimal API exposed. The ultimate goal is
 * to move logic to write XML data to this class and remove the reliance on
 * vtkXMLWriter. To get things off the ground quickly, this is kept as a
 * subclass of vtkXMLWriter for now.
 */

#ifndef vtkXMLDataWriterHelper_h
#define vtkXMLDataWriterHelper_h

#include "vtkIOParallelXMLModule.h" // For export macro
#include "vtkXMLWriter.h"

VTK_ABI_NAMESPACE_BEGIN
class vtkCompositeDataSet;
class vtkXMLDataElement;
class vtkXMLWriter2;

class VTKIOPARALLELXML_EXPORT vtkXMLDataWriterHelper : public vtkXMLWriter
{
public:
  static vtkXMLDataWriterHelper* New();
  vtkTypeMacro(vtkXMLDataWriterHelper, vtkXMLWriter);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  ///@{
  /**
   * Get/Set the writer using this helper. Attributes from the writer are used
   * to control how data is written out.
   */
  void SetWriter(vtkXMLWriter2*);
  vtkGetObjectMacro(Writer, vtkXMLWriter2);
  ///@}

  ///@{
  /**
   * The writing process is split into 4 parts:
   * 1. `OpenFile` opens the file for writing.
   * 2. `BeginWriting` begins writing by adding header.
   * 3. Write the contents. API calls like `AddGlobalFieldData`, `AddXML` can be used for this.
   * 4. `EndWriting` ends the writing, adding any footers as needed.
   */
  bool OpenFile();
  bool BeginWriting();
  bool EndWriting();
  ///@}

  /**
   * Adds global field data for composite dataset.
   */
  bool AddGlobalFieldData(vtkCompositeDataSet* dataset);

  /**
   * Serialize and add an XML dom described by the `xmlElement` to the file.
   */
  bool AddXML(vtkXMLDataElement* xmlElement);

  ///@{
  /**
   * These methods should be used by the caller to provide necessary information
   * to the helper to generate a valid header. This is currently necessary since
   * we are making this class reused parts of vtkXMLWriter. When than dependence
   * is severed, this API will likely change.
   */
  void SetDataSetName(const std::string& name) { this->DataSetName = name; }
  void SetDataSetVersion(int major, int minor)
  {
    this->DataSetVersion[0] = major;
    this->DataSetVersion[1] = minor;
  }
  ///@}

  const char* GetDefaultFileExtension() override { return nullptr; }

protected:
  vtkXMLDataWriterHelper();
  ~vtkXMLDataWriterHelper() override;

  const char* GetDataSetName() override { return this->DataSetName.c_str(); }
  int GetDataSetMajorVersion() override { return this->DataSetVersion[0]; }
  int GetDataSetMinorVersion() override { return this->DataSetVersion[1]; }

private:
  vtkXMLDataWriterHelper(const vtkXMLDataWriterHelper&) = delete;
  void operator=(const vtkXMLDataWriterHelper&) = delete;

  vtkXMLWriter2* Writer;
  std::string DataSetName;
  int DataSetVersion[2];
};

VTK_ABI_NAMESPACE_END
#endif