OTB  10.0.0
Orfeo Toolbox
otbWrapperInputImageParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbWrapperInputImageParameter_h
22 #define otbWrapperInputImageParameter_h
23 
24 
25 #include "otbImageFileReader.h"
26 #include "otbClampImageFilter.h"
27 #include "otbWrapperParameter.h"
28 
29 #include "itkImageBase.h"
30 
31 #include <string>
32 
33 namespace otb
34 {
35 namespace Wrapper
36 {
43 class OTBApplicationEngine_EXPORT InputImageParameter : public Parameter
44 {
45 public:
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
53  itkNewMacro(Self);
54 
57 
58  struct Connector
59  {
60  itk::Object::Pointer app;
61  std::string key;
62  bool isMem;
63  };
64 
66  bool SetFromFileName(std::string filename);
67  itkGetConstReferenceMacro(FileName, std::string);
69 
71  {
72  m_Connection = std::move(c);
73  }
74 
75  const Connector& GetConnection() const
76  {
77  return m_Connection;
78  }
79 
80  void SetConnectionMode(bool isMem)
81  {
82  m_Connection.isMem = isMem;
83  }
84 
86  ImageBaseType const* GetImage() const;
89 
99 
107 
110 
111  // Complex image
116 
121 
123  template <class TImageType>
124  TImageType* GetImage();
125 
127  void SetImage(ImageBaseType* image);
128 
129 
131  template <class TInputImage, class TOutputImage>
132  TOutputImage* CastImage();
133 
134  bool HasValue() const override;
135  void ClearValue() override;
136 
137  ParameterType GetType() const override;
138  std::string ToString() const override;
139  void FromString(const std::string& value) override;
140 
141 protected:
144 
146  ~InputImageParameter() override = default;
147 
148 private:
149  InputImageParameter(const Parameter&) = delete;
150  void operator=(const Parameter&) = delete;
151 
152  std::string m_FileName;
153  itk::ProcessObject::Pointer m_Reader = nullptr;
154 
155  ImageBaseType::Pointer m_Image = nullptr;
156 
157  itk::ProcessObject::Pointer m_OutputCaster = nullptr;
158  itk::DataObject::Pointer m_OutputCasted = nullptr;
159 
160 private:
162  template <typename TOutputImage, typename TInputImage>
163  TOutputImage* Cast(TInputImage*);
164 
166  std::string m_PreviousFileName;
167 
169  bool m_UseFilename = true;
170 
171  Connector m_Connection{};
172 
173 }; // End class InputImage Parameter
174 
175 } // End namespace Wrapper
176 } // End namespace otb
177 
178 #ifndef OTB_MANUAL_INSTANTIATION
180 #endif
181 
182 #endif
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:92
Creation of an "otb" vector image which contains metadata.
This class represents a InputImage parameter.
bool SetFromFileName(std::string filename)
itk::SmartPointer< const Self > ConstPointer
Int32VectorImageType * GetInt32VectorImage()
UInt16ImageType * GetUInt16Image()
UInt32ImageType * GetUInt32Image()
Int16VectorImageType * GetInt16VectorImage()
ComplexInt16ImageType * GetComplexInt16Image()
ComplexInt32ImageType * GetComplexInt32Image()
UInt8VectorImageType * GetUInt8VectorImage()
ComplexDoubleVectorImageType * GetComplexDoubleVectorImage()
ParameterType GetType() const override
ComplexInt16VectorImageType * GetComplexInt16VectorImage()
UInt16VectorImageType * GetUInt16VectorImage()
UInt8ImageType * GetUInt8Image()
UInt32VectorImageType * GetUInt32VectorImage()
UInt8RGBImageType * GetUInt8RGBImage()
ComplexInt32VectorImageType * GetComplexInt32VectorImage()
UInt8RGBAImageType * GetUInt8RGBAImage()
ComplexDoubleImageType * GetComplexDoubleImage()
void operator=(const Parameter &)=delete
FloatImageType * GetFloatImage()
FloatVectorImageType * GetFloatVectorImage()
DoubleImageType * GetDoubleImage()
~InputImageParameter() override=default
void SetImage(ImageBaseType *image)
ImageBaseType const * GetImage() const
void FromString(const std::string &value) override
Int32ImageType * GetInt32Image()
InputImageParameter(const Parameter &)=delete
ComplexFloatVectorImageType * GetComplexFloatVectorImage()
bool HasValue() const override
DoubleVectorImageType * GetDoubleVectorImage()
Int16ImageType * GetInt16Image()
ComplexFloatImageType * GetComplexFloatImage()
std::string ToString() const override
This class represent a parameter for the wrapper framework This class is a high level class represent...
itk::ImageBase< 2 > ImageBaseType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.