diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index b9db494becf30b3c3bf956c318f28c0d9a1cbc9a..dcd1182b563680c436c831d7e284f6d785e1c43a 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -23,6 +23,7 @@ #include <vector> #include "itkDataObject.h" +#include "otbObjectListInterface.h" #include "itkObjectFactory.h" namespace otb @@ -36,7 +37,7 @@ namespace otb * \ingroup OTBObjectList */ template <class TObject> -class ITK_EXPORT ObjectList : public itk::DataObject +class ITK_EXPORT ObjectList : public itk::DataObject , public ObjectListInterface { public: /** Standard typedefs */ @@ -99,6 +100,11 @@ public: * \return The pointer to the nth element of the list. */ ObjectPointerType GetNthElement(unsigned int index) const; + /** + * Get the nth element of the list as a DataObject *. + * \param index The index of the object to get. + */ + Superclass * GetNthDataObject(unsigned int index) const; /** * Return the first element of the list. * \return The first element of the list. diff --git a/Modules/Core/ObjectList/include/otbObjectList.txx b/Modules/Core/ObjectList/include/otbObjectList.txx index 26044b1432f2023d2c34ecbdb57afa8374bab3e3..121dfd90b01678a16fd501c76862bba7f5bab064 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.txx +++ b/Modules/Core/ObjectList/include/otbObjectList.txx @@ -162,6 +162,16 @@ ObjectList<TObject> } return m_InternalContainer[index]; } + +template <class TObject> +typename ObjectList<TObject>::Superclass * +ObjectList<TObject> +::GetNthDataObject(unsigned int index) const +{ + ObjectType * object = GetNthElement(index).GetPointer(); + return dynamic_cast< Superclass * > ( object ); +} + /** * Return the first element of the list. * \return The first element of the list. diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbObjectListInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..a99df955c6bbeb89bfdb583505fe5a2d2e5d4631 --- /dev/null +++ b/Modules/Core/ObjectList/include/otbObjectListInterface.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbObjectListInterface_h +#define otbObjectListInterface_h + +#include "itkDataObject.h" + +namespace otb +{ + +class ObjectListInterface +{ + +public: + + ObjectListInterface() {}; + virtual ~ObjectListInterface(){}; + + virtual itk::DataObject * GetNthDataObject(unsigned int index) const = 0; + + virtual std::size_t Size(void) const = 0; + +}; + +} // end of otb namespace + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index e3458e9fab5a8b13c08eb06dddaa5d08523db439..dbf71f564737e417a91148712c1f31c80005fae5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -449,6 +449,20 @@ Application::RegisterPipeline() if ( inputData.count( current ) || !current ) continue; std::cout<<"it is not an input"<<std::endl; + if ( dynamic_cast< ObjectListInterface *> (current) ) + { + ObjectListInterface * list = + dynamic_cast< ObjectListInterface *> (current); + int length = list->Size(); + for ( int i = 0 ; i < length ; i++ ) + { + itk::DataObject * newData = list->GetNthDataObject(i); + if ( inputData.count( current ) || !current ) + continue; + dataStack.push( newData ); + } + continue; + } itk::ProcessObject * process = (current->GetSource()).GetPointer(); if ( m_Filters.find( process ) != m_Filters.end() || !process ) continue;