Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
berryQualifiedName.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 "berryQualifiedName.h"
14 
15 #include <berryObject.h>
16 
17 #include <Poco/Bugcheck.h>
18 #include <Poco/Hash.h>
19 
20 #include <string>
21 #include <sstream>
22 
23 namespace berry
24 {
25 
26 QualifiedName::QualifiedName(std::string qualifier, std::string localName)
27 {
28  poco_assert(!localName.empty());
29  this->qualifier = qualifier;
30  this->localName = localName;
31 }
32 
33 bool
35 ::operator==(const QualifiedName& qName) const
36 {
37  if (this == &qName) return true;
38 
39  return qualifier == qName.GetQualifier() && localName == qName.GetLocalName();
40 }
41 
42 bool
44 ::operator<(const QualifiedName& qName) const
45 {
46  return qualifier < qName.GetQualifier() ? true : (qualifier == qName.GetQualifier() ? localName < qName.GetLocalName() : false);
47 }
48 
49 std::string
52 {
53  return localName;
54 }
55 
56 std::string
59 {
60  return qualifier;
61 }
62 
63 std::size_t
65 ::HashCode() const
66 {
67  return (qualifier.empty() ? 0 : (Poco::Hash<std::string >().operator()(qualifier) + Poco::Hash<std::string>().operator()(localName)));
68 }
69 
70 std::string
73 {
74  std::string temp = ( GetQualifier().empty() ? "" : GetQualifier() + ':');
75  std::stringstream ss;
76  ss << temp << GetLocalName();
77  return ss.str();
78 }
79 
80 }
bool operator<(const QualifiedName &qName) const
QualifiedName(std::string qualifier, std::string localName)
std::string GetLocalName() const
std::string GetQualifier() const
std::vcl_size_t HashCode() const
bool operator==(const QualifiedName &qName) const