Commit dddd2520 authored by Otmane Lahlou's avatar Otmane Lahlou

ENH: add methods to fil the map storing tag/apps associations

parent dac67056
......@@ -102,7 +102,7 @@ ApplicationsBrowser
}
//
// Get available application in search path
// get available application in search path
StringVector appList = otb::Wrapper::ApplicationRegistry::GetAvailableApplications();
//
......@@ -124,6 +124,84 @@ ApplicationsBrowser
return appList;
}
/*******************************************************************************/
StringVector
ApplicationsBrowser
::GetApplicationTags( const std::string& appName )
{
//
// output vector
StringVector vtags;
//
// instantiate the application using the factory
otb::Wrapper::Application::Pointer application
= otb::Wrapper::ApplicationRegistry::CreateApplication(appName);
//
// get tags
if ( !application.IsNull() )
{
vtags = application->GetDocTags();
}
return vtags;
}
/*******************************************************************************/
void
ApplicationsBrowser
::SearchAvailableApplicationsTags()
{
//
// get all the applications in the search path
StringVector vapp = GetAvailableApplications();
//
// loop on the applications to get tags
ApplicationsTagContainer outputContainer;
StringVector::const_iterator it = vapp.begin();
while ( it != vapp.end() )
{
// get tags of current app
StringVector ctags = GetApplicationTags( *it );
// key will be the tag (easier for tree origanisation in )
StringVector::const_iterator itTag = ctags.begin();
while ( itTag != ctags.end() )
{
// search for this tag in the output container
ApplicationsTagContainer::iterator pos = outputContainer.find( *itTag );
if ( pos != outputContainer.end() ) // key found
{
//
// add the application name (*it) as value for the current app tag
(*pos).second.push_back(*it);
}
else
{
//
// if tag not found in the container, add it
std::pair< std::string, StringVector > currentAppTags;
currentAppTags.first = *itTag;
currentAppTags.second.push_back( *it );
outputContainer.insert( currentAppTags );
}
++itTag;
}
++it;
}
//
// emit a signal with the ApplicationsTagContainer as
// parameter
emit AvailableApplicationsTagsChanged(outputContainer);
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
......
......@@ -96,18 +96,29 @@ class Monteverdi2_EXPORT ApplicationsBrowser :
// Public methods.
public:
/** typedef */
/** \brief Constructor. */
ApplicationsBrowser( QObject* parent =NULL );
/** \brief Destructor. */
virtual ~ApplicationsBrowser();
/** Set the path where to look for applications */
/** set the path where to look for applications */
void SetAutoLoadPath(const std::string & itk_auto_load_path);
/** Get available applications in the search path */
/** get available applications in the search path */
StringVector GetAvailableApplications();
/** return the list applications <->tags */
StringVector GetApplicationTags(const std::string& appName);
/** return std::map storing tag/apps association for all the
* applications in the search path
*/
void SearchAvailableApplicationsTags();
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
......@@ -119,6 +130,7 @@ public slots:
//
// Signals.
signals:
void AvailableApplicationsTagsChanged(const ApplicationsTagContainer &);
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
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