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
berryQualifiedName.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 "berryQualifiedName.h"
18 
19 #include <berryObject.h>
20 
21 #include <Poco/Bugcheck.h>
22 #include <Poco/Hash.h>
23 
24 #include <string>
25 #include <sstream>
26 
27 namespace berry
28 {
29 
30 QualifiedName::QualifiedName(std::string qualifier, std::string localName)
31 {
32  poco_assert(!localName.empty());
33  this->qualifier = qualifier;
34  this->localName = localName;
35 }
36 
37 bool
39 ::operator==(const QualifiedName& qName) const
40 {
41  if (this == &qName) return true;
42 
43  return qualifier == qName.GetQualifier() && localName == qName.GetLocalName();
44 }
45 
46 bool
48 ::operator<(const QualifiedName& qName) const
49 {
50  return qualifier < qName.GetQualifier() ? true : (qualifier == qName.GetQualifier() ? localName < qName.GetLocalName() : false);
51 }
52 
53 std::string
56 {
57  return localName;
58 }
59 
60 std::string
63 {
64  return qualifier;
65 }
66 
67 std::size_t
69 ::HashCode() const
70 {
71  return (qualifier.empty() ? 0 : (Poco::Hash<std::string >().operator()(qualifier) + Poco::Hash<std::string>().operator()(localName)));
72 }
73 
74 std::string
77 {
78  std::string temp = ( GetQualifier().empty() ? "" : GetQualifier() + ':');
79  std::stringstream ss;
80  ss << temp << GetLocalName();
81  return ss.str();
82 }
83 
84 }
QualifiedName(std::string qualifier, std::string localName)
bool operator==(const QualifiedName &qName) const
std::string GetLocalName() const
std::vcl_size_t HashCode() const
std::string GetQualifier() const
bool operator<(const QualifiedName &qName) const