Commit 15917614 authored by Antoine Regimbeau's avatar Antoine Regimbeau

REFAC: change export and change design

parent 964aa044
......@@ -29,8 +29,9 @@ namespace otb
/** \class OGRExtendedFilenameToOptions
*/
#include "OTBGdalAdaptersExport.h"
class ITK_EXPORT OGRExtendedFilenameToOptions : public ExtendedFilenameHelper
class OTBGdalAdapters_EXPORT OGRExtendedFilenameToOptions : public ExtendedFilenameHelper
{
public:
/** Standard class typedefs. */
......@@ -41,23 +42,21 @@ public:
typedef Superclass::OptionMapType OptionMapType;
typedef OptionMapType::iterator MapIteratorType;
typedef std::vector<std::string> GDALOptionType;
itkTypeMacro(OGRExtendedFilenameToOptions, otb::ExtendedFilenameHelper);
itkNewMacro(Self);
typedef std::vector<std::string> GDALOptionType;
/** The creation option structure. */
struct OpenOptionType
{
std::pair< bool, std::string > simpleFileName;
GDALOptionType gdalOptions;
// std::unordered_map< std::string , bool > availableOptions;
};
struct CreationOptionType
{
std::pair< bool, std::string > simpleFileName;
GDALOptionType gdalOptions;
// std::unordered_map< std::string , bool > availableOptions;
};
......@@ -76,6 +75,9 @@ public:
GDALOptionType GetGDALCreationOptions() const ;
GDALOptionType GetGDALLayerOptions() const ;
bool SimpleFileNameIsSet() const;
bool HasGDALLayerOption() const;
void SetGDALLayerOptions( const GDALOptionType & options );
void AddGDALLayerOptions( const GDALOptionType & options );
......@@ -93,6 +95,7 @@ private:
OpenOptionType m_OpenOptions;
CreationOptionType m_CreationOptions;
LayerOptionType m_LayerOptions;
bool m_HasFileName;
};
} //end namespace otb
......
......@@ -26,19 +26,15 @@ namespace otb
{
OGRExtendedFilenameToOptions::
OGRExtendedFilenameToOptions()
OGRExtendedFilenameToOptions():
m_HasFileName(false)
{
m_OpenOptions.simpleFileName.first = false;
m_OpenOptions.simpleFileName.second = "";
m_CreationOptions.simpleFileName.first = false;
m_CreationOptions.simpleFileName.second = "";
}
OGRExtendedFilenameToOptions::
OGRExtendedFilenameToOptions( const GDALOptionType & options ):
m_LayerOptions()
m_LayerOptions(),
m_HasFileName(false)
{
this->SetGDALLayerOptions( options );
}
......@@ -58,13 +54,9 @@ OGRExtendedFilenameToOptions::
SetExtendedFileName(const char *extFname)
{
Superclass::SetExtendedFileName(extFname);
OptionMapType map = GetOptionMap();
m_HasFileName = true;
m_OpenOptions.simpleFileName.first = true;
m_OpenOptions.simpleFileName.second = this->GetSimpleFileName();
m_CreationOptions.simpleFileName.first = true;
m_CreationOptions.simpleFileName.second = this->GetSimpleFileName();
OptionMapType map = GetOptionMap();
MapIteratorType it;
for ( it=map.begin(); it != map.end(); it++ )
......@@ -113,19 +105,6 @@ GetGDALOptions( const std::string & type ) const
}
}
OGRExtendedFilenameToOptions::
GDALOptionType
OGRExtendedFilenameToOptions::
GetGDALLayerOptions() const
{
GDALOptionType options;
for (const auto & option : m_LayerOptions.gdalOptions )
{
options.push_back( option.first + "=" + option.second );
}
return options;
}
void
OGRExtendedFilenameToOptions::
SetGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options )
......@@ -144,9 +123,9 @@ void
OGRExtendedFilenameToOptions::
AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options )
{
std::vector<std::string> tmp;
for ( const auto & option : options )
{
std::vector<std::string> tmp;
boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on);
if ( tmp.size()<2 )
boost::split(tmp, option , boost::is_any_of("="), boost::token_compress_on);
......@@ -154,6 +133,35 @@ AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & option
}
}
bool
OGRExtendedFilenameToOptions::
SimpleFileNameIsSet() const
{
return m_HasFileName;
}
bool
OGRExtendedFilenameToOptions::
HasGDALLayerOption() const
{
if ( m_LayerOptions.gdalOptions.empty() )
return false;
return true;
}
OGRExtendedFilenameToOptions::
GDALOptionType
OGRExtendedFilenameToOptions::
GetGDALLayerOptions() const
{
GDALOptionType options;
for (const auto & option : m_LayerOptions.gdalOptions )
{
options.push_back( option.first + "=" + option.second );
}
return options;
}
#define GetGDALOptionMacro( Type ) \
OGRExtendedFilenameToOptions:: \
GDALOptionType \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment