summaryrefslogtreecommitdiff
path: root/src/CommonAPI/DBus/DBusAddress.cpp
blob: f317e5733b4f42798e00b4a7fbf5459580a46234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <algorithm>

#include <CommonAPI/DBus/DBusAddress.hpp>

namespace CommonAPI {
namespace DBus {

DBusAddress::DBusAddress(const std::string &_service,
						 const std::string &_objectPath,
						 const std::string &_interface)
	: service_(_service),
	  objectPath_(_objectPath),
	  interface_(_interface) {
}

DBusAddress::DBusAddress(const DBusAddress &_source)
	: service_(_source.service_),
	  objectPath_(_source.objectPath_),
	  interface_(_source.interface_) {
}

DBusAddress::~DBusAddress() {
}

bool
DBusAddress::operator==(const DBusAddress &_other) const {
	return (service_ == _other.service_ &&
			objectPath_ == _other.objectPath_ &&
			interface_ == _other.interface_);
}

bool
DBusAddress::operator !=(const DBusAddress &_other) const {
	return (service_ != _other.service_ ||
			objectPath_ != _other.objectPath_ ||
			interface_ != _other.interface_);
}

bool
DBusAddress::operator<(const DBusAddress &_other) const {
	if (service_ < _other.service_)
		return true;

	if (service_ == _other.service_) {
		if (objectPath_ < _other.objectPath_)
			return true;

		if (objectPath_ == _other.objectPath_) {
			if (interface_ < _other.interface_)
				return true;
		}
	}

	return false;
}

const std::string &
DBusAddress::getService() const {
	return service_;
}

void
DBusAddress::setService(const std::string &_service) {
	service_ = _service;
}

const std::string &
DBusAddress::getObjectPath() const {
	return objectPath_;
}

void
DBusAddress::setObjectPath(const std::string &_objectPath) {
	objectPath_ = _objectPath;
}

const std::string &
DBusAddress::getInterface() const {
	return interface_;
}

void
DBusAddress::setInterface(const std::string &_interface) {
	interface_ = _interface;
}

std::ostream &
operator<<(std::ostream &_out, const DBusAddress &_dbusAddress) {
	_out << "service=" << _dbusAddress.service_.c_str()
		<< ":path=" << _dbusAddress.objectPath_.c_str()
		<< ":interface=" << _dbusAddress.interface_.c_str();
	return _out;
}


} // namespace DBus
} // namespace CommonAPI