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