Commit 4c6275c8 authored by Victor Poughon's avatar Victor Poughon

Merge branch '1649-wrapper-application' into 'develop'

Refactor of otbWrapperApplication.h

See merge request !150
parents 258d3f59 07722648
......@@ -216,6 +216,8 @@ macro(otb_module_impl)
endif()
# Generate the export macro header for symbol visibility/Windows DLL declspec
# This header is called *Modulename*Export.h in the build directory,
# and contains defines for _EXPORT macros such as OTBApplicationEngine_EXPORT
generate_export_header(${otb-module}
EXPORT_FILE_NAME ${_export_header_file}
EXPORT_MACRO_NAME ${otb-module}_EXPORT
......
......@@ -377,6 +377,8 @@ macro(otb_module_impl)
endif()
# Generate the export macro header for symbol visibility/Windows DLL declspec
# This header is called *Modulename*Export.h in the build directory,
# and contains defines for _EXPORT macros such as OTBApplicationEngine_EXPORT
generate_export_header(${otb-module}
EXPORT_FILE_NAME ${_export_header_file}
EXPORT_MACRO_NAME ${otb-module}_EXPORT
......
......@@ -50,9 +50,236 @@
namespace otb
{
ApplicationException::ApplicationException(const char *file, unsigned int line,
const char* message, const char* loc) :
ExceptionObject(file, line, message, loc)
{
}
/** Constructor. */
ApplicationException::ApplicationException(const std::string &file, unsigned int line,
const char* message, const char* loc) :
ExceptionObject(file, line, message, loc)
{
}
namespace Wrapper
{
void Application::SetName( const std::string & name )
{
m_Name = name;
GetDocExample()->SetApplicationName(name);
this->Modified();
m_Logger->SetName(name);
}
const char* Application::GetName() const
{
return m_Name.c_str();
}
void Application::SetDescription(const std::string& description)
{
m_Description = description;
this->Modified();
}
const char* Application::GetDescription() const
{
return m_Description.c_str();
}
void Application::SetHaveInXML(bool haveInXML)
{
m_HaveInXML = haveInXML;
this->Modified();
}
bool Application::GetHaveInXML() const
{
return m_HaveInXML;
}
void Application::SetHaveOutXML(bool haveOutXML)
{
m_HaveOutXML = haveOutXML;
this->Modified();
}
bool Application::GetHaveOutXML() const
{
return m_HaveOutXML;
}
void Application::SetDocName(const std::string& value)
{
m_DocName = value;
this->Modified();
}
const char* Application::GetDocName() const
{
return m_DocName.c_str();
}
void Application::SetDocLongDescription(const std::string& value)
{
m_DocLongDescription = value;
this->Modified();
}
const char* Application::GetDocLongDescription() const
{
return m_DocLongDescription.c_str();
}
void Application::SetDocAuthors(const std::string& value)
{
m_DocAuthors = value;
this->Modified();
}
const char* Application::GetDocAuthors() const
{
return m_DocAuthors.c_str();
}
void Application::SetDocLimitations(const std::string& value)
{
m_DocLimitations = value;
this->Modified();
}
const char* Application::GetDocLimitations() const
{
return m_DocLimitations.c_str();
}
void Application::SetDocSeeAlso(const std::string& value)
{
m_DocSeeAlso = value;
this->Modified();
}
const char* Application::GetDocSeeAlso() const
{
return m_DocSeeAlso.c_str();
}
void Application::SetDocTags(std::vector<std::string> value)
{
m_DocTags = value;
this->Modified();
}
std::vector<std::string> Application::GetDocTags() const
{
return m_DocTags;
}
void Application::AddDocTag(const std::string & tag)
{
const auto wh = std::find(begin(m_DocTags), end(m_DocTags), tag);
if (wh == end(m_DocTags))
{
m_DocTags.push_back(tag);
this->Modified();
}
}
DocExampleStructure::Pointer Application::GetDocExample()
{
if (!IsInitialized())
{
Init();
}
return m_DocExample;
}
unsigned int Application::GetNumberOfExamples()
{
return GetDocExample()->GetNbOfExamples();
}
std::string Application::GetExampleComment(unsigned int id)
{
return GetDocExample()->GetExampleComment(id);
}
unsigned int Application::GetExampleNumberOfParameters(unsigned int id)
{
return GetDocExample()->GetNumberOfParameters(id);
}
std::string Application::GetExampleParameterKey(unsigned int exId, unsigned int paramId)
{
return GetDocExample()->GetParameterKey(paramId, exId);
}
std::string Application::GetExampleParameterValue(unsigned int exId, unsigned int paramId)
{
return GetDocExample()->GetParameterValue(paramId, exId);
}
void Application::SetDocExampleParameterValue(const std::string key, const std::string value, unsigned int exId)
{
GetDocExample()->AddParameter( key, value, exId );
this->Modified();
}
void Application::SetExampleComment( const std::string & comm, unsigned int i )
{
GetDocExample()->SetExampleComment( comm, i );
this->Modified();
}
unsigned int Application::AddExample(const std::string & comm)
{
unsigned int id = GetDocExample()->AddExample( comm );
this->Modified();
return id;
}
std::string Application::GetCLExample()
{
return GetDocExample()->GenerateCLExample();
}
std::string Application::GetHtmlExample()
{
return GetDocExample()->GenerateHtmlExample();
}
void Application::ForceInXMLParseFlag()
{
m_IsInXMLParsed = false;
}
void Application::SetDocLink(const std::string & link)
{
if (m_Doclink.compare(link) != 0)
{
m_Doclink = link;
this->Modified();
}
}
const std::string& Application::GetDocLink() const
{
return m_Doclink;
}
void Application::SetOfficialDocLink()
{
std::string link = "http://www.orfeo-toolbox.org/Applications/";
link.append(this->GetName());
link.append(".html");
this->SetDocLink(link);
}
Application::Application()
: m_Name(""),
m_Description(""),
......@@ -89,6 +316,7 @@ void Application::SetLogger(otb::Logger *logger)
{
m_Logger = logger;
}
this->Modified();
}
std::vector<std::string>
......@@ -1653,24 +1881,9 @@ unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::stri
}
FloatVectorImageType* Application::GetParameterImage(std::string parameter)
{
FloatVectorImageType::Pointer ret = nullptr;
Parameter* param = GetParameterByKey(parameter);
if (dynamic_cast<InputImageParameter*> (param))
{
InputImageParameter* paramDown = dynamic_cast<InputImageParameter*> (param);
ret = paramDown->GetImage();
}
else
{
itkExceptionMacro(<<parameter << " parameter can't be casted to ImageType");
}
return ret;
return this->GetParameterImage<FloatVectorImageType>(parameter);
}
FloatVectorImageListType* Application::GetParameterImageList(std::string parameter)
......@@ -2220,5 +2433,52 @@ Application::GetImageBasePixelType(const std::string & key, unsigned int idx)
return ImagePixelType_uint8;
}
#define otbGetParameterImageMacro( Image ) \
Image##Type * Application::GetParameter##Image(std::string parameter) \
{ \
Parameter* param = GetParameterByKey(parameter); \
InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); \
if ( paramDown ) \
{ \
return paramDown->Get##Image(); \
} \
ComplexInputImageParameter* paramDownC = dynamic_cast<ComplexInputImageParameter*>(param); \
if ( paramDownC ) \
{ \
return paramDownC->Get##Image(); \
} \
return Image##Type::Pointer(); \
}
otbGetParameterImageMacro(UInt8Image);
otbGetParameterImageMacro(UInt16Image);
otbGetParameterImageMacro(Int16Image);
otbGetParameterImageMacro(UInt32Image);
otbGetParameterImageMacro(Int32Image);
otbGetParameterImageMacro(FloatImage);
otbGetParameterImageMacro(DoubleImage);
otbGetParameterImageMacro(UInt8VectorImage);
otbGetParameterImageMacro(UInt16VectorImage);
otbGetParameterImageMacro(Int16VectorImage);
otbGetParameterImageMacro(UInt32VectorImage);
otbGetParameterImageMacro(Int32VectorImage);
otbGetParameterImageMacro(FloatVectorImage);
otbGetParameterImageMacro(DoubleVectorImage);
otbGetParameterImageMacro(UInt8RGBImage);
otbGetParameterImageMacro(UInt8RGBAImage);
// Complex image
otbGetParameterImageMacro(ComplexInt16Image);
otbGetParameterImageMacro(ComplexInt32Image);
otbGetParameterImageMacro(ComplexFloatImage);
otbGetParameterImageMacro(ComplexDoubleImage);
otbGetParameterImageMacro(ComplexInt16VectorImage);
otbGetParameterImageMacro(ComplexInt32VectorImage);
otbGetParameterImageMacro(ComplexFloatVectorImage);
otbGetParameterImageMacro(ComplexDoubleVectorImage);
}
}
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