VTK  9.3.20240418
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 
9 #include <cstdlib> // for std::size_t
10 #include <memory> // for std::unique_ptr
11 
12 VTK_ABI_NAMESPACE_BEGIN
13 
30 class VTKIOCORE_EXPORT vtkResourceStream : public vtkObject
31 {
32  struct vtkInternals;
33 
34 public:
35  enum class SeekDirection
36  {
37  Begin = 0,
38  Current = 1,
39  End = 2
40  };
41 
42  vtkTypeMacro(vtkResourceStream, vtkObject);
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
56  virtual std::size_t Read(void* buffer, std::size_t bytes) = 0;
57 
69  virtual bool EndOfStream() = 0;
70 
81  virtual vtkTypeInt64 Seek(vtkTypeInt64 pos, SeekDirection dir);
82 
92  virtual vtkTypeInt64 Tell();
93 
99  bool SupportSeek() const;
100 
101 protected:
110  vtkResourceStream(bool supportSeek);
111  ~vtkResourceStream() override;
114 
115 private:
116  std::unique_ptr<vtkInternals> Impl;
117 };
118 
119 VTK_ABI_NAMESPACE_END
120 
121 #endif
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
Abstract class used for custom streams.
vtkResourceStream(bool supportSeek)
Constructor.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool EndOfStream()=0
Check if the stream reached an end.
virtual vtkTypeInt64 Tell()
Get the stream cursor position.
bool SupportSeek() const
Check if stream supports Seek and Tell functions.
virtual vtkTypeInt64 Seek(vtkTypeInt64 pos, SeekDirection dir)
Move the stream cursor position.
vtkResourceStream(const vtkResourceStream &)=delete
vtkResourceStream & operator=(const vtkResourceStream &)=delete
~vtkResourceStream() override
virtual std::size_t Read(void *buffer, std::size_t bytes)=0
Read data form the stream.
@ dir
Definition: vtkX3D.h:324