OTB  9.0.0
Orfeo Toolbox
otbMetadataSupplierInterface.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 otbMetadataSupplierInterface_h
22 #define otbMetadataSupplierInterface_h
23 
24 #include "OTBMetadataExport.h"
25 #include <vector>
26 #include <string>
27 #include "otbStringUtils.h"
28 #include "otbStringUtilities.h"
29 #include <boost/algorithm/string.hpp>
31 
32 namespace otb
33 {
40 class OTBMetadata_EXPORT MetadataSupplierInterface
41 {
42 public:
43  const std::array<std::string, 3> TRUES = {"1", "true", "True"};
44  const std::array<std::string, 3> FALSES = {"0", "false", "False"};
45  virtual std::string GetResourceFile(std::string const& ="") const = 0;
46  virtual std::vector<std::string> GetResourceFiles() const
47  {
48  return std::vector<std::string>{this->GetResourceFile()};
49  }
50 
51 
56  virtual std::string GetMetadataValue(std::string const& path, bool& hasValue, int band=-1) const = 0;
57 
58  bool HasValue(std::string const& path, int band=-1) const;
59 
60  virtual int GetNbBands() const = 0;
61 
62  template <typename T> T GetAs(T const& defaultValue, std::string const& path, int band=-1) const;
63 
64  template <typename T> T GetAs(std::string const& path, int band=-1) const;
65 
69  template < typename T> std::vector<T> GetAsVector(std::string const& path, char sep=' ', int size=-1, int band=-1) const;
70 
72  virtual unsigned int GetNumberOf(std::string const& path) const = 0;
73 
75  virtual unsigned int GetAttributId(std::string const& path, std::string const& value) const = 0;
76 
77  virtual ~MetadataSupplierInterface() = default;
78 };
79 
80 template <> bool MetadataSupplierInterface::GetAs(bool const& defaultValue, std::string const& path, int band) const;
81 // TODO : for complex types ...
82 
83 } // end namespace otb
84 
85 #ifndef OTB_MANUAL_INSTANTIATION
87 #endif
88 
89 #endif
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbStringUtilities.h
otb::MetadataSupplierInterface
Base class to access metadata information in files/images.
Definition: otbMetadataSupplierInterface.h:40
otb::MetadataSupplierInterface::GetResourceFiles
virtual std::vector< std::string > GetResourceFiles() const
Definition: otbMetadataSupplierInterface.h:46
otbMissingMetadataException.h
otbStringUtils.h
otb::MetadataSupplierInterface::GetAs
T GetAs(T const &defaultValue, std::string const &path, int band=-1) const
Definition: otbMetadataSupplierInterface.hxx:31
otbMetadataSupplierInterface.hxx