Medical Imaging Interaction Toolkit  2018.4.99-08619e4f
Medical Imaging Interaction Toolkit
mitkIOAdapter.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 #ifndef __mitkIOAdapter_h
13 #define __mitkIOAdapter_h
14 
15 #include "mitkBaseProcess.h"
16 
17 #include "itkObject.h"
18 
19 namespace mitk
20 {
27  class IOAdapterBase : public itk::Object
28  {
29  public:
32  typedef itk::Object Superclass;
35 
37  virtual itk::SmartPointer<BaseDataSource> CreateIOProcessObject(const std::string filename,
38  const std::string filePrefix,
39  const std::string filePattern) = 0;
40  virtual bool CanReadFile(const std::string filename,
41  const std::string filePrefix,
42  const std::string filePattern) = 0;
43 
44  protected:
46  ~IOAdapterBase() override {}
47  private:
48  IOAdapterBase(const Self &); // purposely not implemented
49  void operator=(const Self &); // purposely not implemented
50  };
51 
60  template <class T>
61  class IOAdapter : public IOAdapterBase
62  {
63  public:
65  typedef IOAdapter Self;
67 
69  itkFactorylessNewMacro(Self);
71  const std::string filePrefix,
72  const std::string filePattern) override
73  {
74  typename T::Pointer ioProcessObject = T::New();
75  ioProcessObject->SetFileName(filename.c_str());
76  ioProcessObject->SetFilePrefix(filePrefix.c_str());
77  ioProcessObject->SetFilePattern(filePattern.c_str());
78  return ioProcessObject.GetPointer();
79  }
80 
81  bool CanReadFile(const std::string filename,
82  const std::string filePrefix,
83  const std::string filePattern) override
84  {
85  return T::CanReadFile(filename, filePrefix, filePattern);
86  }
87 
88  protected:
89  IOAdapter() {}
90  ~IOAdapter() override {}
91  private:
92  IOAdapter(const Self &); // purposely not implemented
93  void operator=(const Self &); // purposely not implemented
94  };
95 
96 } // end namespace mitk
97 
98 #endif
itk::Object Superclass
Definition: mitkIOAdapter.h:32
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
Definition: mitkIOAdapter.h:33
virtual itk::SmartPointer< BaseDataSource > CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern)=0
Create an object and return a pointer to it as a mitk::BaseProcess.
virtual bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)=0
mitk::BaseDataSource::Pointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) override
Create an object and return a pointer to it as a mitk::BaseProcess.
Definition: mitkIOAdapter.h:70
IOAdapterBase class is an abstract adapter class for IO process objects.
Definition: mitkIOAdapter.h:27
IOAdapterBase Self
Definition: mitkIOAdapter.h:31
IOAdapter class is an adapter class for instantiation of IO process objects. Additional this interfac...
Definition: mitkIOAdapter.h:61
IOAdapter Self
Definition: mitkIOAdapter.h:65
~IOAdapter() override
Definition: mitkIOAdapter.h:90
itk::SmartPointer< Self > Pointer
Definition: mitkIOAdapter.h:66
bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) override
Definition: mitkIOAdapter.h:81
~IOAdapterBase() override
Definition: mitkIOAdapter.h:46
itk::SmartPointer< const Self > ConstPointer
Definition: mitkIOAdapter.h:34