CComponentAddress.h
Go to the documentation of this file.
1 #ifndef icomp_CComponentAddress_included
2 #define icomp_CComponentAddress_included
3 
4 
5 // Qt includes
6 #include <QtCore/QByteArray>
7 
8 // ACF includes
9 #include <iser/ISerializable.h>
10 
11 
12 namespace icomp
13 {
14 
15 
23 {
24 public:
26  CComponentAddress(const QByteArray& packageId, const QByteArray& componentId);
27 
31  bool IsValid() const;
32 
33  const QByteArray& GetPackageId() const;
34  void SetPackageId(const QByteArray& id);
35 
36  const QByteArray& GetComponentId() const;
37  void SetComponentId(const QByteArray& id);
38 
39  QString ToString() const;
40  bool FromString(const QString& address);
41 
42  bool operator==(const CComponentAddress& address) const;
43  bool operator!=(const CComponentAddress& address) const;
44  bool operator<(const CComponentAddress& address) const;
45 
46  // reimplemented (iser::ISerializable)
47  virtual bool Serialize(iser::IArchive& archive);
48 
49  friend uint qHash(const CComponentAddress& address, uint seed);
50 
51 private:
52  QByteArray m_packageId;
53  QByteArray m_componentId;
54 };
55 
56 
57 // inline methods
58 
59 inline const QByteArray& CComponentAddress::GetPackageId() const
60 {
61  return m_packageId;
62 }
63 
64 
65 inline void CComponentAddress::SetPackageId(const QByteArray& id)
66 {
67  m_packageId = id;
68 }
69 
70 
71 inline const QByteArray& CComponentAddress::GetComponentId() const
72 {
73  return m_componentId;
74 }
75 
76 
77 inline void CComponentAddress::SetComponentId(const QByteArray& id)
78 {
79  m_componentId = id;
80 }
81 
82 
83 inline bool CComponentAddress::operator==(const CComponentAddress& address) const
84 {
85  return ((m_packageId == address.m_packageId) && (m_componentId == address.m_componentId));
86 }
87 
88 
89 inline bool CComponentAddress::operator!=(const CComponentAddress& address) const
90 {
91  return ((m_packageId != address.m_packageId) || (m_componentId != address.m_componentId));
92 }
93 
94 
95 inline bool CComponentAddress::operator<(const CComponentAddress& address) const
96 {
97  if (m_packageId == address.m_packageId){
98  return m_componentId < address.m_componentId;
99  }
100 
101  return m_packageId < address.m_packageId;
102 }
103 
104 
105 // related global functions
106 
107 inline uint qHash(const CComponentAddress& address, uint seed = 0)
108 {
109  Q_UNUSED(seed);
110 
111  return qHash(address.m_packageId) + qHash(address.m_packageId);
112 }
113 
114 
115 } // namespace icomp
116 
117 
118 #endif // !icomp_CComponentAddress_included
119 
120 
bool operator<(const CComponentAddress &address) const
Represents global address of component.
uint qHash(const CComponentAddress &address, uint seed=0)
bool IsValid() const
Check if this address is valid.
const QByteArray & GetPackageId() const
bool operator==(const CComponentAddress &address) const
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
Common class for all classes which objects can be archived or restored from archive.
Definition: ISerializable.h:23
bool operator!=(const CComponentAddress &address) const
Represent input/output persistence archive.
Definition: IArchive.h:30
bool FromString(const QString &address)
QString ToString() const
friend uint qHash(const CComponentAddress &address, uint seed)
const QByteArray & GetComponentId() const
void SetComponentId(const QByteArray &id)
void SetPackageId(const QByteArray &id)

© 2007-2017 Witold Gantzke and Kirill Lepskiy