Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
64646df8
Commit
64646df8
authored
Nov 28, 2011
by
Cyrille Valladeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: add a structure for appli example
parent
2b96d7a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
256 additions
and
0 deletions
+256
-0
Code/ApplicationEngine/otbWrapperDocExampleStructure.h
Code/ApplicationEngine/otbWrapperDocExampleStructure.h
+168
-0
Testing/Code/ApplicationEngine/CMakeLists.txt
Testing/Code/ApplicationEngine/CMakeLists.txt
+13
-0
Testing/Code/ApplicationEngine/otbWrapperCoreTests.cxx
Testing/Code/ApplicationEngine/otbWrapperCoreTests.cxx
+2
-0
Testing/Code/ApplicationEngine/otbWrapperDocExampleStructureTest.cxx
...e/ApplicationEngine/otbWrapperDocExampleStructureTest.cxx
+73
-0
No files found.
Code/ApplicationEngine/otbWrapperDocExampleStructure.h
0 → 100644
View file @
64646df8
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperDocExampleStructure_h
#define __otbWrapperDocExampleStructure_h
#include <string>
#include <iostream>
#include <vector>
#include "itkMacro.h"
#include "otbConfigure.h"
namespace
otb
{
namespace
Wrapper
{
/** \class DocExampleStructure
* \brief This class represent a string parameter for the wrapper framework
*/
class
DocExampleStructure
{
public:
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
PairType
;
typedef
std
::
vector
<
PairType
>
ParameterListType
;
void
AddParameter
(
const
std
::
string
key
,
const
std
::
string
value
)
{
PairType
myPair
;
myPair
.
first
=
key
;
myPair
.
second
=
value
;
this
->
AddParameter
(
myPair
);
}
void
AddParameter
(
const
PairType
myPair
)
{
m_ParameterList
.
push_back
(
myPair
);
}
PairType
GetParameter
(
unsigned
int
i
)
{
if
(
m_ParameterList
.
size
()
<=
i
)
itkGenericExceptionMacro
(
"Index "
<<
i
<<
" out of range. (max index: "
<<
m_ParameterList
.
size
()
<<
")."
);
return
m_ParameterList
[
i
];
}
ParameterListType
GetParameterList
()
{
return
m_ParameterList
;
}
std
::
string
GetParameterKey
(
unsigned
int
i
)
{
return
this
->
GetParameter
(
i
).
first
;
}
int
GetParameterValueAsInt
(
unsigned
int
i
)
{
return
atoi
(
this
->
GetParameter
(
i
).
second
.
c_str
());
}
float
GetParameterValueAsFloat
(
unsigned
int
i
)
{
return
atoi
(
this
->
GetParameter
(
i
).
second
.
c_str
());
}
std
::
string
GetParameterValueAsString
(
unsigned
int
i
)
{
return
this
->
GetParameter
(
i
).
second
;
}
void
SetApplicationName
(
const
std
::
string
name
)
{
m_ApplicationName
=
name
;
}
std
::
string
GetApplicationName
()
{
return
m_ApplicationName
;
}
void
SetBinPath
(
const
std
::
vector
<
std
::
string
>
bPath
)
{
m_BinPath
=
bPath
;
}
void
AddBinPath
(
std
::
string
myPath
)
{
m_BinPath
.
push_back
(
myPath
);
}
std
::
vector
<
std
::
string
>
GetBinPath
()
{
return
m_BinPath
;
}
std
::
string
GenerateCLExample
()
{
if
(
m_ApplicationName
.
empty
()
||
m_BinPath
.
size
()
==
0
||
m_ParameterList
.
size
()
==
0
)
{
itkGenericExceptionMacro
(
"Missing attributs to generate the example."
);
}
itk
::
OStringStream
oss
;
oss
<<
OTB_CONFIG
<<
"/bin/otbApplicationLauncherCommandLine "
;
for
(
unsigned
int
i
=
0
;
i
<
m_BinPath
.
size
();
i
++
)
{
oss
<<
m_BinPath
[
i
]
<<
" "
;
}
for
(
unsigned
int
i
=
0
;
i
<
m_ParameterList
.
size
();
i
++
)
{
oss
<<
"-"
<<
m_ParameterList
[
i
].
first
<<
" "
<<
m_ParameterList
[
i
].
second
<<
" "
;
}
std
::
string
res
=
oss
.
str
();
// Supress last added space
res
.
erase
(
res
.
size
()
-
1
,
1
);
return
res
;
}
/** Constructor */
DocExampleStructure
()
{}
/** Destructor */
virtual
~
DocExampleStructure
()
{}
protected:
private:
DocExampleStructure
(
const
DocExampleStructure
&
);
//purposely not implemented
void
operator
=
(
const
DocExampleStructure
&
);
//purposely not implemented
ParameterListType
m_ParameterList
;
std
::
string
m_ApplicationName
;
std
::
vector
<
std
::
string
>
m_BinPath
;
};
// End class Parameter
}
// End namespace Wrapper
}
// End namespace otb
#endif
Testing/Code/ApplicationEngine/CMakeLists.txt
View file @
64646df8
...
...
@@ -170,6 +170,18 @@ add_test(NAME owTvApplicationHtmlDocGeneratorTest
${
TEMP
}
/owTvOReadImageInfoDoc.html
)
endif
(
BUILD_APPLICATIONS
)
# DocExampleStructure
add_test
(
owTuDocExampleStructure
${
OTB_WRAPPER_TESTS
}
otbWrapperDocExampleStructure
)
add_test
(
owTuDocExampleStructureTest
${
OTB_WRAPPER_TESTS
}
otbWrapperDocExampleStructureTest
)
# ----------------Source files CXX -----------------------------------
set
(
Wrapper_SRCS
...
...
@@ -192,6 +204,7 @@ otbWrapperStringParameterTest.cxx
otbWrapperRAMParameterTest.cxx
otbWrapperStringListParameterTest.cxx
otbWrapperApplicationHtmlDocGeneratorTest.cxx
otbWrapperDocExampleStructureTest.cxx
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/Code/Core
)
...
...
Testing/Code/ApplicationEngine/otbWrapperCoreTests.cxx
View file @
64646df8
...
...
@@ -53,5 +53,7 @@ void RegisterTests()
REGISTER_TEST
(
otbWrapperRAMParameterNew
);
REGISTER_TEST
(
otbWrapperApplicationHtmlDocGeneratorNew
);
REGISTER_TEST
(
otbWrapperApplicationHtmlDocGeneratorTest1
);
REGISTER_TEST
(
otbWrapperDocExampleStructure
);
REGISTER_TEST
(
otbWrapperDocExampleStructureTest
);
}
Testing/Code/ApplicationEngine/otbWrapperDocExampleStructureTest.cxx
0 → 100644
View file @
64646df8
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "otbWrapperDocExampleStructure.h"
#include "itksys/SystemTools.hxx"
int
otbWrapperDocExampleStructure
(
int
argc
,
char
*
argv
[])
{
typedef
otb
::
Wrapper
::
DocExampleStructure
DocExampleStructureType
;
DocExampleStructureType
docStruct
;
return
EXIT_SUCCESS
;
}
int
otbWrapperDocExampleStructureTest
(
int
argc
,
char
*
argv
[])
{
typedef
otb
::
Wrapper
::
DocExampleStructure
DocExampleStructureType
;
DocExampleStructureType
docStruct
;
docStruct
.
SetApplicationName
(
"TestApplication"
);
std
::
vector
<
std
::
string
>
bPath
;
bPath
.
push_back
(
"binPath1"
);
docStruct
.
SetBinPath
(
bPath
);
docStruct
.
AddBinPath
(
"binPath2"
);
DocExampleStructureType
::
PairType
mPair
;
mPair
.
first
=
"key1"
;
mPair
.
second
=
"val1"
;
docStruct
.
AddParameter
(
mPair
);
docStruct
.
AddParameter
(
"key2"
,
"val2"
);
std
::
string
exp
=
docStruct
.
GenerateCLExample
();
if
(
exp
.
find
(
"otbApplicationLauncherCommandLine binPath1 binPath2 -key1 val1 -key2 val2"
)
==
std
::
string
::
npos
)
{
std
::
cout
<<
"ERROR in expression: "
<<
exp
<<
std
::
endl
;
std
::
cout
<<
"The returned expression is not the waited one"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
std
::
cout
<<
exp
.
substr
(
0
,
exp
.
find_first_of
(
" "
)
)
<<
std
::
endl
;
if
(
!
itksys
::
SystemTools
::
FileExists
(
exp
.
substr
(
0
,
exp
.
find_first_of
(
" "
)
).
c_str
()
)
)
{
std
::
cout
<<
"ERROR in expression: "
<<
exp
<<
std
::
endl
;
std
::
cout
<<
"The executable is not valid"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
return
EXIT_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment