OTB  6.7.0
Orfeo Toolbox
otbVectorDataIOBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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:
67 
69  itkTypeMacro(VectorDataIOBase, Superclass);
70 
71  itkStaticConstMacro(VDimension, unsigned int, 3);
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 
180 } // end namespace otb
181 
182 #endif // otbVectorDataIOBase_h
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
virtual bool CanStreamWrite() const
itk::SmartPointer< Self > Pointer
Abstract superclass defines VectorData IO interface.
itk::Vector< double, VDimension > SpacingType
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
virtual bool CanStreamRead() const
itk::Point< double, VDimension > PointType
itk::LightProcessObject Superclass