Free memory with dbus_free instead of free. Account for NULL signatures.
[dbus-cxx-async.git] / include / dbus-c++ / object.h
blobdd305bd1de0e6a3d6b5543a90870b61fc3125102
1 /*
3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
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.
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.
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
25 #ifndef __DBUSXX_OBJECT_H
26 #define __DBUSXX_OBJECT_H
28 #include <string>
29 #include <list>
31 #include "api.h"
32 #include "interface.h"
33 #include "connection.h"
34 #include "message.h"
35 #include "types.h"
37 namespace DBus {
39 class DBUSXXAPI Object
41 protected:
43 Object(Connection &conn, const Path &path, const char *service);
45 public:
47 virtual ~Object();
49 const DBus::Path &path() const { return _path; }
51 const std::string &service() const { return _service; }
53 Connection &conn() { return _conn; }
55 private:
57 DBUSXXAPILOCAL virtual bool handle_message(const Message &) = 0;
58 DBUSXXAPILOCAL virtual void register_obj() = 0;
59 DBUSXXAPILOCAL virtual void unregister_obj() = 0;
61 private:
63 Connection _conn;
64 DBus::Path _path;
65 std::string _service;
71 class ObjectAdaptor;
73 typedef std::list<ObjectAdaptor *> ObjectAdaptorPList;
74 typedef std::list<std::string> ObjectPathList;
76 class DBUSXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase
78 public:
80 static ObjectAdaptor *from_path(const Path &path);
82 static ObjectAdaptorPList from_path_prefix(const std::string &prefix);
84 static ObjectPathList child_nodes_from_prefix(const std::string &prefix);
86 struct Private;
88 ObjectAdaptor(Connection &conn, const Path &path);
90 ~ObjectAdaptor();
92 ObjectAdaptor &object() { return *this; }
94 private:
96 void _emit_signal(SignalMessage &);
98 bool handle_message(const Message &);
100 void register_obj();
101 void unregister_obj();
103 friend struct Private;
109 class ObjectProxy;
111 typedef std::list<ObjectProxy *> ObjectProxyPList;
113 class DBUSXXAPI ObjectProxy : public Object, public virtual ProxyBase,
114 virtual public CallbackTarget
116 public:
118 ObjectProxy(Connection &conn, const Path &path, const char *service = "");
120 ~ObjectProxy();
122 ObjectProxy &object() { return *this; }
124 private:
126 Message _invoke_method(CallMessage &, int timeout);
127 PendingCall _invoke_method_async(CallMessage &, const PendingCallSlot &, void*, int timeout);
129 bool handle_message(const Message &);
131 void register_obj();
132 void unregister_obj();
134 private:
136 MessageSlot _filtered;
137 PendingCalls _pending;
139 friend class PendingCall; //TODO: in order to manage pending calls lifetime
140 friend struct PendingCall::Private; //TODO: in order to manage pending calls lifetime
143 } /* namespace DBus */
145 #endif//__DBUSXX_OBJECT_H