# DBus-C++

## Desktop Communication Bus System

libdbus-c-- Documentation 0.9.0

- Files
- Data Structures
- Globals
- Main Page

object.h
Go to the documentation of this file.
1/*
2 *
3 * D-Bus++ - C++ bindings for D-Bus
4 *
5 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
6 *
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24
25#ifndef __DBUSXX_OBJECT_H
26#define __DBUSXX_OBJECT_H
27
28#include <string>
29#include <list>
30
31#include "api.h"
32#include "interface.h"
33#include "connection.h"
34#include "message.h"
35#include "types.h"
36
37 namespace DBus
38{
39
40 class DXXAPI Object
41{
42 protected:
43
44 Object(Connection &conn, const Path &path, const char *service);
45
46 public:
47
48 virtual ~Object();
49
50 inline const DBus::Path &path() const;
51
52 inline const std::string &service() const;
53
54 inline Connection &conn();
55
56 void set_timeout(int new_timeout = -1);
57
58 inline int get_timeout() const;
59
60 private:
61
62 DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
63 DXXAPILOCAL virtual void register_obj() = 0;
64 DXXAPILOCAL virtual void unregister_obj(bool throw_on_error = true) = 0;
65
66 private:
67
68 Connection _conn;
69 DBus::Path _path;
70 std::string _service;
71 int _default_timeout;
72};
73
74/*
75*/
76
77 Connection &Object::conn()
78{
79 return _conn;
80}
81
82 const DBus::Path &Object::path() const
83{
84 return _path;
85}
86
87 const std::string &Object::service() const
88{
89 return _service;
90}
91
92 int Object::get_timeout() const
93{
94 return _default_timeout;
95}
96
97/*
98*/
99
100 class DXXAPI Tag
101{
102 public:
103
104 virtual ~Tag()
105 {}
106};
107
108/*
109*/
110
111 class ObjectAdaptor;
112
113 typedef std::list<ObjectAdaptor *> ObjectAdaptorPList;
114 typedef std::list<std::string> ObjectPathList;
115
116 class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase
117{
118 public:
119
120 static ObjectAdaptor *from_path(const Path &path);
121
122 static ObjectAdaptorPList from_path_prefix(const std::string &prefix);
123
124 static ObjectPathList child_nodes_from_prefix(const std::string &prefix);
125
126 struct Private;
127
128 ObjectAdaptor(Connection &conn, const Path &path);
129
130 ~ObjectAdaptor();
131
132 inline const ObjectAdaptor *object() const;
133
134 protected:
135
136 class DXXAPI Continuation
137 {
138 public:
139
140 inline MessageIter &writer();
141
142 inline Tag *tag();
143
144 private:
145
146 Continuation(Connection &conn, const CallMessage &call, const Tag *tag);
147
148 Connection _conn;
149 CallMessage _call;
150 MessageIter _writer;
151 ReturnMessage _return;
152 const Tag *_tag;
153
154 friend class ObjectAdaptor;
155 };
156
157 void return_later(const Tag *tag);
158
159 void return_now(Continuation *ret);
160
161 void return_error(Continuation *ret, const Error error);
162
163 Continuation *find_continuation(const Tag *tag);
164
165 private:
166
167 void _emit_signal(SignalMessage &);
168
169 bool handle_message(const Message &);
170
171 void register_obj();
172 void unregister_obj(bool throw_on_error = true);
173
174 typedef std::map<const Tag *, Continuation *> ContinuationMap;
175 ContinuationMap _continuations;
176
177 friend struct Private;
178};
179
180 const ObjectAdaptor *ObjectAdaptor::object() const
181{
182 return this;
183}
184
185 Tag *ObjectAdaptor::Continuation::tag()
186{
187 return const_cast<Tag *>(_tag);
188}
189
190 MessageIter &ObjectAdaptor::Continuation::writer()
191{
192 return _writer;
193}
194
195/*
196*/
197
198 class ObjectProxy;
199
200 typedef std::list<ObjectProxy *> ObjectProxyPList;
201
202 class DXXAPI ObjectProxy : public Object, public virtual ProxyBase
203{
204 public:
205
206 ObjectProxy(Connection &conn, const Path &path, const char *service = "");
207
208 ~ObjectProxy();
209
210 inline const ObjectProxy *object() const;
211
212 private:
213
214 Message _invoke_method(CallMessage &);
215
216 bool _invoke_method_noreply(CallMessage &call);
217
218 bool handle_message(const Message &);
219
220 void register_obj();
221 void unregister_obj(bool throw_on_error = true);
222
223 private:
224
225 MessageSlot _filtered;
226};
227
228 const ObjectProxy *ObjectProxy::object() const
229{
230 return this;
231}
232
233} /* namespace DBus */
234
235#endif//__DBUSXX_OBJECT_H
api.h
DXXAPILOCAL
#define DXXAPILOCAL
Definition api.h:32
DXXAPI
#define DXXAPI
Definition api.h:36
DBus::AdaptorBase
Definition interface.h:59
DBus::CallMessage
Definition message.h:269
DBus::Connection
Definition connection.h:49
DBus::Error
Definition error.h:40
DBus::MessageIter
Definition message.h:45
DBus::Message
Definition message.h:159
DBus::ObjectAdaptor::Continuation
Definition object.h:137
DBus::ObjectAdaptor::Continuation::_writer
MessageIter _writer
Definition object.h:150
DBus::ObjectAdaptor::Continuation::writer
MessageIter & writer()
Definition object.h:190
DBus::ObjectAdaptor::Continuation::_conn
Connection _conn
Definition object.h:148
DBus::ObjectAdaptor::Continuation::tag
Tag * tag()
Definition object.h:185
DBus::ObjectAdaptor::Continuation::ObjectAdaptor
friend class ObjectAdaptor
Definition object.h:154
DBus::ObjectAdaptor::Continuation::_return
ReturnMessage _return
Definition object.h:151
DBus::ObjectAdaptor::Continuation::Continuation
Continuation(Connection &conn, const CallMessage &call, const Tag *tag)
Definition object.cpp:281
DBus::ObjectAdaptor::Continuation::_tag
const Tag * _tag
Definition object.h:152
DBus::ObjectAdaptor::Continuation::_call
CallMessage _call
Definition object.h:149
DBus::ObjectAdaptor::from_path_prefix
static ObjectAdaptorPList from_path_prefix(const std::string &prefix)
Definition object.cpp:115
DBus::ObjectAdaptor::handle_message
bool handle_message(const Message &)
Definition object.cpp:203
DBus::ObjectAdaptor::child_nodes_from_prefix
static ObjectPathList child_nodes_from_prefix(const std::string &prefix)
Definition object.cpp:134
DBus::ObjectAdaptor::from_path
static ObjectAdaptor * from_path(const Path &path)
Definition object.cpp:105
DBus::ObjectAdaptor::register_obj
void register_obj()
Definition object.cpp:170
DBus::ObjectAdaptor::return_now
void return_now(Continuation *ret)
Definition object.cpp:252
DBus::ObjectAdaptor::unregister_obj
void unregister_obj(bool throw_on_error=true)
Definition object.cpp:182
DBus::ObjectAdaptor::_continuations
ContinuationMap _continuations
Definition object.h:175
DBus::ObjectAdaptor::return_later
void return_later(const Tag *tag)
Definition object.cpp:246
DBus::ObjectAdaptor::ContinuationMap
std::map< const Tag *, Continuation * > ContinuationMap
Definition object.h:174
DBus::ObjectAdaptor::find_continuation
Continuation * find_continuation(const Tag *tag)
Definition object.cpp:274
DBus::ObjectAdaptor::ObjectAdaptor
ObjectAdaptor(Connection &conn, const Path &path)
Definition object.cpp:159
DBus::ObjectAdaptor::_emit_signal
void _emit_signal(SignalMessage &)
Definition object.cpp:191
DBus::ObjectAdaptor::object
const ObjectAdaptor * object() const
Definition object.h:180
DBus::ObjectAdaptor::return_error
void return_error(Continuation *ret, const Error error)
Definition object.cpp:263
DBus::ObjectProxy
Definition object.h:203
DBus::ObjectProxy::object
const ObjectProxy * object() const
Definition object.h:228
DBus::ObjectProxy::_invoke_method_noreply
bool _invoke_method_noreply(CallMessage &call)
Definition object.cpp:343
DBus::ObjectProxy::_invoke_method
Message _invoke_method(CallMessage &)
Definition object.cpp:332
DBus::ObjectProxy::_filtered
MessageSlot _filtered
Definition object.h:225
DBus::ObjectProxy::handle_message
bool handle_message(const Message &)
Definition object.cpp:354
DBus::ObjectProxy::ObjectProxy
ObjectProxy(Connection &conn, const Path &path, const char *service="")
Definition object.cpp:290
DBus::ObjectProxy::unregister_obj
void unregister_obj(bool throw_on_error=true)
Definition object.cpp:318
DBus::ObjectProxy::register_obj
void register_obj()
Definition object.cpp:301
DBus::Object::_conn
Connection _conn
Definition object.h:68
DBus::Object::handle_message
virtual DXXAPILOCAL bool handle_message(const Message &)=0
DBus::Object::_default_timeout
int _default_timeout
Definition object.h:71
DBus::Object::unregister_obj
virtual DXXAPILOCAL void unregister_obj(bool throw_on_error=true)=0
DBus::Object::path
const DBus::Path & path() const
Definition object.h:82
DBus::Object::Object
Object(Connection &conn, const Path &path, const char *service)
Definition object.cpp:42
DBus::Object::get_timeout
int get_timeout() const
Definition object.h:92
DBus::Object::service
const std::string & service() const
Definition object.h:87
DBus::Object::register_obj
virtual DXXAPILOCAL void register_obj()=0
DBus::Object::set_timeout
void set_timeout(int new_timeout=-1)
Definition object.cpp:51
DBus::Object::conn
Connection & conn()
Definition object.h:77
DBus::Object::_path
DBus::Path _path
Definition object.h:69
DBus::Object::_service
std::string _service
Definition object.h:70
DBus::ProxyBase
Definition interface.h:86
DBus::ReturnMessage
Definition message.h:299
DBus::SignalMessage
Definition message.h:241
DBus::Tag
Definition object.h:101
DBus::Tag::~Tag
virtual ~Tag()
Definition object.h:104
connection.h
interface.h
message.h
DBus
Definition connection_p.h:42
DBus::MessageSlot
Slot< bool, const Message & > MessageSlot
Definition connection.h:41
DBus::ObjectProxyPList
std::list< ObjectProxy * > ObjectProxyPList
Definition object.h:200
DBus::ObjectAdaptorPList
std::list< ObjectAdaptor * > ObjectAdaptorPList
Definition object.h:113
DBus::ObjectPathList
std::list< std::string > ObjectPathList
Definition object.h:114
DBus::Path
Definition types.h:42
DBus::ObjectAdaptor::Private
Definition object.cpp:60
types.h