Medical Imaging Interaction Toolkit  2024.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
berryIAdaptable.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 
13 #ifndef _BERRY_IADAPTABLE_H_
14 #define _BERRY_IADAPTABLE_H_
15 
17 
18 #include <berryObject.h>
19 
20 #include <berryLog.h>
21 
22 #include <typeinfo>
23 
24 namespace berry {
25 
51 {
52 
53 public:
54 
65  virtual Object* GetAdapter(const QString& adapterType) const = 0;
66 
67  template<class A>
69  {
70  const char* typeName = qobject_interface_iid<A*>();
71  if (typeName == nullptr)
72  {
73  BERRY_WARN << "Error getting adapter for '" << Reflection::DemangleName(typeid(*this).name()) << "': "
74  << "Cannot get the interface id for type '" << Reflection::GetClassName<A>()
75  << "'. It is probably missing a Q_DECLARE_INTERFACE macro in its header.";
76  return nullptr;
77  }
78  return dynamic_cast<A*>(this->GetAdapter(typeName));
79  }
80 
81  virtual ~IAdaptable();
82 
83 };
84 
85 } // namespace berry
86 
87 #endif /*_BERRY_IADAPTABLE_H_*/
org_blueberry_core_runtime_Export.h
berry::Reflection::DemangleName
org_blueberry_core_runtime_EXPORT QString DemangleName(const char *typeName)
berryLog.h
berry::Object
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
BERRY_WARN
#define BERRY_WARN
Definition: berryLog.h:21
org_blueberry_core_runtime_EXPORT
#define org_blueberry_core_runtime_EXPORT
Definition: org_blueberry_core_runtime_Export.h:26
berry::IAdaptable
Definition: berryIAdaptable.h:50
berry::IAdaptable::GetAdapter
A * GetAdapter()
Definition: berryIAdaptable.h:68
berryObject.h
berry
Definition: QmitkPropertyItemModel.h:24