Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryHandleObject.cpp
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 #include "berryHandleObject.h"
18 #include <typeinfo>
19 
20 namespace berry
21 {
22 
23 const uint HandleObject::HASH_CODE_NOT_COMPUTED = 0;
24 const uint HandleObject::HASH_FACTOR = 89;
25 const uint HandleObject::HASH_INITIAL = qHash(HandleObject::GetStaticClassName());
26 
27 HandleObject::HandleObject(const QString& ID) :
28  hashCode(HASH_CODE_NOT_COMPUTED), defined(false), id(ID)
29 {
30 }
31 
32 bool HandleObject::operator==(const Object* object) const
33 {
34  // Check if they're the same.
35  if (object == this)
36  {
37  return true;
38  }
39 
40  // Check if they're the same type.
41  if (const Self* o = dynamic_cast<const Self*>(object))
42  {
43  // Check each property in turn.
44  return (id == o->id);
45  }
46 
47  return false;
48 }
49 
50 QString HandleObject::GetId() const
51 {
52  return id;
53 }
54 
56 {
57  return defined;
58 }
59 
60 }
bool operator==(const Object *object) const override
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
QString GetId() const
static const char * GetStaticClassName()
Definition: berryObject.cpp:70
const std::string ID
unsigned int uint
HandleObject(const QString &id)
uint qHash(const berry::Object &o)