-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native DBus objectmanager support on server side (switchable)
- Loading branch information
Martin Haefner
committed
Jul 18, 2024
1 parent
0d21e85
commit caa3f07
Showing
12 changed files
with
529 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef __SIMPPL_ORG_FREEDESKTOP_DBUS_OBJECTMANAGER_H__ | ||
#define __SIMPPL_ORG_FREEDESKTOP_DBUS_OBJECTMANAGER_H__ | ||
|
||
|
||
#include "simppl/interface.h" | ||
#include "simppl/map.h" | ||
#include "simppl/vector.h" | ||
#include "simppl/objectpath.h" | ||
#include "simppl/any.h" | ||
|
||
|
||
namespace org | ||
{ | ||
namespace freedesktop | ||
{ | ||
namespace DBus | ||
{ | ||
using simppl::dbus::out; | ||
|
||
|
||
typedef | ||
std::map<simppl::dbus::ObjectPath, ///< object registration path | ||
std::map<std::string, ///< interface name | ||
std::map<std::string, simppl::dbus::Any> ///< properties | ||
> | ||
> managed_objects_t; | ||
|
||
|
||
INTERFACE(ObjectManager) | ||
{ | ||
Method<out<managed_objects_t>> GetManagedObjects; | ||
|
||
Signal<simppl::dbus::ObjectPath, std::map<std::string, std::map<std::string, simppl::dbus::Any>>> InterfacesAdded; | ||
Signal<simppl::dbus::ObjectPath, std::vector<std::string>> InterfacesRemoved; | ||
|
||
ObjectManager() | ||
: INIT(GetManagedObjects) | ||
, INIT(InterfacesAdded) | ||
, INIT(InterfacesRemoved) | ||
{ | ||
// NOOP | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
|
||
|
||
#endif // __SIMPPL_ORG_FREEDESKTOP_DBUS_OBJECTMANAGER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#ifndef __SIMPPL_DBUS_OBJECTMANAGERINTERPOSER_H__ | ||
#define __SIMPPL_DBUS_OBJECTMANAGERINTERPOSER_H__ | ||
|
||
#if SIMPPL_HAVE_OBJECTMANAGER | ||
# include "simppl/api/objectmanager.h" | ||
# include "simppl/objectmanagermixin.h" | ||
|
||
# include "simppl/serverside.h" // FIXME remove this? | ||
|
||
|
||
namespace simppl | ||
{ | ||
|
||
namespace dbus | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
/** | ||
* Check if object manager interface is part of the implemented interfaces. | ||
*/ | ||
template<template<int, | ||
typename, | ||
template<typename...> class, | ||
template<typename...> class, | ||
template<typename,int> class, | ||
typename> class... Is> | ||
struct ObjectManagerInterposer | ||
{ | ||
enum { avail = Find<org::freedesktop::DBus::ObjectManager<0, SkeletonBase, ServerMethod, ServerSignal, ServerProperty, SkeletonBase>, | ||
typename make_typelist<Is<0, SkeletonBase, ServerMethod, ServerSignal, ServerProperty, SkeletonBase>...>::type>::value != -1 }; | ||
|
||
typedef typename std::conditional<avail, SizedObjectManagerMixin<sizeof...(Is)>, SizedSkeletonBase<sizeof...(Is)>>::type type; | ||
}; | ||
|
||
} // detail | ||
|
||
} // dbus | ||
|
||
} // simppl | ||
|
||
#else | ||
|
||
namespace simppl | ||
{ | ||
|
||
namespace dbus | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
/** | ||
* No objectmanager interposing. You may implement the API for yourself. | ||
*/ | ||
template<template<int, | ||
typename, | ||
template<typename...> class, | ||
template<typename...> class, | ||
template<typename,int> class, | ||
typename> class... Is> | ||
struct ObjectManagerInterposer | ||
{ | ||
typedef SizedSkeletonBase<sizeof...(Is)> type; | ||
}; | ||
|
||
} // detail | ||
|
||
} // dbus | ||
|
||
} // simppl | ||
|
||
#endif // SIMPPL_HAVE_OBJECTMANAGER | ||
|
||
#endif // __SIMPPL_DBUS_OBJECTMANAGERINTERPOSER_H__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef __SIMPPL_DBUS_OBJECTMANAGERMIXIN_H__ | ||
#define __SIMPPL_DBUS_OBJECTMANAGERMIXIN_H__ | ||
|
||
#include <set> | ||
|
||
#include "simppl/skeletonbase.h" | ||
|
||
|
||
namespace simppl | ||
{ | ||
|
||
namespace dbus | ||
{ | ||
|
||
class SkeletonBase; | ||
|
||
/** | ||
* If native objectmanager support is enabled, this class | ||
* extends the API of the Skeletons in case the | ||
* org.freedesktop.DBus.ObjectManager API is included. | ||
*/ | ||
struct ObjectManagerMixin : public SkeletonBase | ||
{ | ||
public: | ||
|
||
ObjectManagerMixin(size_t size) | ||
: SkeletonBase(size) | ||
{ | ||
// NOOP | ||
} | ||
|
||
void add_managed_object(SkeletonBase* obj); | ||
void remove_managed_object(SkeletonBase* obj); | ||
|
||
private: | ||
|
||
void serialize_object(DBusMessageIter& iter, const simppl::dbus::SkeletonBase& obj); | ||
|
||
DBusHandlerResult handle_objectmanager_request(DBusMessage* msg); | ||
|
||
std::set<SkeletonBase*> objects_; | ||
}; | ||
|
||
|
||
template<size_t N> | ||
struct SizedObjectManagerMixin : public ObjectManagerMixin | ||
{ | ||
SizedObjectManagerMixin() | ||
: ObjectManagerMixin(N) | ||
{ | ||
// NOOP | ||
} | ||
}; | ||
|
||
} // dbus | ||
|
||
} // simppl | ||
|
||
|
||
#endif // __SIMPPL_DBUS_OBJECTMANAGERMIXIN_H__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.