OTB  6.7.0
Orfeo Toolbox
otbVectorDataFileWriter.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 otbVectorDataFileWriter_h
22 #define otbVectorDataFileWriter_h
23 
24 #include "itkProcessObject.h"
25 #include "itkMacro.h"
26 #include "otbVectorDataIOBase.h"
27 #include <string>
28 
29 namespace otb
30 {
38 {
39 public:
42 
44  VectorDataFileWriterException(const char *file, unsigned int line,
45  const char* message = "Error in IO",
46  const char* loc = "Unknown") :
47  ExceptionObject(file, line, message, loc)
48  {
49  }
50 
52  VectorDataFileWriterException(const std::string& file, unsigned int line,
53  const char* message = "Error in IO",
54  const char* loc = "Unknown") :
55  ExceptionObject(file, line, message, loc)
56  {
57  }
58 };
60 
69 template <class TInputVectorData>
70 class ITK_EXPORT VectorDataFileWriter : public itk::ProcessObject
71 {
72 public:
73 
79 
81  itkNewMacro(Self);
82 
85 
86  typedef TInputVectorData InputVectorDataType;
88 
90  using Superclass::SetInput;
91  void SetInput(const InputVectorDataType *input);
92  const InputVectorDataType * GetInput(void);
93  const InputVectorDataType * GetInput(unsigned int idx);
95 
97  virtual void Write();
98 
99  void GenerateData() override;
100 
101  void Update() override
102  {
103  this->Write();
104  }
105 
107  itkSetStringMacro(FileName);
108  itkGetStringMacro(FileName);
110 
111 protected:
113  ~VectorDataFileWriter() override;
114 
115  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
116 
117  std::string m_FileName; // The file to be read
119  bool m_UserSpecifiedVectorDataIO; // track whether the VectorDataIO
121 
122 private:
123  VectorDataFileWriter(const Self &) = delete;
124  void operator =(const Self&) = delete;
125 
126 };
127 
128 } // end namespace otb
129 
130 #ifndef OTB_MANUAL_INSTANTIATION
132 #endif
133 
134 #endif // otbVectorDataFileWriter_h
VectorDataIOBaseType::Pointer m_VectorDataIO
VectorDataFileWriterException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
itk::SmartPointer< Self > Pointer
VectorDataFileWriterException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Abstract superclass defines VectorData IO interface.
itk::SmartPointer< const Self > ConstPointer
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:58
This class writes vector data file format (shapefile and KML)