OTB  9.0.0
Orfeo Toolbox
otbVectorDataIOBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbVectorDataIOBase_h
22 #define otbVectorDataIOBase_h
23 
24 #include <string>
25 
26 #include "itkLightProcessObject.h"
27 #include "itkIndent.h"
28 #include "itkPoint.h"
29 #include "itkDataObject.h"
30 
31 #include "OTBVectorDataBaseExport.h"
32 
33 namespace otb
34 {
35 
60 class OTBVectorDataBase_EXPORT VectorDataIOBase : public itk::LightProcessObject
61 {
62 public:
65  typedef itk::LightProcessObject Superclass;
66  typedef itk::SmartPointer<Self> Pointer;
67 
69  itkTypeMacro(VectorDataIOBase, Superclass);
70 
71  itkStaticConstMacro(VDimension, unsigned int, 3);
72  typedef itk::Vector<double, VDimension> SpacingType;
73  typedef itk::Point<double, VDimension> PointType;
74 
76  itkSetStringMacro(FileName);
77  itkGetStringMacro(FileName);
79 
82  typedef enum { BigEndian, LittleEndian, OrderNotApplicable } ByteOrder;
83 
95  itkSetEnumMacro(ByteOrder, ByteOrder);
96  itkGetEnumMacro(ByteOrder, ByteOrder);
98  {
99  this->SetByteOrder(BigEndian);
100  }
102  {
103  this->SetByteOrder(LittleEndian);
104  }
106 
109  std::string GetByteOrderAsString(ByteOrder) const;
110 
112  typedef std::streamoff SizeType;
113 
114  /*-------- This part of the interfaces deals with reading data ----- */
115 
118  virtual bool CanReadFile(const char*) const = 0;
119 
122  virtual bool CanStreamRead() const
123  {
124  return false;
125  }
126 
127  /* /\** Read the spacing and dimensions of the VectorData. */
128  /* * Assumes SetFileName has been called with a valid file name. *\/ */
129  /* virtual void ReadVectorDataInformation() = 0; */
130 
132  virtual void Read(itk::DataObject* data) = 0;
133 
134  /*-------- This part of the interfaces deals with writing data ----- */
135 
138  virtual bool CanWriteFile(const char*) const = 0;
139 
142  virtual bool CanStreamWrite() const
143  {
144  return false;
145  }
146 
147  /* /\** Writes the spacing and dimensions of the VectorData. */
148  /* * Assumes SetFileName has been called with a valid file name. *\/ */
149  /* virtual void WriteVectorDataInformation() = 0; */
150 
154  virtual void Write(const itk::DataObject* data, char** papszOptions = nullptr) = 0;
155 
156 protected:
158  ~VectorDataIOBase() override;
159 
160  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
161 
164 
167 
169  std::string m_FileName;
170 
172  virtual void Reset(const bool freeDynamic = true);
173 
174 private:
175  VectorDataIOBase(const Self&) = delete;
176  void operator=(const Self&) = delete;
177 };
178 
179 } // end namespace otb
180 
181 #endif // otbVectorDataIOBase_h
otb::VectorDataIOBase::SpacingType
itk::Vector< double, VDimension > SpacingType
Definition: otbVectorDataIOBase.h:72
otb::Wrapper::XML::Write
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
otb::VectorDataIOBase::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataIOBase.h:66
otb::VectorDataIOBase::m_FileName
std::string m_FileName
Definition: otbVectorDataIOBase.h:169
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VectorDataIOBase::SetByteOrderToBigEndian
void SetByteOrderToBigEndian()
Definition: otbVectorDataIOBase.h:97
otb::VectorDataIOBase::Self
VectorDataIOBase Self
Definition: otbVectorDataIOBase.h:64
otb::VectorDataIOBase::CanStreamWrite
virtual bool CanStreamWrite() const
Definition: otbVectorDataIOBase.h:142
otb::VectorDataIOBase::ByteOrder
ByteOrder
Definition: otbVectorDataIOBase.h:82
otb::VectorDataIOBase::SizeType
std::streamoff SizeType
Definition: otbVectorDataIOBase.h:112
otb::Wrapper::XML::Read
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
otb::VectorDataIOBase::SetByteOrderToLittleEndian
void SetByteOrderToLittleEndian()
Definition: otbVectorDataIOBase.h:101
otb::VectorDataIOBase::CanStreamRead
virtual bool CanStreamRead() const
Definition: otbVectorDataIOBase.h:122
otb::VectorDataIOBase::m_ByteOrder
ByteOrder m_ByteOrder
Definition: otbVectorDataIOBase.h:163
otb::VectorDataIOBase::Superclass
itk::LightProcessObject Superclass
Definition: otbVectorDataIOBase.h:65
otb::VectorDataIOBase::m_Initialized
bool m_Initialized
Definition: otbVectorDataIOBase.h:166
otb::VectorDataIOBase
Abstract superclass defines VectorData IO interface.
Definition: otbVectorDataIOBase.h:60
otb::VectorDataIOBase::PointType
itk::Point< double, VDimension > PointType
Definition: otbVectorDataIOBase.h:73