Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitkBaseDataSource.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkBaseDataSource_h
14 #define mitkBaseDataSource_h
15 
16 #include <MitkCoreExports.h>
17 #include <itkProcessObject.h>
18 #include <mitkCommon.h>
19 
20 #define mitkBaseDataSourceGetOutputDeclarations \
21  OutputType *GetOutput(); \
22  const OutputType *GetOutput() const; \
23  OutputType *GetOutput(DataObjectPointerArraySizeType idx); \
24  const OutputType *GetOutput(DataObjectPointerArraySizeType idx) const;
25 
26 #define mitkBaseDataSourceGetOutputDefinitions(className) \
27  className::OutputType *className::GetOutput(void) \
28  { \
29  return itkDynamicCastInDebugMode<OutputType *>(this->GetPrimaryOutput()); \
30  } \
31  const className::OutputType *className::GetOutput(void) const \
32  { \
33  return itkDynamicCastInDebugMode<const OutputType *>(this->GetPrimaryOutput()); \
34  } \
35  className::OutputType *className::GetOutput(DataObjectPointerArraySizeType idx) \
36  { \
37  OutputType *out = dynamic_cast<OutputType *>(this->ProcessObject::GetOutput(idx)); \
38  if (out == nullptr && this->ProcessObject::GetOutput(idx) != nullptr) \
39  { \
40  itkWarningMacro(<< "Unable to convert output number " << idx << " to type " << typeid(OutputType).name()); \
41  } \
42  return out; \
43  } \
44  const className::OutputType *className::GetOutput(DataObjectPointerArraySizeType idx) const \
45  { \
46  const OutputType *out = dynamic_cast<const OutputType *>(this->ProcessObject::GetOutput(idx)); \
47  if (out == nullptr && this->ProcessObject::GetOutput(idx) != nullptr) \
48  { \
49  itkWarningMacro(<< "Unable to convert output number " << idx << " to type " << typeid(OutputType).name()); \
50  } \
51  return out; \
52  }
53 
54 namespace mitk
55 {
56  class BaseData;
57 
71  class MITKCORE_EXPORT BaseDataSource : public itk::ProcessObject
72  {
73  public:
75 
76  typedef BaseData OutputType;
77  typedef itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType;
78 
80 
103  virtual void
104  GraftOutput(OutputType *output);
105 
112  virtual void GraftOutput(const DataObjectIdentifierType &key, OutputType *output);
113 
123  virtual void GraftNthOutput(unsigned int idx, OutputType *output);
124 
128  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override = 0;
129 
133  DataObjectPointer MakeOutput(const DataObjectIdentifierType &name) override = 0;
134 
142  bool Updating() const;
143 
144  protected:
145  BaseDataSource();
146  ~BaseDataSource() override;
147 
148  // purposely not implemented
149  static Pointer New();
150  };
151 
152 } // namespace mitk
153 
154 #endif
itk::SmartPointer< Self >
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::BaseDataSource::DataObjectIdentifierType
itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
Definition: mitkBaseDataSource.h:77
mitk::BaseDataSource
Superclass of all classes generating some kind of mitk::BaseData.
Definition: mitkBaseDataSource.h:71
MitkCoreExports.h
mitkBaseDataSourceGetOutputDeclarations
#define mitkBaseDataSourceGetOutputDeclarations
Definition: mitkBaseDataSource.h:20
mitkCommon.h
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15