Skip to content
Snippets Groups Projects
Commit 5ebcfac5 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

ENH: move implementation of non virtual methods to a source file to add them...

ENH: move implementation of non virtual methods to a source file to add them in the shared library in MetadataStorageInterface and MetadataSupplierInterface
parent 595bf621
No related branches found
No related tags found
No related merge requests found
......@@ -22,13 +22,14 @@
#define otbMetadataStorageInterface_h
#include "OTBMetadataExport.h"
#include "itkExceptionObject.h"
#include "itkMacro.h"
#include <vector>
#include <string>
#include <sstream>
#include "otbStringUtils.h"
#include "otbMacro.h"
#include "otbStringUtilities.h"
#include "otbJoinContainer.h"
namespace otb
{
......@@ -48,17 +49,9 @@ public:
virtual void SetMetadataValue(const char * path, const char * value, int band=-1) = 0;
// TODO : check precision settings
void SetAs(const std::string & path, double value, int band=-1)
{
std::ostringstream oss;
oss << value;
SetMetadataValue(path.c_str(), oss.str().c_str(), band);
}
void SetAs(const std::string & path, double value, int band=-1);
void SetAs(const std::string & path, const std::string & value, int band=-1)
{
SetMetadataValue(path.c_str(), value.c_str(), band);
}
void SetAs(const std::string & path, const std::string & value, int band=-1);
/** Parse a std::vector to a metadata value */
template < typename T> void SetAsVector(const char *path, std::vector<T> value, const char sep=' ', int band=-1)
......
......@@ -77,12 +77,8 @@ public:
* If band >= 0, the metadata value is looked in the specified band*/
virtual const char * GetMetadataValue(const char * path, int band=-1) const = 0;
bool HasValue(const char * path, int band=-1)
{
const char * ret = GetMetadataValue(path, band);
return ret;
}
bool HasValue(const char * path, int band=-1);
// utility functions
template <typename T> T GetAs(const char *path, int band=-1) const
{
......
......@@ -71,6 +71,9 @@ set(OTBMetadata_SRC
otbImageMetadata.cxx
otbGeometryMetadata.cxx
otbMetadataStorageInterface.cxx
otbMetadataSupplierInterface.cxx
)
add_library(OTBMetadata ${OTBMetadata_SRC})
......
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbMetadataStorageInterface.h"
namespace otb
{
void MetadataStorageInterface::SetAs(const std::string & path, double value, int band)
{
std::ostringstream oss;
oss << value;
SetMetadataValue(path.c_str(), oss.str().c_str(), band);
}
void MetadataStorageInterface::SetAs(const std::string & path, const std::string & value, int band)
{
SetMetadataValue(path.c_str(), value.c_str(), band);
}
}
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbMetadataSupplierInterface.h"
namespace otb
{
bool MetadataSupplierInterface::HasValue(const char * path, int band)
{
const char * ret = GetMetadataValue(path, band);
return ret;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment