Medical Imaging Interaction Toolkit  2016.11.0
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 BlueBerry Platform
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 
17 #ifndef _BERRY_IADAPTABLE_H_
18 #define _BERRY_IADAPTABLE_H_
19 
21 
22 #include <berryObject.h>
23 
24 #include <berryLog.h>
25 
26 #include <typeinfo>
27 
28 namespace berry {
29 
55 {
56 
57 public:
58 
69  virtual Object* GetAdapter(const QString& adapterType) const = 0;
70 
71  template<class A>
73  {
74  const char* typeName = qobject_interface_iid<A*>();
75  if (typeName == nullptr)
76  {
77  BERRY_WARN << "Error getting adapter for '" << Reflection::DemangleName(typeid(*this).name()) << "': "
78  << "Cannot get the interface id for type '" << Reflection::GetClassName<A>()
79  << "'. It is probably missing a Q_DECLARE_INTERFACE macro in its header.";
80  return nullptr;
81  }
82  return dynamic_cast<A*>(this->GetAdapter(typeName));
83  }
84 
85  virtual ~IAdaptable();
86 
87 };
88 
89 } // namespace berry
90 
91 #endif /*_BERRY_IADAPTABLE_H_*/
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
QString DemangleName(const char *mangledName)
#define org_blueberry_core_runtime_EXPORT
#define BERRY_WARN
Definition: berryLog.h:25