ICF 3.0.5.47
Technical documentation of ICF Libraries
CComponentAddress.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QByteArray>
11
12// ICF includes
13#include <iser/ISerializable.h>
14
15
16namespace icomp
17{
18
19
25{
26public:
28 CComponentAddress(const QByteArray& packageId, const QByteArray& componentId);
29
33 bool IsValid() const;
34
35 const QByteArray& GetPackageId() const;
36 void SetPackageId(const QByteArray& id);
37
38 const QByteArray& GetComponentId() const;
39 void SetComponentId(const QByteArray& id);
40
41 QString ToString() const;
42 bool FromString(const QString& address);
43
44 bool operator==(const CComponentAddress& address) const;
45 bool operator!=(const CComponentAddress& address) const;
46 bool operator<(const CComponentAddress& address) const;
47
48 // reimplemented (iser::ISerializable)
49 virtual bool Serialize(iser::IArchive& archive);
50
51 friend size_t qHash(const CComponentAddress& address, size_t seed);
52
53private:
54 QByteArray m_packageId;
55 QByteArray m_componentId;
56};
57
58
59// inline methods
60
61inline const QByteArray& CComponentAddress::GetPackageId() const
62{
63 return m_packageId;
64}
65
66
67inline void CComponentAddress::SetPackageId(const QByteArray& id)
68{
69 m_packageId = id;
70}
71
72
73inline const QByteArray& CComponentAddress::GetComponentId() const
74{
75 return m_componentId;
76}
77
78
79inline void CComponentAddress::SetComponentId(const QByteArray& id)
80{
81 m_componentId = id;
82}
83
84
85inline bool CComponentAddress::operator==(const CComponentAddress& address) const
86{
87 return ((m_packageId == address.m_packageId) && (m_componentId == address.m_componentId));
88}
89
90
91inline bool CComponentAddress::operator!=(const CComponentAddress& address) const
92{
93 return ((m_packageId != address.m_packageId) || (m_componentId != address.m_componentId));
94}
95
96
97inline bool CComponentAddress::operator<(const CComponentAddress& address) const
98{
99 if (m_packageId == address.m_packageId){
100 return m_componentId < address.m_componentId;
101 }
102
103 return m_packageId < address.m_packageId;
104}
105
106
107// related global functions
108
109inline size_t qHash(const CComponentAddress& address, size_t seed = 0)
110{
111 return qHash(address.m_packageId, seed) + qHash(address.m_packageId);
112}
113
114
115} // namespace icomp
116
117
Represents global address of component.
bool FromString(const QString &address)
bool operator==(const CComponentAddress &address) const
bool IsValid() const
Check if this address is valid.
const QByteArray & GetComponentId() const
QString ToString() const
void SetComponentId(const QByteArray &id)
const QByteArray & GetPackageId() const
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
bool operator!=(const CComponentAddress &address) const
bool operator<(const CComponentAddress &address) const
friend size_t qHash(const CComponentAddress &address, size_t seed)
CComponentAddress(const QByteArray &packageId, const QByteArray &componentId)
void SetPackageId(const QByteArray &id)
Represent input/output persistence archive.
Definition IArchive.h:33
Common class for all classes which objects can be archived or restored from archive.
Package with interfaces and class used for components concept.
size_t qHash(const CComponentAddress &address, size_t seed=0)

© Witold Gantzke and Kirill Lepskiy