Diana Software
QEventLabel.cc
Go to the documentation of this file.
1 #include "QEventLabel.hh"
2 
4 
5 QEventLabel::QEventLabel(const std::string& label)
6 {
7  Init(label);
8 }
9 
10 
11 QEventLabel::QEventLabel(const char* label)
12 {
13  Init(label);
14 }
15 
16 void QEventLabel::Init(const std::string& label)
17 {
18  const size_t und = label.find_first_of("@");
19  if(und != std::string::npos) {
20  owner = label.substr(0,und);
21  name = label.substr(und+1,std::string::npos);
22  } else {
23  owner = "";
24  name = label;
25  }
26 }
27 
28 const QEventLabel& QEventLabel::operator=(const std::string& label)
29 {
30  Init(label);
31  return *this;
32 }
33 
34 bool QEventLabel::operator<(const QEventLabel& other) const
35 {
36  if(owner < other.owner) return true;
37  if(other.owner < owner) return false;
38  return name < other.name;
39 }
40 
41 bool QEventLabel::operator==(const QEventLabel& other) const
42 {
43  if(owner == other.owner
44  && name == other.name) return true;
45  return false;
46 }
47 
48 std::string QEventLabel::GetStringLabel() const
49 {
50  std::string ret = owner;
51  ret += "@";
52  ret += name;
53  return ret;
54 }
55 
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
label for QObject in the QEvent
Definition: QEventLabel.hh:23
std::string GetStringLabel() const
get string in the format "owner@name"
Definition: QEventLabel.cc:48
bool operator<(const QEventLabel &other) const
less operator
Definition: QEventLabel.cc:34
QEventLabel()
default constructor
Definition: QEventLabel.hh:26
std::string owner
owner of the QObject
Definition: QEventLabel.hh:60
const QEventLabel & operator=(const std::string &label)
assignment operator
Definition: QEventLabel.cc:28
bool operator==(const QEventLabel &other) const
comparison operator
Definition: QEventLabel.cc:41
std::string name
name of the QObject
Definition: QEventLabel.hh:62
void Init(const std::string &)
function called in constructors
Definition: QEventLabel.cc:16