Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkNewModuleIOActivator.cpp
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 #include <usModuleActivator.h>
13 #include <usModuleContext.h>
14 
16 
18 
19 #include "mitkExampleIOMimeTypes.h"
20 
21 namespace mitk
22 {
26  class NewModuleIOActivator : public us::ModuleActivator
27  {
28  public:
29  void Load(us::ModuleContext *context) override
30  {
31  // We can register our read/write services with a custom service ranking
32  // services with a higher ranking are prioritized, default us 0
35 
36  m_MimeTypes = mitk::ExampleIOMimeTypes::Get();
37  for (std::vector<mitk::CustomMimeType *>::const_iterator mimeTypeIter = m_MimeTypes.begin(),
38  iterEnd = m_MimeTypes.end();
39  mimeTypeIter != iterEnd;
40  ++mimeTypeIter)
41  {
42  context->RegisterService(*mimeTypeIter, props);
43  }
44 
45  m_ExampleDataStructureReaderService = new ExampleDataStructureReaderService();
46 
47  m_ExampleDataStructureWriterService = new ExampleDataStructureWriterService();
48  }
49 
50  void Unload(us::ModuleContext *) override
51  {
52  for (unsigned int loop(0); loop < m_MimeTypes.size(); ++loop)
53  {
54  delete m_MimeTypes.at(loop);
55  }
56 
57  delete m_ExampleDataStructureReaderService;
58 
59  delete m_ExampleDataStructureWriterService;
60  }
61 
62  private:
63  ExampleDataStructureReaderService *m_ExampleDataStructureReaderService;
64 
65  ExampleDataStructureWriterService *m_ExampleDataStructureWriterService;
66 
67  std::vector<mitk::CustomMimeType *> m_MimeTypes;
68  };
69 }
70 
71 US_EXPORT_MODULE_ACTIVATOR(mitk::NewModuleIOActivator)
US_Core_EXPORT const std::string & SERVICE_RANKING()
DataCollection - Class to facilitate loading/accessing structured data.
virtual void Unload(ModuleContext *context)=0
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
static std::vector< CustomMimeType * > Get()
#define US_EXPORT_MODULE_ACTIVATOR(_activator_type)
Export a module activator class.
virtual void Load(ModuleContext *context)=0