Commit 7fafc49c authored by Otmane Lahlou's avatar Otmane Lahlou

ADD: init a class in charge of searching applications in a given directory

parent 56d94002
......@@ -29,6 +29,7 @@ set( Common_SOURCES
mvdTypes.cxx
mvdVectorImageModel.cxx
mvdApplicationsToolBox.cxx
mvdApplicationsBrowser.cxx
)
# Headers for classes with Q_OBJECT macro (needs to go to Qt moc)
......@@ -57,6 +58,7 @@ set( Common_HEADERS_MOC
mvdStatusBarWidget.h
mvdVectorImageModel.h
mvdApplicationsToolBox.h
mvdApplicationsBrowser.h
)
# Qt designer UI files
......@@ -108,7 +110,7 @@ add_library(Monteverdi2_Common
#############################################################################
target_link_libraries(Monteverdi2_Common
OTBIO
OTBIO OTBApplicationEngine
${OPENGL_LIBRARIES}
Qt4::QtCore
Qt4::QtGui
......
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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.
=========================================================================*/
#include "mvdApplicationsBrowser.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "otbWrapperApplicationRegistry.h"
#include "otbWrapperApplication.h"
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::ApplicationsBrowser
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CONSTANTS */
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
ApplicationsBrowser
::ApplicationsBrowser( QObject* parent ) :
QObject( parent ),
m_AutoLoadPath("")
{
}
/*******************************************************************************/
ApplicationsBrowser
::~ApplicationsBrowser()
{
}
/*******************************************************************************/
void
ApplicationsBrowser
::SetAutoLoadPath(const std::string & itk_auto_load_path)
{
m_AutoLoadPath = itk_auto_load_path;
//
// add the path
otb::Wrapper::ApplicationRegistry::AddApplicationPath(m_AutoLoadPath);
}
/*******************************************************************************/
StringVector
ApplicationsBrowser
::GetAvailableApplications()
{
//
// check if search path is not empty
// TODO : throw exception to be catched by the catalog manager later
if (m_AutoLoadPath.empty())
{
std::cerr << "ERROR: Search path is empty "<< std::endl;
}
//
// Get available application in search path
StringVector appList = otb::Wrapper::ApplicationRegistry::GetAvailableApplications();
//
// some verbosity
// TODO : remove this verbosity later
if ( appList.size() == 0 )
{
std::cerr << "ERROR: Available modules : none." << std::endl;
}
else
{
std::cout << "--- Available modules :" << std::endl;
for (StringVector::const_iterator it = appList.begin(); it != appList.end(); ++it)
{
std::cout << "\t" << *it << std::endl;
}
}
return appList;
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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 __mvdApplicationsBrowser_h
#define __mvdApplicationsBrowser_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtCore>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdTypes.h"
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class ApplicationsBrowser
*
* \brief Search for available applications in a directory.
*
* This class provides the functionnalities to look for
* otbWrapperApplication apps in a given directory. The method used to
* set the directory is SetAutoLoadPath(const std::string &).
*
* If applications are available in the directory set by the user,
* tags of each application are extracted.
*
* An association application-tags is then setup and stored in a
* std::vector to be sent ( via a signal ) to the
* mvd::ApplicationsToolBox or any widget or class connected to this
* signal.
*
*/
class Monteverdi2_EXPORT ApplicationsBrowser :
public QObject
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** \brief Constructor. */
ApplicationsBrowser( QObject* parent =NULL );
/** \brief Destructor. */
virtual ~ApplicationsBrowser();
/** Set the path where to look for applications */
void SetAutoLoadPath(const std::string & itk_auto_load_path);
/** Get available applications in the search path */
StringVector GetAvailableApplications();
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
// Public SLOTS.
public slots:
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private methods.
private:
//
// Private attributes.
private:
std::string m_AutoLoadPath;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
};
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
} // end namespace 'mvd'
#endif // __mvdApplicationsBrowser_h
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