Home · All Classes · All Namespaces · Modules · Functions · Files
referenced-handles.h
1 
23 #ifndef _TelepathyQt_referenced_handles_h_HEADER_GUARD_
24 #define _TelepathyQt_referenced_handles_h_HEADER_GUARD_
25 
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29 
30 #include <TelepathyQt/Constants>
31 #include <TelepathyQt/Types>
32 
33 #ifndef QT_NO_STL
34 # include <list>
35 #endif
36 
37 #include <QList>
38 #include <QSet>
39 #include <QSharedDataPointer>
40 #include <QVector>
41 
42 namespace Tp
43 {
44 
45 class Connection;
46 
47 class TP_QT_EXPORT ReferencedHandles
48 {
49 public:
50  typedef UIntList::const_iterator const_iterator;
51  typedef UIntList::ConstIterator ConstIterator;
52  typedef UIntList::const_pointer const_pointer;
53  typedef UIntList::const_reference const_reference;
54  typedef UIntList::difference_type difference_type;
55  typedef UIntList::pointer pointer;
56  typedef UIntList::reference reference;
57  typedef UIntList::size_type size_type;
58  typedef UIntList::value_type value_type;
59 
63 
64  ConnectionPtr connection() const;
65  HandleType handleType() const;
66 
67  uint at(int i) const;
68 
69  inline uint back() const
70  {
71  return last();
72  }
73 
74  inline uint first() const
75  {
76  return at(0);
77  }
78 
79  inline uint front() const
80  {
81  return first();
82  }
83 
84  inline uint last() const
85  {
86  return at(size() - 1);
87  }
88 
89  uint value(int i, uint defaultValue = 0) const;
90 
91  const_iterator begin() const;
92 
93  inline const_iterator constBegin() const
94  {
95  return begin();
96  }
97 
98  inline const_iterator constEnd() const
99  {
100  return end();
101  }
102 
103  const_iterator end() const;
104 
105  bool contains(uint handle) const;
106 
107  int count(uint handle) const;
108 
109  inline int count() const
110  {
111  return size();
112  }
113 
114  inline bool empty() const
115  {
116  return isEmpty();
117  }
118 
119  inline bool endsWith(uint handle) const
120  {
121  return !isEmpty() && last() == handle;
122  }
123 
124  int indexOf(uint handle, int from = 0) const;
125 
126  bool isEmpty() const;
127 
128  int lastIndexOf(uint handle, int from = -1) const;
129 
130  inline int length() const
131  {
132  return count();
133  }
134 
135  ReferencedHandles mid(int pos, int length = -1) const;
136 
137  int size() const;
138 
139  inline bool startsWith(uint handle) const
140  {
141  return !isEmpty() && first() == handle;
142  }
143 
144  inline void append(const ReferencedHandles& another)
145  {
146  *this = *this + another;
147  }
148 
149  void clear();
150  void move(int from, int to);
151 
152  inline void pop_back()
153  {
154  return removeLast();
155  }
156 
157  inline void pop_front()
158  {
159  return removeFirst();
160  }
161 
162  int removeAll(uint handle);
163 
164  void removeAt(int i);
165 
166  inline void removeFirst()
167  {
168  return removeAt(0);
169  }
170 
171  inline void removeLast()
172  {
173  return removeAt(size() - 1);
174  }
175 
176  bool removeOne(uint handle);
177 
178  void swap(int i, int j);
179 
180  uint takeAt(int i);
181 
182  inline uint takeFirst()
183  {
184  return takeAt(0);
185  }
186 
187  inline uint takeLast()
188  {
189  return takeAt(size() - 1);
190  }
191 
192  bool operator!=(const ReferencedHandles& another) const
193  {
194  return !(*this == another);
195  }
196 
197  bool operator!=(const UIntList& another) const
198  {
199  return !(*this == another);
200  }
201 
202  ReferencedHandles operator+(const ReferencedHandles& another) const;
203 
205  {
206  return *this = (*this + another);
207  }
208 
210  {
211  return *this += another;
212  }
213 
214  ReferencedHandles& operator=(const ReferencedHandles& another);
215 
216  bool operator==(const ReferencedHandles& another) const;
217  bool operator==(const UIntList& list) const;
218 
219  inline uint operator[](int i) const
220  {
221  return at(i);
222  }
223 
224  UIntList toList() const;
225 
226  inline QSet<uint> toSet() const
227  {
228  return toList().toSet();
229  }
230 
231 #ifndef QT_NO_STL
232  inline std::list<uint> toStdList() const
233  {
234  return toList().toStdList();
235  }
236 #endif
237 
238  inline QVector<uint> toVector() const
239  {
240  return toList().toVector();
241  }
242 
243 private:
244  // For access to the "prime" constructor
245  friend class ContactManager;
247  friend class PendingContacts;
248  friend class PendingHandles;
249 
250  TP_QT_NO_EXPORT ReferencedHandles(const ConnectionPtr &connection,
251  HandleType handleType, const UIntList& handles);
252 
253  struct Private;
254  friend struct Private;
255  QSharedDataPointer<Private> mPriv;
256 };
257 
258 typedef QListIterator<uint> ReferencedHandlesIterator;
259 
260 } // Tp
261 
262 Q_DECLARE_METATYPE(Tp::ReferencedHandles);
263 
264 #endif
uint operator[](int i) const
Definition: referenced-handles.h:219
bool operator!=(const ReferencedHandles &another) const
Definition: referenced-handles.h:192
int length() const
Definition: referenced-handles.h:130
ReferencedHandles & operator<<(const ReferencedHandles &another)
Definition: referenced-handles.h:209
uint takeLast()
Definition: referenced-handles.h:187
const_iterator constEnd() const
Definition: referenced-handles.h:98
bool operator!=(const UIntList &another) const
Definition: referenced-handles.h:197
UIntList::value_type value_type
Definition: referenced-handles.h:58
The PendingContactAttributes class represents the parameters of and the reply to an asynchronous requ...
Definition: pending-contact-attributes.h:40
The ContactManager class is responsible for managing contacts.
Definition: contact-manager.h:50
UIntList::const_pointer const_pointer
Definition: referenced-handles.h:52
bool startsWith(uint handle) const
Definition: referenced-handles.h:139
The PendingHandles class represents the parameters of and the reply to an asynchronous handle request...
Definition: pending-handles.h:46
UIntList::const_iterator const_iterator
Definition: referenced-handles.h:50
QVector< uint > toVector() const
Definition: referenced-handles.h:238
UIntList::const_reference const_reference
Definition: referenced-handles.h:53
std::list< uint > toStdList() const
Definition: referenced-handles.h:232
bool empty() const
Definition: referenced-handles.h:114
uint first() const
Definition: referenced-handles.h:74
bool operator==(const SUSocketAddress &v1, const SUSocketAddress &v2)
Definition: types.cpp:50
UIntList::difference_type difference_type
Definition: referenced-handles.h:54
uint front() const
Definition: referenced-handles.h:79
bool endsWith(uint handle) const
Definition: referenced-handles.h:119
uint takeFirst()
Definition: referenced-handles.h:182
int count() const
Definition: referenced-handles.h:109
UIntList::pointer pointer
Definition: referenced-handles.h:55
uint last() const
Definition: referenced-handles.h:84
The PendingContacts class is used by ContactManager when creating/updating Contact objects...
Definition: pending-contacts.h:46
void append(const ReferencedHandles &another)
Definition: referenced-handles.h:144
UIntList::reference reference
Definition: referenced-handles.h:56
UIntList::size_type size_type
Definition: referenced-handles.h:57
QSet< uint > toSet() const
Definition: referenced-handles.h:226
Definition: build/TelepathyQt/_gen/types.h:107
QListIterator< uint > ReferencedHandlesIterator
Definition: referenced-handles.h:258
void pop_front()
Definition: referenced-handles.h:157
Helper container for safe management of handle lifetimes. Every handle in a ReferencedHandles contain...
Definition: referenced-handles.h:47
void removeLast()
Definition: referenced-handles.h:171
void pop_back()
Definition: referenced-handles.h:152
HandleType
Definition: build/TelepathyQt/_gen/constants.h:1375
Definition: abstract-adaptor.cpp:31
ReferencedHandles & operator+=(const ReferencedHandles &another)
Definition: referenced-handles.h:204
UIntList::ConstIterator ConstIterator
Definition: referenced-handles.h:51
void removeFirst()
Definition: referenced-handles.h:166
const_iterator constBegin() const
Definition: referenced-handles.h:93
uint back() const
Definition: referenced-handles.h:69


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.7