Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryContributorFactory.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 
14 
15 #include "internal/berryRegistryContributor.h"
16 #include "internal/berryCTKPluginUtils.h"
17 
18 #include <ctkPlugin.h>
19 
20 namespace berry {
21 
23 {
24  QString id = QString::number(contributor->getPluginId());
25  QString name = contributor->getSymbolicName();
26  QString hostId;
27  QString hostName;
28 
29 // // determine host properties, if any
30 // if (OSGIUtils.getDefault().isFragment(contributor)) {
31 // Bundle[] hosts = OSGIUtils.getDefault().getHosts(contributor);
32 // if (hosts != null) {
33 // Bundle hostBundle = hosts[0];
34 // hostId = Long.toString(hostBundle.getBundleId());
35 // hostName = hostBundle.getSymbolicName();
36 // }
37 // }
38 
39  IContributor::Pointer result(new RegistryContributor(id, name, hostId, hostName));
40  return result;
41 }
42 
44 {
45  if (contributor.IsNull())
47 
48  if (RegistryContributor::Pointer regContributor = contributor.Cast<RegistryContributor>())
49  {
50  QString symbolicName = regContributor->GetActualName();
51  return CTKPluginUtils::GetDefault()->GetPlugin(symbolicName);
52  }
54 }
55 
56 }
SmartPointer< Other > Cast() const
static SmartPointer< IContributor > CreateContributor(const QSharedPointer< ctkPlugin > &contributor)
static QSharedPointer< ctkPlugin > Resolve(const SmartPointer< IContributor > &contributor)