Medical Imaging Interaction Toolkit  2018.4.99-6ca56567
Medical Imaging Interaction Toolkit
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_*/
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
QString DemangleName(const char *mangledName)
#define org_blueberry_core_runtime_EXPORT
#define BERRY_WARN
Definition: berryLog.h:21