Skip to content
Snippets Groups Projects
Commit 20a44cd0 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: wrap more Application method, remove Parameter and ParameterGroup, rename...

ENH: wrap more Application method, remove Parameter and ParameterGroup, rename ApplicationRegistry to Registry
parent 115f3f28
No related branches found
No related tags found
No related merge requests found
......@@ -15,22 +15,42 @@ namespace otb
namespace Wrapper
{
enum DefaultValueMode
enum DefaultValueMode
{
UNKNOWN,
RELATIVE,
ABSOLUTE
};
typedef enum
{
ParameterType_Empty,
ParameterType_Int,
ParameterType_Float,
ParameterType_String,
ParameterType_Filename,
ParameterType_Directory,
ParameterType_Choice,
ParameterType_InputImage,
ParameterType_InputComplexImage,
ParameterType_InputVectorData,
ParameterType_OutputImage,
ParameterType_OutputVectorData,
ParameterType_Radius,
ParameterType_Group,
} ParameterType;
typedef enum
{
UserLevel_Basic,
UserLevel_Advanced
} UserLevel;
}
}
/** \class Parameter
* \brief This class represent a parameter for the wrapper framework
* This class is a high level class representing a parameter for the
* wrapper framework. It should be subclassed to represent different
* kinds of parameters
*/
/*
class Parameter : public itkObject
{
public:
......@@ -84,6 +104,7 @@ private:
void operator =(const ParameterGroup&);
};
DECLARE_REF_COUNT_CLASS( ParameterGroup )
*/
class Application: public itkObject
{
......@@ -97,7 +118,22 @@ public:
void Init();
void UpdateParameters();
void Execute();
ParameterGroup* GetParameterList();
void ExecuteAndWriteOutput();
// ParameterGroup* GetParameterList();
// Parameter* GetParameterByKey(std::string parameter);
// const Parameter* GetParameterByKey(std::string parameter) const;
std::list<std::string> GetParametersKeys();
void EnableParameter(std::string paramKey);
void DisableParameter(std::string paramKey);
bool IsParameterEnabled(std::string paramKey) const;
bool IsMandatory(std::string paramKey) const;
bool HasUserValue(std::string paramKey) const;
void ClearValue(std::string paramKey);
bool HasValue(std::string paramKey) const;
otb::Wrapper::UserLevel GetParameterUserLevel(std::string paramKey) const;
otb::Wrapper::ParameterType GetParameterType(std::string paramKey) const;
void SetParameterInt(std::string parameter, int value);
void SetParameterFloat(std::string parameter, float value);
......@@ -110,7 +146,13 @@ public:
protected:
Application();
virtual ~Application();
void AddChoice(std::string paramKey, std::string paramName);
void AddParameter(otb::Wrapper::ParameterType type, std::string paramKey, std::string paramName);
void MandatoryOn(std::string paramKey);
void MandatoryOff(std::string paramKey);
void SetParameterUserLevel(std::string paramKey, otb::Wrapper::UserLevel level);
private:
virtual void DoCreateParameters() = 0;
virtual void DoUpdateParameters() = 0;
......@@ -122,18 +164,18 @@ private:
DECLARE_REF_COUNT_CLASS( Application )
class ApplicationRegistry : public itkObject
class Registry : public itkObject
{
public:
static std::list<std::string> GetAvailableApplications();
static Application_Pointer CreateApplication(const std::string& name);
protected:
ApplicationRegistry();
virtual ~ApplicationRegistry();
Registry();
virtual ~Registry();
private:
ApplicationRegistry(const Self&);
Registry(const Self&);
void operator=(const Self&);
};
......@@ -18,22 +18,22 @@
#ifndef __otbWrapperSWIGIncludes_h
#define __otbWrapperSWIGIncludes_h
#include "otbWrapperParameter.h"
#include "otbWrapperParameterGroup.h"
//#include "otbWrapperParameter.h"
//#include "otbWrapperParameterGroup.h"
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationRegistry.h"
typedef otb::Wrapper::Parameter Parameter;
typedef otb::Wrapper::Parameter::Pointer::SmartPointer Parameter_Pointer;
//typedef otb::Wrapper::Parameter Parameter;
//typedef otb::Wrapper::Parameter::Pointer::SmartPointer Parameter_Pointer;
typedef otb::Wrapper::ParameterGroup ParameterGroup;
typedef otb::Wrapper::ParameterGroup::Pointer::SmartPointer ParameterGroup_Pointer;
//typedef otb::Wrapper::ParameterGroup ParameterGroup;
//typedef otb::Wrapper::ParameterGroup::Pointer::SmartPointer ParameterGroup_Pointer;
typedef otb::Wrapper::Application Application;
typedef otb::Wrapper::Application::Pointer::SmartPointer Application_Pointer;
typedef otb::Wrapper::ApplicationRegistry ApplicationRegistry;
typedef otb::Wrapper::ApplicationRegistry::Pointer::SmartPointer ApplicationRegistry_Pointer;
typedef otb::Wrapper::ApplicationRegistry Registry;
typedef otb::Wrapper::ApplicationRegistry::Pointer::SmartPointer Registry_Pointer;
#endif
......@@ -64,7 +64,6 @@ private:
std::cout << "~Smoothing" << std::endl;
}
void DoCreateParameters()
{
AddParameter(ParameterType_InputImage, "in", "Input Image");
......
......@@ -2,14 +2,17 @@
# Example on the use of the Smoothing
#
from sys import argv
import otbApplication
import otbApplication as otb
print otbApplication.ApplicationRegistry.GetAvailableApplications()
print otb.Registry.GetAvailableApplications()
app = otb.Registry.CreateApplication("Smoothing")
print app.GetParametersKeys()
app = otbApplication.ApplicationRegistry.CreateApplication("Smoothing")
app.SetParameterString("in", argv[1])
for type in ['mean', 'gaussian', 'anidif']:
print 'Testing ' + type
app.SetParameterString("type", type)
app.SetParameterString("out", argv[2] + type + ".tif")
app.Execute()
......
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