2019-05-29 22:28:15 +02:00
/**
2022-07-05 17:08:35 +02:00
* (C) 2016 - 2021 KISTLER INSTRUMENTE AG, Winterthur, Switzerland
2024-04-16 22:48:34 +02:00
* (C) 2016 - 2024 Stanislav Angelovic <stanislav.angelovic@protonmail.com>
2019-05-29 22:28:15 +02:00
*
* @file StandardInterfaces.h
*
* Created on: Dec 13, 2016
* Project: sdbus-c++
* Description: High-level D-Bus IPC C++ library based on sd-bus
*
* This file is part of sdbus-c++.
*
* sdbus-c++ is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* sdbus-c++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with sdbus-c++. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SDBUS_CXX_STANDARDINTERFACES_H_
#define SDBUS_CXX_STANDARDINTERFACES_H_
#include <sdbus-c++/IObject.h>
#include <sdbus-c++/IProxy.h>
#include <sdbus-c++/Types.h>
#include <string>
2024-04-16 22:28:42 +02:00
#include <string_view>
2019-05-29 22:28:15 +02:00
#include <map>
#include <vector>
namespace sdbus {
// Proxy for peer
class Peer_proxy
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.Peer" ;
2019-05-29 22:28:15 +02:00
protected :
Peer_proxy ( sdbus :: IProxy & proxy )
2024-04-19 21:36:45 +02:00
: m_proxy ( proxy )
2019-05-29 22:28:15 +02:00
{
}
2022-09-01 11:04:45 +02:00
Peer_proxy ( const Peer_proxy & ) = delete ;
Peer_proxy & operator = ( const Peer_proxy & ) = delete ;
2024-04-19 21:36:45 +02:00
Peer_proxy ( Peer_proxy && ) = delete ;
Peer_proxy & operator = ( Peer_proxy && ) = delete ;
2022-09-01 11:04:45 +02:00
2019-06-10 22:54:16 +02:00
~ Peer_proxy () = default ;
2023-12-30 18:57:10 +01:00
void registerProxy ()
{
}
2019-05-29 22:28:15 +02:00
public :
void Ping ()
{
2024-04-19 21:36:45 +02:00
m_proxy . callMethod ( "Ping" ). onInterface ( INTERFACE_NAME );
2019-05-29 22:28:15 +02:00
}
std :: string GetMachineId ()
{
std :: string machineUUID ;
2024-04-19 21:36:45 +02:00
m_proxy . callMethod ( "GetMachineId" ). onInterface ( INTERFACE_NAME ). storeResultsTo ( machineUUID );
2019-05-29 22:28:15 +02:00
return machineUUID ;
}
private :
2024-04-19 21:36:45 +02:00
sdbus :: IProxy & m_proxy ;
2019-05-29 22:28:15 +02:00
};
// Proxy for introspection
class Introspectable_proxy
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.Introspectable" ;
2019-05-29 22:28:15 +02:00
protected :
Introspectable_proxy ( sdbus :: IProxy & proxy )
2024-04-19 21:36:45 +02:00
: m_proxy ( proxy )
2019-05-29 22:28:15 +02:00
{
}
2022-09-01 11:04:45 +02:00
Introspectable_proxy ( const Introspectable_proxy & ) = delete ;
Introspectable_proxy & operator = ( const Introspectable_proxy & ) = delete ;
2024-04-19 21:36:45 +02:00
Introspectable_proxy ( Introspectable_proxy && ) = delete ;
Introspectable_proxy & operator = ( Introspectable_proxy && ) = delete ;
2022-09-01 11:04:45 +02:00
2019-06-10 22:54:16 +02:00
~ Introspectable_proxy () = default ;
2023-12-30 18:57:10 +01:00
void registerProxy ()
{
}
2019-05-29 22:28:15 +02:00
public :
std :: string Introspect ()
{
std :: string xml ;
2024-04-19 21:36:45 +02:00
m_proxy . callMethod ( "Introspect" ). onInterface ( INTERFACE_NAME ). storeResultsTo ( xml );
2019-05-29 22:28:15 +02:00
return xml ;
}
private :
2024-04-19 21:36:45 +02:00
sdbus :: IProxy & m_proxy ;
2019-05-29 22:28:15 +02:00
};
// Proxy for properties
class Properties_proxy
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.Properties" ;
2019-05-29 22:28:15 +02:00
protected :
Properties_proxy ( sdbus :: IProxy & proxy )
2024-04-19 21:36:45 +02:00
: m_proxy ( proxy )
2023-12-30 18:57:10 +01:00
{
}
Properties_proxy ( const Properties_proxy & ) = delete ;
Properties_proxy & operator = ( const Properties_proxy & ) = delete ;
2024-04-19 21:36:45 +02:00
Properties_proxy ( Properties_proxy && ) = delete ;
Properties_proxy & operator = ( Properties_proxy && ) = delete ;
2023-12-30 18:57:10 +01:00
~ Properties_proxy () = default ;
void registerProxy ()
2019-05-29 22:28:15 +02:00
{
2024-04-19 21:36:45 +02:00
m_proxy
. uponSignal ( "PropertiesChanged" )
2019-05-29 22:28:15 +02:00
. onInterface ( INTERFACE_NAME )
2024-03-29 13:23:44 +01:00
. call ([ this ]( const InterfaceName & interfaceName
, const std :: map < PropertyName , sdbus :: Variant >& changedProperties
, const std :: vector < PropertyName >& invalidatedProperties )
2019-05-29 22:28:15 +02:00
{
this -> onPropertiesChanged ( interfaceName , changedProperties , invalidatedProperties );
});
}
2024-03-29 13:23:44 +01:00
virtual void onPropertiesChanged ( const InterfaceName & interfaceName
, const std :: map < PropertyName , sdbus :: Variant >& changedProperties
, const std :: vector < PropertyName >& invalidatedProperties ) = 0 ;
2019-05-29 22:28:15 +02:00
public :
2024-03-29 13:23:44 +01:00
sdbus :: Variant Get ( const InterfaceName & interfaceName , const PropertyName & propertyName )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getProperty ( propertyName ). onInterface ( interfaceName );
2024-03-29 13:23:44 +01:00
}
2024-04-16 22:28:42 +02:00
sdbus :: Variant Get ( std :: string_view interfaceName , std :: string_view propertyName )
2019-05-29 22:28:15 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getProperty ( propertyName ). onInterface ( interfaceName );
2019-05-29 22:28:15 +02:00
}
2023-09-14 10:54:57 +02:00
template < typename _Function >
2024-03-29 13:23:44 +01:00
PendingAsyncCall GetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , _Function && callback )
2023-09-14 10:54:57 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2023-09-14 10:54:57 +02:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
[[nodiscard]] Slot GetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , _Function && callback , return_slot_t )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2025-05-05 04:31:44 -07:00
std :: future < sdbus :: Variant > GetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , with_future_t )
{
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). getResultAsFuture ();
}
2024-03-29 13:23:44 +01:00
template < typename _Function >
2024-04-16 22:28:42 +02:00
PendingAsyncCall GetAsync ( std :: string_view interfaceName , std :: string_view propertyName , _Function && callback )
2024-03-29 13:23:44 +01:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2024-03-29 13:23:44 +01:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
[[nodiscard]] Slot GetAsync ( std :: string_view interfaceName , std :: string_view propertyName , _Function && callback , return_slot_t )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2024-04-16 22:28:42 +02:00
std :: future < sdbus :: Variant > GetAsync ( std :: string_view interfaceName , std :: string_view propertyName , with_future_t )
2024-03-29 13:23:44 +01:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getPropertyAsync ( propertyName ). onInterface ( interfaceName ). getResultAsFuture ();
2024-03-29 13:23:44 +01:00
}
void Set ( const InterfaceName & interfaceName , const PropertyName & propertyName , const sdbus :: Variant & value )
2019-05-29 22:28:15 +02:00
{
2024-04-19 21:36:45 +02:00
m_proxy . setProperty ( propertyName ). onInterface ( interfaceName ). toValue ( value );
2019-05-29 22:28:15 +02:00
}
2024-04-16 22:28:42 +02:00
void Set ( std :: string_view interfaceName , const std :: string_view propertyName , const sdbus :: Variant & value )
2024-03-29 13:23:44 +01:00
{
2024-04-19 21:36:45 +02:00
m_proxy . setProperty ( propertyName ). onInterface ( interfaceName ). toValue ( value );
2024-03-29 13:23:44 +01:00
}
void Set ( const InterfaceName & interfaceName , const PropertyName & propertyName , const sdbus :: Variant & value , dont_expect_reply_t )
{
2024-04-19 21:36:45 +02:00
m_proxy . setProperty ( propertyName ). onInterface ( interfaceName ). toValue ( value , dont_expect_reply );
2024-03-29 13:23:44 +01:00
}
2024-04-16 22:28:42 +02:00
void Set ( std :: string_view interfaceName , const std :: string_view propertyName , const sdbus :: Variant & value , dont_expect_reply_t )
2023-09-14 10:54:57 +02:00
{
2024-04-19 21:36:45 +02:00
m_proxy . setProperty ( propertyName ). onInterface ( interfaceName ). toValue ( value , dont_expect_reply );
2023-09-14 10:54:57 +02:00
}
template < typename _Function >
2024-03-29 13:23:44 +01:00
PendingAsyncCall SetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , const sdbus :: Variant & value , _Function && callback )
2023-09-14 10:54:57 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2023-09-14 10:54:57 +02:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
2025-05-05 11:18:00 +02:00
[[nodiscard]] Slot SetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , const sdbus :: Variant & value , _Function && callback , return_slot_t )
2024-04-18 19:53:35 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2025-05-05 04:31:44 -07:00
std :: future < void > SetAsync ( const InterfaceName & interfaceName , const PropertyName & propertyName , const sdbus :: Variant & value , with_future_t )
{
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). getResultAsFuture ();
}
2024-03-29 13:23:44 +01:00
template < typename _Function >
2024-04-16 22:28:42 +02:00
PendingAsyncCall SetAsync ( std :: string_view interfaceName , std :: string_view propertyName , const sdbus :: Variant & value , _Function && callback )
2024-03-29 13:23:44 +01:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2024-03-29 13:23:44 +01:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
2025-05-05 11:18:00 +02:00
[[nodiscard]] Slot SetAsync ( std :: string_view interfaceName , std :: string_view propertyName , const sdbus :: Variant & value , _Function && callback , return_slot_t )
2024-04-18 19:53:35 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2024-04-16 22:28:42 +02:00
std :: future < void > SetAsync ( std :: string_view interfaceName , std :: string_view propertyName , const sdbus :: Variant & value , with_future_t )
2024-03-29 13:23:44 +01:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . setPropertyAsync ( propertyName ). onInterface ( interfaceName ). toValue ( value ). getResultAsFuture ();
2024-03-29 13:23:44 +01:00
}
std :: map < PropertyName , sdbus :: Variant > GetAll ( const InterfaceName & interfaceName )
2019-05-29 22:28:15 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllProperties (). onInterface ( interfaceName );
2023-09-14 10:54:57 +02:00
}
2024-04-16 22:28:42 +02:00
std :: map < PropertyName , sdbus :: Variant > GetAll ( std :: string_view interfaceName )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllProperties (). onInterface ( interfaceName );
2024-04-16 22:28:42 +02:00
}
2023-09-14 10:54:57 +02:00
template < typename _Function >
2024-03-29 13:23:44 +01:00
PendingAsyncCall GetAllAsync ( const InterfaceName & interfaceName , _Function && callback )
2023-09-14 10:54:57 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2023-09-14 10:54:57 +02:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
2025-05-05 11:18:00 +02:00
[[nodiscard]] Slot GetAllAsync ( const InterfaceName & interfaceName , _Function && callback , return_slot_t )
2024-04-18 19:53:35 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2025-05-05 04:31:44 -07:00
std :: future < std :: map < PropertyName , sdbus :: Variant >> GetAllAsync ( const InterfaceName & interfaceName , with_future_t )
{
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). getResultAsFuture ();
}
2024-04-16 22:28:42 +02:00
template < typename _Function >
PendingAsyncCall GetAllAsync ( std :: string_view interfaceName , _Function && callback )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
2024-04-16 22:28:42 +02:00
}
2024-04-18 19:53:35 +02:00
template < typename _Function >
2025-05-05 11:18:00 +02:00
[[nodiscard]] Slot GetAllAsync ( std :: string_view interfaceName , _Function && callback , return_slot_t )
2024-04-18 19:53:35 +02:00
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
2024-04-18 19:53:35 +02:00
}
2024-04-16 22:28:42 +02:00
std :: future < std :: map < PropertyName , sdbus :: Variant >> GetAllAsync ( std :: string_view interfaceName , with_future_t )
{
2024-04-19 21:36:45 +02:00
return m_proxy . getAllPropertiesAsync (). onInterface ( interfaceName ). getResultAsFuture ();
2024-04-16 22:28:42 +02:00
}
2019-05-29 22:28:15 +02:00
private :
2024-04-19 21:36:45 +02:00
sdbus :: IProxy & m_proxy ;
2019-05-29 22:28:15 +02:00
};
// Proxy for object manager
class ObjectManager_proxy
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.ObjectManager" ;
2019-05-29 22:28:15 +02:00
protected :
ObjectManager_proxy ( sdbus :: IProxy & proxy )
2024-04-19 21:36:45 +02:00
: m_proxy ( proxy )
2023-12-30 18:57:10 +01:00
{
}
ObjectManager_proxy ( const ObjectManager_proxy & ) = delete ;
ObjectManager_proxy & operator = ( const ObjectManager_proxy & ) = delete ;
2024-04-19 21:36:45 +02:00
ObjectManager_proxy ( ObjectManager_proxy && ) = delete ;
ObjectManager_proxy & operator = ( ObjectManager_proxy && ) = delete ;
2023-12-30 18:57:10 +01:00
~ ObjectManager_proxy () = default ;
void registerProxy ()
2019-05-29 22:28:15 +02:00
{
2024-04-19 21:36:45 +02:00
m_proxy
. uponSignal ( "InterfacesAdded" )
2019-05-29 22:28:15 +02:00
. onInterface ( INTERFACE_NAME )
. call ([ this ]( const sdbus :: ObjectPath & objectPath
2024-03-29 13:23:44 +01:00
, const std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>& interfacesAndProperties )
2019-05-29 22:28:15 +02:00
{
this -> onInterfacesAdded ( objectPath , interfacesAndProperties );
});
2024-04-19 21:36:45 +02:00
m_proxy
. uponSignal ( "InterfacesRemoved" )
2019-05-29 22:28:15 +02:00
. onInterface ( INTERFACE_NAME )
. call ([ this ]( const sdbus :: ObjectPath & objectPath
2024-03-29 13:23:44 +01:00
, const std :: vector < sdbus :: InterfaceName >& interfaces )
2019-05-29 22:28:15 +02:00
{
this -> onInterfacesRemoved ( objectPath , interfaces );
});
}
virtual void onInterfacesAdded ( const sdbus :: ObjectPath & objectPath
2024-03-29 13:23:44 +01:00
, const std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>& interfacesAndProperties ) = 0 ;
2019-05-29 22:28:15 +02:00
virtual void onInterfacesRemoved ( const sdbus :: ObjectPath & objectPath
2024-03-29 13:23:44 +01:00
, const std :: vector < sdbus :: InterfaceName >& interfaces ) = 0 ;
2019-05-29 22:28:15 +02:00
public :
2024-03-29 13:23:44 +01:00
std :: map < sdbus :: ObjectPath , std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>> GetManagedObjects ()
2019-05-29 22:28:15 +02:00
{
2024-03-29 13:23:44 +01:00
std :: map < sdbus :: ObjectPath , std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>> objectsInterfacesAndProperties ;
2024-04-19 21:36:45 +02:00
m_proxy . callMethod ( "GetManagedObjects" ). onInterface ( INTERFACE_NAME ). storeResultsTo ( objectsInterfacesAndProperties );
2019-05-29 22:28:15 +02:00
return objectsInterfacesAndProperties ;
}
2025-05-05 04:31:44 -07:00
template < typename _Function >
PendingAsyncCall GetManagedObjectsAsync ( _Function && callback )
{
return m_proxy . callMethodAsync ( "GetManagedObjects" ). onInterface ( INTERFACE_NAME ). uponReplyInvoke ( std :: forward < _Function > ( callback ));
}
template < typename _Function >
[[nodiscard]] Slot GetManagedObjectsAsync ( _Function && callback , return_slot_t )
{
return m_proxy . callMethodAsync ( "GetManagedObjects" ). onInterface ( INTERFACE_NAME ). uponReplyInvoke ( std :: forward < _Function > ( callback ), return_slot );
}
std :: future < std :: map < sdbus :: ObjectPath , std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>>> GetManagedObjectsAsync ( with_future_t )
{
return m_proxy . callMethodAsync ( "GetManagedObjects" ). onInterface ( INTERFACE_NAME ). getResultAsFuture < std :: map < sdbus :: ObjectPath , std :: map < sdbus :: InterfaceName , std :: map < PropertyName , sdbus :: Variant >>>> ();
}
2019-05-29 22:28:15 +02:00
private :
2024-04-19 21:36:45 +02:00
sdbus :: IProxy & m_proxy ;
2019-05-29 22:28:15 +02:00
};
// Adaptors for the above-listed standard D-Bus interfaces are not necessary because the functionality
2021-10-14 15:53:51 +02:00
// is provided by underlying libsystemd implementation. The exception is Properties_adaptor,
// ObjectManager_adaptor and ManagedObject_adaptor, which provide convenience functionality to emit signals.
2019-06-03 22:02:15 +02:00
2019-06-03 23:47:27 +02:00
// Adaptor for properties
2019-06-03 22:02:15 +02:00
class Properties_adaptor
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.Properties" ;
2019-06-03 22:02:15 +02:00
protected :
2024-04-19 21:36:45 +02:00
Properties_adaptor ( sdbus :: IObject & object ) : m_object ( object )
2019-06-03 22:02:15 +02:00
{
}
2022-09-01 11:04:45 +02:00
Properties_adaptor ( const Properties_adaptor & ) = delete ;
Properties_adaptor & operator = ( const Properties_adaptor & ) = delete ;
2024-04-19 21:36:45 +02:00
Properties_adaptor ( Properties_adaptor && ) = delete ;
Properties_adaptor & operator = ( Properties_adaptor && ) = delete ;
2022-09-01 11:04:45 +02:00
2019-06-10 22:54:16 +02:00
~ Properties_adaptor () = default ;
2023-12-30 18:40:38 +01:00
void registerAdaptor ()
{
}
2019-06-03 22:02:15 +02:00
public :
2024-03-29 13:23:44 +01:00
void emitPropertiesChangedSignal ( const InterfaceName & interfaceName , const std :: vector < PropertyName >& properties )
2019-06-03 22:02:15 +02:00
{
2024-04-19 21:36:45 +02:00
m_object . emitPropertiesChangedSignal ( interfaceName , properties );
2019-06-03 22:02:15 +02:00
}
2024-04-16 22:28:42 +02:00
void emitPropertiesChangedSignal ( const char * interfaceName , const std :: vector < PropertyName >& properties )
{
2024-04-19 21:36:45 +02:00
m_object . emitPropertiesChangedSignal ( interfaceName , properties );
2024-04-16 22:28:42 +02:00
}
2024-03-29 13:23:44 +01:00
void emitPropertiesChangedSignal ( const InterfaceName & interfaceName )
2019-06-03 22:02:15 +02:00
{
2024-04-19 21:36:45 +02:00
m_object . emitPropertiesChangedSignal ( interfaceName );
2019-06-03 22:02:15 +02:00
}
2024-04-16 22:28:42 +02:00
void emitPropertiesChangedSignal ( const char * interfaceName )
{
2024-04-19 21:36:45 +02:00
m_object . emitPropertiesChangedSignal ( interfaceName );
2024-04-16 22:28:42 +02:00
}
2019-06-03 22:02:15 +02:00
private :
2024-04-19 21:36:45 +02:00
sdbus :: IObject & m_object ;
2019-06-03 22:02:15 +02:00
};
2021-10-14 15:53:51 +02:00
/*!
* @brief Object Manager Convenience Adaptor
*
* Adding this class as _Interfaces.. template parameter of class AdaptorInterfaces
* implements the *GetManagedObjects()* method of the [org.freedesktop.DBus.ObjectManager.GetManagedObjects](https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
* interface.
*
* Note that there can be multiple object managers in a path hierarchy. InterfacesAdded/InterfacesRemoved
* signals are sent from the closest object manager at either the same path or the closest parent path of an object.
*/
2019-06-03 23:47:27 +02:00
class ObjectManager_adaptor
{
2024-04-16 22:28:42 +02:00
static inline const char * INTERFACE_NAME = "org.freedesktop.DBus.ObjectManager" ;
2019-06-03 23:47:27 +02:00
protected :
2024-04-19 21:36:45 +02:00
explicit ObjectManager_adaptor ( sdbus :: IObject & object ) : m_object ( object )
2019-06-03 23:47:27 +02:00
{
}
2022-09-01 11:04:45 +02:00
ObjectManager_adaptor ( const ObjectManager_adaptor & ) = delete ;
ObjectManager_adaptor & operator = ( const ObjectManager_adaptor & ) = delete ;
2024-04-19 21:36:45 +02:00
ObjectManager_adaptor ( ObjectManager_adaptor && ) = delete ;
ObjectManager_adaptor & operator = ( ObjectManager_adaptor && ) = delete ;
2022-09-01 11:04:45 +02:00
2019-06-10 22:54:16 +02:00
~ ObjectManager_adaptor () = default ;
2023-12-30 18:40:38 +01:00
void registerAdaptor ()
{
2024-04-19 21:36:45 +02:00
m_object . addObjectManager ();
2023-12-30 18:40:38 +01:00
}
2021-10-14 15:53:51 +02:00
private :
2024-04-19 21:36:45 +02:00
sdbus :: IObject & m_object ;
2021-10-14 15:53:51 +02:00
};
/*!
* @brief Managed Object Convenience Adaptor
*
* Adding this class as _Interfaces.. template parameter of class AdaptorInterfaces
* will extend the resulting object adaptor with emitInterfacesAddedSignal()/emitInterfacesRemovedSignal()
* according to org.freedesktop.DBus.ObjectManager.InterfacesAdded/.InterfacesRemoved.
*
* Note that objects which implement this adaptor require an object manager (e.g via ObjectManager_adaptor) to be
* instantiated on one of it's parent object paths or the same path. InterfacesAdded/InterfacesRemoved
* signals are sent from the closest object manager at either the same path or the closest parent path of an object.
*/
class ManagedObject_adaptor
{
protected :
2022-09-01 11:04:45 +02:00
explicit ManagedObject_adaptor ( sdbus :: IObject & object )
2024-04-19 21:36:45 +02:00
: m_object ( object )
2021-10-14 15:53:51 +02:00
{
}
2022-09-01 11:04:45 +02:00
ManagedObject_adaptor ( const ManagedObject_adaptor & ) = delete ;
ManagedObject_adaptor & operator = ( const ManagedObject_adaptor & ) = delete ;
2024-04-19 21:36:45 +02:00
ManagedObject_adaptor ( ManagedObject_adaptor && ) = delete ;
ManagedObject_adaptor & operator = ( ManagedObject_adaptor && ) = delete ;
2022-09-01 11:04:45 +02:00
2021-10-14 15:53:51 +02:00
~ ManagedObject_adaptor () = default ;
2023-12-30 18:40:38 +01:00
void registerAdaptor ()
{
}
2019-06-03 23:47:27 +02:00
public :
2021-10-14 15:53:51 +02:00
/*!
* @brief Emits InterfacesAdded signal for this object path
*
* See IObject::emitInterfacesAddedSignal().
*/
2019-06-03 23:47:27 +02:00
void emitInterfacesAddedSignal ()
{
2024-04-19 21:36:45 +02:00
m_object . emitInterfacesAddedSignal ();
2019-06-03 23:47:27 +02:00
}
2021-10-14 15:53:51 +02:00
/*!
* @brief Emits InterfacesAdded signal for this object path
*
* See IObject::emitInterfacesAddedSignal().
*/
2024-03-29 13:23:44 +01:00
void emitInterfacesAddedSignal ( const std :: vector < sdbus :: InterfaceName >& interfaces )
2019-06-03 23:47:27 +02:00
{
2024-04-19 21:36:45 +02:00
m_object . emitInterfacesAddedSignal ( interfaces );
2019-06-03 23:47:27 +02:00
}
2021-10-14 15:53:51 +02:00
/*!
* @brief Emits InterfacesRemoved signal for this object path
*
* See IObject::emitInterfacesRemovedSignal().
*/
2019-06-03 23:47:27 +02:00
void emitInterfacesRemovedSignal ()
{
2024-04-19 21:36:45 +02:00
m_object . emitInterfacesRemovedSignal ();
2019-06-03 23:47:27 +02:00
}
2021-10-14 15:53:51 +02:00
/*!
* @brief Emits InterfacesRemoved signal for this object path
*
* See IObject::emitInterfacesRemovedSignal().
*/
2024-03-29 13:23:44 +01:00
void emitInterfacesRemovedSignal ( const std :: vector < InterfaceName >& interfaces )
2019-06-03 23:47:27 +02:00
{
2024-04-19 21:36:45 +02:00
m_object . emitInterfacesRemovedSignal ( interfaces );
2019-06-03 23:47:27 +02:00
}
private :
2024-04-19 21:36:45 +02:00
sdbus :: IObject & m_object ;
2019-06-03 23:47:27 +02:00
};
2019-05-29 22:28:15 +02:00
}
#endif /* SDBUS_CXX_STANDARDINTERFACES_H_ */