otbObjectListToObjectListFilter.h 4.15 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


13
14
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
16
17
18
19
20
21
22
23
24
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbObjectListToObjectListFilter_h
#define __otbObjectListToObjectListFilter_h

#include "otbObjectListSource.h"

namespace otb
{
25

26
/** \class ObjectListToObjectListFilter
27
   * \brief Base class for filters that take an ObjectList as input and produce an ObjectList as output.
28
   *
29
30
   * ObjectListToObjectListFilter is the base class for all process objects that output
   * ObjectList data and require ObjectList data as input. Specifically, this class
31
   * defines the SetInput() method for defining the input to a filter.
32
33
34
35
   *
   * Be aware that this class is templated over the list type, not the object type. It will
   * be typically something like otb::ObjectList<ObjectType>. This is to enable the use of
   * class derived from ObjectList or other implementations.
36
   *
37
38
   *
   * \ingroup ObjectListFilter
39
 */
40
41
42
43
44
template <class TInputList, class TOutputList >
class ITK_EXPORT ObjectListToObjectListFilter : public otb::ObjectListSource<TOutputList>
{
public:
  /** Standard class typedefs. */
Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
45
  typedef ObjectListToObjectListFilter        Self;
46
  typedef otb::ObjectListSource<TOutputList>  Superclass;
Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
47
48
  typedef itk::SmartPointer<Self>             Pointer;
  typedef itk::SmartPointer<const Self>       ConstPointer;
49

50
51
  /** Method for creation through the object factory. */
  itkNewMacro(Self);
52

53
54
  /** Run-time type information (and related methods). */
  itkTypeMacro(ObjectListToObjectListFilter, ObjectListSource);
55

56
  /** Some typedefs. */
Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
57
58
59
60
61
62
  typedef TInputList                          InputListType;
  typedef TOutputList                         OutputListType;
  typedef typename TInputList::ConstPointer   InputListPointer;
  typedef typename TOutputList::Pointer       OutputListPointer;
  typedef typename TInputList::ConstIterator  InputListIterator;
  typedef typename InputListType::ObjectType  InputObjectType;
63
  typedef typename OutputListType::ObjectType OutputObjectType;
64

Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
65
  typedef itk::DataObject::Pointer            DataObjectPointer;
66

67
68
  virtual void SetInput( const InputListType *input);
  const InputListType * GetInput(void);
69

70
71
72
73
74
75
76
protected:
  /** Constructor */
  ObjectListToObjectListFilter();
  /** Destructor */
  virtual ~ObjectListToObjectListFilter() {};
  /**PrintSelf method */
  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
77

78
  virtual void GenerateData(void);
79

80
  /** Multi-threading implementation */
81

Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
82
83
  typedef std::vector<OutputListPointer> OutputListForThreadType;

84
  virtual void BeforeThreadedGenerateData();
85

86
  virtual void AfterThreadedGenerateData() {};
87

Emmanuel Christophe's avatar
STYLE    
Emmanuel Christophe committed
88
89
  virtual int SplitRequestedRegion(int threadId, int threadCount, unsigned int requestedElements,
                                   unsigned int& startIndex, unsigned int& stopIndex);
90

91
92
93
  /** startIndex and stopIndex represent the indices of the Objects
   * to examine in thread threadId */
  virtual void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, int threadId);
94

95
96
97
98
  /** Static function used as a "callback" by the MultiThreader.  The threading
   * library will call this routine for each thread, which will delegate the
   * control to ThreadedGenerateData(). */
  static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );
99

100
101
102
103
104
  /** Internal structure used for passing image data into the threading library */
  struct ThreadStruct
  {
    Pointer Filter;
  };
105

106
107
  OutputListForThreadType m_ObjectListPerThread;

108
  /** End Multi-threading implementation */
109
110


111
112
113
private:
  ObjectListToObjectListFilter(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented
114

115
};
116
117
118
119
120
121
122
123

} // end namespace otb

#ifndef ITK_MANUAL_INSTANTIATION
#include "otbObjectListToObjectListFilter.txx"
#endif

#endif