diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2009-10-14 09:16:52 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2009-10-14 12:28:02 +0200 |
commit | bb73c2745b7612fd2663050be5c28d013468587e (patch) | |
tree | 4b9d036738d667960a3cf61f50104b1ba29a0719 | |
parent | fce06ca799e2981ae7d013533da076837417276a (diff) |
gdbus C++: demonstrate how to bind methods in private base classesgdbus-cxx
Passing the "this" pointer to DBusObjectHelper::add() does not
work in this case because it cannot downcast to the required
base class. However, the caller can do that, which solves the
problem.
-rw-r--r-- | src/gdbus/test/example.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gdbus/test/example.cpp b/src/gdbus/test/example.cpp index a26bf6f3..3a5e099e 100644 --- a/src/gdbus/test/example.cpp +++ b/src/gdbus/test/example.cpp @@ -156,13 +156,19 @@ public: } }; +class Test2 +{ +public: + void test2() {} +}; + template<> struct dbus_traits<args> : public dbus_struct_traits<args, dbus_member<args, int, &args::a, dbus_member<args, std::string, &args::b, dbus_member_single<args, std::map<std::string, std::string>, &args::c> > > > {}; -class DBusTest : public Test +class DBusTest : public Test, private Test2 { DBusObjectHelper m_object; DBusObjectHelper m_secondary; @@ -187,6 +193,7 @@ public: m_object.add(this, &Test::error, "Error"); m_object.add(&hello_global, "Global"); m_object.add(&DBusTest::hello_static, "Static"); + m_object.add(static_cast<Test2 *>(this), &Test2::test2, "Private"); // The hello_const() method cannot be registered // because there is no matching MakeMethodEntry<> // specialization for it or DBusObjectHelper::add() |