Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
berryPlatform.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 
13 
14 #include "berryPlatform.h"
15 
16 #include <berryIProduct.h>
17 
18 #include "internal/berryInternalPlatform.h"
19 #include "internal/berryIRuntimeConstants.h"
20 
21 #include <service/datalocation/ctkLocation.h>
22 
23 namespace berry {
24 
25 const QString Platform::PI_RUNTIME = IRuntimeConstants::PI_RUNTIME();
26 
28 const int Platform::OS_AIX = BERRY_OS_AIX;
37 const int Platform::OS_QNX = BERRY_OS_QNX;
43 const int Platform::OS_VMS = BERRY_OS_VMS;
44 
55 
56 const QString Platform::PROP_QTPLUGIN_PATH = "BlueBerry.qtplugin_path";
57 
58 const QString Platform::PROP_NEWINSTANCE = "BlueBerry.newInstance";
59 const QString Platform::PROP_APPLICATION = "BlueBerry.application";
60 const QString Platform::PROP_PLUGIN_DIRS = "BlueBerry.plugin_dirs";
61 const QString Platform::PROP_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins";
62 
63 const QString Platform::PROP_TESTPLUGIN = "BlueBerry.testplugin";
64 const QString Platform::PROP_TESTAPPLICATION = "BlueBerry.testapplication";
65 
66 const QString Platform::PROP_IGNOREAPP = "BlueBerry.ignoreApp";
67 
68 const QString Platform::PROP_XARGS = "xargs";
69 
70 
72 {
73  ctkLocation* location = GetConfigurationLocation();
74  if (location)
75  {
76  return location->getUrl().toLocalFile();
77  }
78  return QDir();
79 }
80 
82 {
83  return InternalPlatform::GetInstance()->GetConfigurationLocation();
84 }
85 
87 {
88  return InternalPlatform::GetInstance()->GetAdapterManager();
89 }
90 
92 {
93  return InternalPlatform::GetInstance()->GetExtensionRegistry();
94 }
95 
97 {
98  return InternalPlatform::GetInstance()->GetPreferencesService();
99 }
100 
101 //PlatformEvents& Platform::GetEvents()
102 //{
103 // return InternalPlatform::GetInstance()->GetEvents();
104 //}
105 
107 {
108  ctkLocation* location = GetInstallLocation();
109  if (location)
110  {
111  return location->getUrl().toLocalFile();
112  }
113  return QDir();
114 }
115 
117 {
118  return InternalPlatform::GetInstance()->GetInstallLocation();
119 }
120 
122 {
123  ctkLocation* location = GetInstanceLocation();
124  if (location)
125  {
126  return location->getUrl().toLocalFile();
127  }
128  return QDir();
129 
130 }
131 
133 {
134  return InternalPlatform::GetInstance()->GetInstanceLocation();
135 }
136 
138 {
139  return BERRY_OS;
140 }
141 
143 {
144  return BERRY_ARCH;
145 }
146 
148 {
149 #ifdef BERRY_OS_FAMILY_UNIX
150  return true;
151 #else
152  return false;
153 #endif
154 }
155 
157 {
158 #ifdef BERRY_OS_FAMILY_WINDOWS
159  return true;
160 #else
161  return false;
162 #endif
163 }
164 
166 {
167 #ifdef BERRY_OS_FAMILY_BSD
168  return true;
169 #else
170  return false;
171 #endif
172 }
173 
175 {
176 #ifdef BERRY_OS_FAMILY_LINUX
177  return true;
178 #else
179  return false;
180 #endif
181 }
182 
184 {
185 #ifdef BERRY_OS_FAMILY_VMS
186  return true;
187 #else
188  return false;
189 #endif
190 }
191 
192 bool Platform::GetStatePath(QDir& statePath, const QSharedPointer<ctkPlugin>& plugin, bool /*create*/)
193 {
194  statePath = GetStateLocation(plugin);
195  return true;
196 }
197 
199 {
200  return InternalPlatform::GetInstance()->GetStateLocation(plugin);
201 }
202 
204 {
205  ctkLocation* location = GetUserLocation();
206  if (location)
207  {
208  return location->getUrl().toLocalFile();
209  }
210  return QDir();
211 
212 }
213 
215 {
216  return InternalPlatform::GetInstance()->GetUserLocation();
217 }
218 
220 {
221  return InternalPlatform::GetInstance()->IsRunning();
222 }
223 
225 {
226  return InternalPlatform::GetInstance()->GetApplicationArgs();
227 }
228 
229 QSharedPointer<ctkPlugin> Platform::GetPlugin(const QString& symbolicName)
230 {
231  return InternalPlatform::GetInstance()->GetPlugin(symbolicName);
232 }
233 
234 QList<QSharedPointer<ctkPlugin> > Platform::GetPlugins(const QString& symbolicName,
235  const QString& version)
236 {
237  return InternalPlatform::GetInstance()->GetPlugins(symbolicName, version);
238 }
239 
240 QVariant berry::Platform::GetDebugOption(const QString& option)
241 {
242  return InternalPlatform::GetInstance()->GetOption(option);
243 }
244 
246 {
247  return InternalPlatform::GetInstance()->GetProduct();
248 }
249 
250 }
static QT_DEPRECATED QDir GetInstancePath()
static const int OS_IRIX
static QStringList GetApplicationArgs()
static const int OS_UNKNOWN_UNIX
#define BERRY_ARCH_IA32
Definition: berryPlatform.h:98
static const int ARCH_PPC
static QT_DEPRECATED QDir GetInstallPath()
static const int OS_VMS
static QT_DEPRECATED bool GetStatePath(QDir &statePath, const QSharedPointer< ctkPlugin > &plugin, bool create=true)
static const int OS_LINUX
static const int OS_FREE_BSD
static QDir GetStateLocation(const QSharedPointer< ctkPlugin > &plugin)
#define BERRY_ARCH_SPARC
#define BERRY_ARCH_PPC
static const QString PROP_NEWINSTANCE
static const int ARCH_MIPS
#define BERRY_OS_MAC_OS_X
Definition: berryPlatform.h:25
static ctkLocation * GetInstallLocation()
static bool IsUnix()
static const int OS_VXWORKS
static const QString PROP_TESTAPPLICATION
#define BERRY_OS_SOLARIS
Definition: berryPlatform.h:29
static bool IsBSD()
static bool IsWindows()
static QList< QSharedPointer< ctkPlugin > > GetPlugins(const QString &symbolicName, const QString &version=QString())
#define BERRY_ARCH_ALPHA
Definition: berryPlatform.h:97
#define BERRY_OS_UNKNOWN_UNIX
Definition: berryPlatform.h:33
static const int OS_AIX
static const int OS_HPUX
#define BERRY_OS_AIX
Definition: berryPlatform.h:21
#define BERRY_ARCH_IA64
Definition: berryPlatform.h:99
#define BERRY_OS_NET_BSD
Definition: berryPlatform.h:26
#define BERRY_OS_TRU64
Definition: berryPlatform.h:23
static const int OS_MAC_OS_X
static const QString PROP_TESTPLUGIN
#define BERRY_ARCH_MIPS
#define BERRY_OS_QNX
Definition: berryPlatform.h:30
#define BERRY_OS_VMS
Definition: berryPlatform.h:36
static ctkLocation * GetInstanceLocation()
static ctkLocation * GetUserLocation()
static const int ARCH_SPARC
#define BERRY_OS_VXWORKS
Definition: berryPlatform.h:31
static bool IsRunning()
static const int OS_WINDOWS_CE
static QT_DEPRECATED QDir GetUserPath()
static const int OS_OPEN_BSD
static IAdapterManager * GetAdapterManager()
static IExtensionRegistry * GetExtensionRegistry()
static const int ARCH_ALPHA
#define BERRY_OS_WINDOWS_NT
Definition: berryPlatform.h:34
#define BERRY_OS_LINUX
Definition: berryPlatform.h:24
#define BERRY_OS_HPUX
Definition: berryPlatform.h:22
#define BERRY_OS_CYGWIN
Definition: berryPlatform.h:32
static int GetOS()
static const QString PROP_APPLICATION
static const QString PI_RUNTIME
static SmartPointer< IProduct > GetProduct()
static const QString PROP_IGNOREAPP
static QSharedPointer< ctkPlugin > GetPlugin(const QString &symbolicName)
static bool IsLinux()
static const int ARCH_HPPA
static const int OS_QNX
static const QString PROP_PLUGIN_DIRS
static const QString PROP_FORCE_PLUGIN_INSTALL
static const int ARCH_IA64
static const int OS_NET_BSD
static ctkLocation * GetConfigurationLocation()
#define BERRY_OS_WINDOWS_CE
Definition: berryPlatform.h:35
static const QString PROP_XARGS
#define BERRY_ARCH_POWER
static const int OS_CYGWIN
#define BERRY_OS_FREE_BSD
Definition: berryPlatform.h:20
static QT_DEPRECATED QDir GetConfigurationPath()
static const QString PROP_QTPLUGIN_PATH
static const int ARCH_ARM
static const int ARCH_POWER
static const int OS_WINDOWS_NT
#define BERRY_ARCH_ARM
static bool IsVMS()
static const int ARCH_AMD64
#define BERRY_OS_IRIX
Definition: berryPlatform.h:28
static const int OS_TRU64
#define BERRY_OS_OPEN_BSD
Definition: berryPlatform.h:27
#define BERRY_ARCH_HPPA
static QVariant GetDebugOption(const QString &option)
#define BERRY_ARCH_AMD64
static const int OS_SOLARIS
static int GetOSArch()
static IPreferencesService * GetPreferencesService()
static const int ARCH_IA32