Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #include <usModuleActivator.h>
17 #include <usModuleContext.h>
18 
20 
22 
23 #include "mitkExampleIOMimeTypes.h"
24 
25 namespace mitk
26 {
30  class NewModuleIOActivator : public us::ModuleActivator
31  {
32  public:
33  void Load(us::ModuleContext *context) override
34  {
35  // We can register our read/write services with a custom service ranking
36  // services with a higher ranking are prioritized, default us 0
39 
40  m_MimeTypes = mitk::ExampleIOMimeTypes::Get();
41  for (std::vector<mitk::CustomMimeType *>::const_iterator mimeTypeIter = m_MimeTypes.begin(),
42  iterEnd = m_MimeTypes.end();
43  mimeTypeIter != iterEnd;
44  ++mimeTypeIter)
45  {
46  context->RegisterService(*mimeTypeIter, props);
47  }
48 
49  m_ExampleDataStructureReaderService = new ExampleDataStructureReaderService();
50 
51  m_ExampleDataStructureWriterService = new ExampleDataStructureWriterService();
52  }
53 
54  void Unload(us::ModuleContext *) override
55  {
56  for (unsigned int loop(0); loop < m_MimeTypes.size(); ++loop)
57  {
58  delete m_MimeTypes.at(loop);
59  }
60 
61  delete m_ExampleDataStructureReaderService;
62 
63  delete m_ExampleDataStructureWriterService;
64  }
65 
66  private:
67  ExampleDataStructureReaderService *m_ExampleDataStructureReaderService;
68 
69  ExampleDataStructureWriterService *m_ExampleDataStructureWriterService;
70 
71  std::vector<mitk::CustomMimeType *> m_MimeTypes;
72  };
73 }
74 
75 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()
virtual void Load(ModuleContext *context)=0
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)