VTK  9.7.1
vtkResourceStream.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkResourceStream_h
4 #define vtkResourceStream_h
5 
6 #include "vtkIOCoreModule.h" // For export macro
7 #include "vtkObject.h"
8 #include "vtkSmartPointer.h" // For vtkSmartPointer
9 
10 #include <cstdlib> // for std::size_t
11 #include <memory> // for std::unique_ptr
12 #include <streambuf> // for std::basic_streambuf
13 
14 VTK_ABI_NAMESPACE_BEGIN
15 
32 class VTKIOCORE_EXPORT vtkResourceStream : public vtkObject
33 {
34  struct vtkInternals;
35 
36 public:
37  enum class SeekDirection
38  {
39  Begin = 0,
40  Current = 1,
41  End = 2
42  };
43 
44  vtkTypeMacro(vtkResourceStream, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
58  virtual std::size_t Read(void* buffer, std::size_t bytes) = 0;
59 
71  virtual bool EndOfStream() = 0;
72 
83  virtual vtkTypeInt64 Seek(vtkTypeInt64 pos, SeekDirection dir);
84 
94  virtual vtkTypeInt64 Tell();
95 
101  bool SupportSeek() const;
102 
103 #ifndef __VTK_WRAP__
104 
110  std::unique_ptr<std::streambuf> ToStreambuf();
111 #endif
112 
113 protected:
122  vtkResourceStream(bool supportSeek);
123  ~vtkResourceStream() override;
124  vtkResourceStream(const vtkResourceStream&) = delete;
125  vtkResourceStream& operator=(const vtkResourceStream&) = delete;
126 
127 private:
128  std::unique_ptr<vtkInternals> Impl;
129 };
130 
131 VTK_ABI_NAMESPACE_END
132 
133 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Abstract class used for custom streams.
a simple class to control print indentation
Definition: vtkIndent.h:28