From 6691d437900901eeb28668b6558b536f7bab918e Mon Sep 17 00:00:00 2001 From: Tobias Lorenz Date: Wed, 7 Jun 2023 14:01:22 +0200 Subject: [PATCH 1/2] Drop "using namespace" in header files. Signed-off-by: Tobias Lorenz --- include/bluez-dbus-cpp/Adapter1.h | 8 +++----- include/bluez-dbus-cpp/GattApplication1.h | 10 ++++------ include/bluez-dbus-cpp/GattCharacteristic1.h | 6 ++---- include/bluez-dbus-cpp/GattDescriptor1.h | 4 +--- include/bluez-dbus-cpp/GattManager1.h | 6 ++---- include/bluez-dbus-cpp/GattService1.h | 6 ++---- include/bluez-dbus-cpp/LEAdvertisement1.h | 6 ++---- include/bluez-dbus-cpp/LEAdvertisingManager1.h | 6 ++---- .../bluez-dbus-cpp/adaptor/ObjectManagerExt_adaptor.h | 2 +- include/bluez-dbus-cpp/adaptor/PropertiesExt_adaptor.h | 6 ++---- src/GattCharacteristic1.cpp | 2 +- src/GattService1.cpp | 2 +- 12 files changed, 23 insertions(+), 41 deletions(-) diff --git a/include/bluez-dbus-cpp/Adapter1.h b/include/bluez-dbus-cpp/Adapter1.h index a2983e2..6f6d0b6 100644 --- a/include/bluez-dbus-cpp/Adapter1.h +++ b/include/bluez-dbus-cpp/Adapter1.h @@ -11,13 +11,11 @@ namespace org { namespace bluez { -using namespace sdbus; - -class Adapter1 : public ProxyInterfaces +class Adapter1 : public sdbus::ProxyInterfaces { public: - Adapter1( IConnection& connection, std::string destination, std::string objectPath ) - : ProxyInterfaces{ connection, std::move(destination), std::move(objectPath) } + Adapter1( sdbus::IConnection& connection, std::string destination, std::string objectPath ) + : sdbus::ProxyInterfaces{ connection, std::move(destination), std::move(objectPath) } { registerProxy(); } diff --git a/include/bluez-dbus-cpp/GattApplication1.h b/include/bluez-dbus-cpp/GattApplication1.h index d25d1e2..2209ab8 100644 --- a/include/bluez-dbus-cpp/GattApplication1.h +++ b/include/bluez-dbus-cpp/GattApplication1.h @@ -17,14 +17,12 @@ namespace org { namespace bluez { -using namespace sdbus; - class GattApplication1 : - public AdaptorInterfaces, + public sdbus::AdaptorInterfaces, public std::enable_shared_from_this { public: - GattApplication1( std::shared_ptr connection, std::string objectPath ) + GattApplication1( std::shared_ptr connection, std::string objectPath ) : AdaptorInterfaces{ *connection, objectPath }, connection_{ connection }, path_{ std::move(objectPath) } @@ -68,7 +66,7 @@ class GattApplication1 : return path_; } - std::shared_ptr getConnection() const + std::shared_ptr getConnection() const { return connection_; } @@ -87,7 +85,7 @@ class GattApplication1 : protected: std::string path_; - std::shared_ptr connection_; + std::shared_ptr connection_; std::vector> services_; }; diff --git a/include/bluez-dbus-cpp/GattCharacteristic1.h b/include/bluez-dbus-cpp/GattCharacteristic1.h index 51341b7..0d28a7e 100644 --- a/include/bluez-dbus-cpp/GattCharacteristic1.h +++ b/include/bluez-dbus-cpp/GattCharacteristic1.h @@ -21,10 +21,8 @@ namespace bluez { // Forward declarations class GattService1; -using namespace sdbus; - class GattCharacteristic1 : - public AdaptorInterfaces, + public sdbus::AdaptorInterfaces, public std::enable_shared_from_this { static constexpr const char* INTERFACE_NAME = "org.bluez.GattCharacteristic1"; @@ -50,7 +48,7 @@ class GattCharacteristic1 : virtual void addDescriptor( std::shared_ptr descriptor ); virtual void removeDescriptor( std::shared_ptr descriptor ); const std::string& getPath() const; - const std::shared_ptr getConnection() const; + const std::shared_ptr getConnection() const; protected: /** diff --git a/include/bluez-dbus-cpp/GattDescriptor1.h b/include/bluez-dbus-cpp/GattDescriptor1.h index 6d4ea32..cf492b7 100644 --- a/include/bluez-dbus-cpp/GattDescriptor1.h +++ b/include/bluez-dbus-cpp/GattDescriptor1.h @@ -17,10 +17,8 @@ namespace bluez { // Forward declarations class GattCharacteristic1; -using namespace sdbus; - class GattDescriptor1 : - public AdaptorInterfaces, + public sdbus::AdaptorInterfaces, public std::enable_shared_from_this { public: diff --git a/include/bluez-dbus-cpp/GattManager1.h b/include/bluez-dbus-cpp/GattManager1.h index 525a960..b07293e 100644 --- a/include/bluez-dbus-cpp/GattManager1.h +++ b/include/bluez-dbus-cpp/GattManager1.h @@ -11,8 +11,6 @@ namespace org { namespace bluez { -using namespace sdbus; - class GattManager1 : public std::enable_shared_from_this { @@ -20,7 +18,7 @@ class GattManager1 : static constexpr const char* INTERFACE_NAME = "org.bluez.GattManager1"; public: - GattManager1( IConnection& connection, std::string destination, std::string objectPath ) + GattManager1( sdbus::IConnection& connection, std::string destination, std::string objectPath ) : proxy_{ createProxy( connection, std::move(destination), std::move(objectPath) ) } { proxy_->finishRegistration(); @@ -43,7 +41,7 @@ class GattManager1 : proxy_->callMethod("RegisterApplication").onInterface(INTERFACE_NAME).withArguments(application, options); } - AsyncMethodInvoker RegisterApplicationAsync( const sdbus::ObjectPath& application, const std::map& options ) + sdbus::AsyncMethodInvoker RegisterApplicationAsync( const sdbus::ObjectPath& application, const std::map& options ) { return proxy_->callMethodAsync("RegisterApplication").onInterface(INTERFACE_NAME).withArguments(application, options); } diff --git a/include/bluez-dbus-cpp/GattService1.h b/include/bluez-dbus-cpp/GattService1.h index 9faa63d..6295857 100644 --- a/include/bluez-dbus-cpp/GattService1.h +++ b/include/bluez-dbus-cpp/GattService1.h @@ -18,10 +18,8 @@ namespace bluez { // Forward declarations class GattApplication1; -using namespace sdbus; - class GattService1 : - public AdaptorInterfaces, + public sdbus::AdaptorInterfaces, public std::enable_shared_from_this { GattService1( const GattService1& service ) = delete; @@ -40,7 +38,7 @@ class GattService1 : virtual void addSubService( std::shared_ptr service ); virtual void removeSubService( std::shared_ptr service ); virtual const std::string& getPath() const final; - virtual std::shared_ptr getConnection() const final; + virtual std::shared_ptr getConnection() const final; virtual int nextCharacteristicIndex() const final; public: diff --git a/include/bluez-dbus-cpp/LEAdvertisement1.h b/include/bluez-dbus-cpp/LEAdvertisement1.h index 49ce832..764b377 100644 --- a/include/bluez-dbus-cpp/LEAdvertisement1.h +++ b/include/bluez-dbus-cpp/LEAdvertisement1.h @@ -13,8 +13,6 @@ namespace org { namespace bluez { -using namespace sdbus; - class LEAdvertisement1 : public std::enable_shared_from_this { @@ -26,7 +24,7 @@ class LEAdvertisement1 : static constexpr const char* INTERFACE_NAME = "org.bluez.LEAdvertisement1"; public: - LEAdvertisement1( IConnection& connection, std::string objectPath ) + LEAdvertisement1( sdbus::IConnection& connection, std::string objectPath ) : object_{ createObject(connection, objectPath) }, path_{ std::move(objectPath) } { @@ -43,7 +41,7 @@ class LEAdvertisement1 : return path_; } - static LEAdvertisement1& create( IConnection& connection, std::string objectPath ) + static LEAdvertisement1& create( sdbus::IConnection& connection, std::string objectPath ) { auto self = new LEAdvertisement1{ connection, std::move(objectPath) }; return *self; diff --git a/include/bluez-dbus-cpp/LEAdvertisingManager1.h b/include/bluez-dbus-cpp/LEAdvertisingManager1.h index 09d0184..577a269 100644 --- a/include/bluez-dbus-cpp/LEAdvertisingManager1.h +++ b/include/bluez-dbus-cpp/LEAdvertisingManager1.h @@ -11,8 +11,6 @@ namespace org { namespace bluez { -using namespace sdbus; - class LEAdvertisingManager1 : public std::enable_shared_from_this { @@ -20,7 +18,7 @@ class LEAdvertisingManager1 : static constexpr const char* INTERFACE_NAME = "org.bluez.LEAdvertisingManager1"; public: - LEAdvertisingManager1( IConnection& connection, std::string destination, std::string objectPath ) + LEAdvertisingManager1( sdbus::IConnection& connection, std::string destination, std::string objectPath ) : proxy_{ createProxy( connection, std::move(destination), std::move(objectPath) ) } { proxy_->finishRegistration(); @@ -43,7 +41,7 @@ class LEAdvertisingManager1 : proxy_->callMethod("RegisterAdvertisement").onInterface(INTERFACE_NAME).withArguments( advertisementPath, options ); } - AsyncMethodInvoker RegisterAdvertisementAsync( const sdbus::ObjectPath& advertisementPath, const std::map& options = {} ) + sdbus::AsyncMethodInvoker RegisterAdvertisementAsync( const sdbus::ObjectPath& advertisementPath, const std::map& options = {} ) { return proxy_->callMethodAsync("RegisterAdvertisement").onInterface(INTERFACE_NAME).withArguments( advertisementPath, options ); } diff --git a/include/bluez-dbus-cpp/adaptor/ObjectManagerExt_adaptor.h b/include/bluez-dbus-cpp/adaptor/ObjectManagerExt_adaptor.h index c90f4ce..a5cc4b7 100644 --- a/include/bluez-dbus-cpp/adaptor/ObjectManagerExt_adaptor.h +++ b/include/bluez-dbus-cpp/adaptor/ObjectManagerExt_adaptor.h @@ -14,7 +14,7 @@ namespace org { namespace bluez { -class ObjectManagerExt_adaptor : public ObjectManager_adaptor +class ObjectManagerExt_adaptor : public sdbus::ObjectManager_adaptor { public: static constexpr const char* INTERFACE_NAME = "org.freedesktop.DBus.ObjectManager"; diff --git a/include/bluez-dbus-cpp/adaptor/PropertiesExt_adaptor.h b/include/bluez-dbus-cpp/adaptor/PropertiesExt_adaptor.h index 7964768..27e1c1a 100644 --- a/include/bluez-dbus-cpp/adaptor/PropertiesExt_adaptor.h +++ b/include/bluez-dbus-cpp/adaptor/PropertiesExt_adaptor.h @@ -8,9 +8,7 @@ #include -using namespace sdbus; - -class PropertiesExt_adaptor : public Properties_adaptor +class PropertiesExt_adaptor : public sdbus::Properties_adaptor { public: PropertiesExt_adaptor(sdbus::IObject& object) @@ -25,4 +23,4 @@ class PropertiesExt_adaptor : public Properties_adaptor { emitPropertiesChangedSignal( interfaceName, std::vector{ property } ); } -}; \ No newline at end of file +}; diff --git a/src/GattCharacteristic1.cpp b/src/GattCharacteristic1.cpp index fbe8da6..097c34f 100644 --- a/src/GattCharacteristic1.cpp +++ b/src/GattCharacteristic1.cpp @@ -190,7 +190,7 @@ const std::string& GattCharacteristic1::getPath() const return path_; } -const std::shared_ptr GattCharacteristic1::getConnection() const +const std::shared_ptr GattCharacteristic1::getConnection() const { return service_->getConnection(); } diff --git a/src/GattService1.cpp b/src/GattService1.cpp index 9683805..b7a510f 100644 --- a/src/GattService1.cpp +++ b/src/GattService1.cpp @@ -116,7 +116,7 @@ const std::string& GattService1::getPath() const return path_; } -std::shared_ptr GattService1::getConnection() const +std::shared_ptr GattService1::getConnection() const { return app_->getConnection(); } From 6bbf38eed05650219dacc3c0168c4bdab5489916 Mon Sep 17 00:00:00 2001 From: Tobias Lorenz Date: Wed, 7 Jun 2023 15:04:00 +0200 Subject: [PATCH 2/2] Fix clang-tidy/clazy findings. Signed-off-by: Tobias Lorenz --- include/bluez-dbus-cpp/GattApplication1.h | 2 +- src/GattCharacteristic1.cpp | 14 +++++++------- src/GattService1.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/bluez-dbus-cpp/GattApplication1.h b/include/bluez-dbus-cpp/GattApplication1.h index 2209ab8..82aa17a 100644 --- a/include/bluez-dbus-cpp/GattApplication1.h +++ b/include/bluez-dbus-cpp/GattApplication1.h @@ -38,7 +38,7 @@ class GattApplication1 : public: void addService( std::shared_ptr service ) { - for( auto serv : services_ ) + for( const auto & serv : services_ ) { if( serv == service ) throw std::invalid_argument(std::string("GattApplication::addService '") + service->getPath() + std::string("' already registered!")); diff --git a/src/GattCharacteristic1.cpp b/src/GattCharacteristic1.cpp index 097c34f..b4a4b03 100644 --- a/src/GattCharacteristic1.cpp +++ b/src/GattCharacteristic1.cpp @@ -107,12 +107,12 @@ void GattCharacteristic1::addFlag( std::string flag ) // ---- Default Handlers ------------------------------------------------------- -std::vector GattCharacteristic1::ReadValue(const std::map& options) +std::vector GattCharacteristic1::ReadValue(const std::map& /*options*/) { return value_; } -void GattCharacteristic1::WriteValue(const std::vector& value, const std::map& options) +void GattCharacteristic1::WriteValue(const std::vector& value, const std::map& /*options*/) { value_ = value; } @@ -122,22 +122,22 @@ std::map>> GattCharacteristi throw sdbus::Error("org.bluez.Error.NotSupported", "Property 'GattCharacteristic1::DirectedValue' not overloaded!"); } -std::tuple GattCharacteristic1::AcquireWrite(const std::map& options) +std::tuple GattCharacteristic1::AcquireWrite(const std::map& /*options*/) { throw sdbus::Error("org.bluez.Error.NotSupported", "Method 'GattCharacteristic1::AcquireWrite' not overloaded!"); } -std::tuple GattCharacteristic1::AcquireNotify(const std::map& options) +std::tuple GattCharacteristic1::AcquireNotify(const std::map& /*options*/) { throw sdbus::Error("org.bluez.Error.NotSupported", "Method 'GattCharacteristic1::AcquireNotify' not overloaded!"); } -void GattCharacteristic1::StartNotify(const std::map& options) +void GattCharacteristic1::StartNotify(const std::map& /*options*/) { notifyingSessions_ += 1; } -void GattCharacteristic1::StopNotify(const std::map& options) +void GattCharacteristic1::StopNotify(const std::map& /*options*/) { notifyingSessions_ -= 1; } @@ -152,7 +152,7 @@ void GattCharacteristic1::addDescriptor( std::shared_ptr descri { const std::string& descPath = descriptor->getPath(); - for( auto path : includes_ ) + for( const auto & path : includes_ ) { if( path == descPath ) throw std::invalid_argument(std::string("GattCharacteristic1::addDescriptor '") + descPath + std::string("' already registered!")); diff --git a/src/GattService1.cpp b/src/GattService1.cpp index b7a510f..843f5c1 100644 --- a/src/GattService1.cpp +++ b/src/GattService1.cpp @@ -53,7 +53,7 @@ GattService1::~GattService1() void GattService1::addCharacteristic( std::shared_ptr characteristic ) { - for( auto chrc : characteristics_ ) + for( const auto & chrc : characteristics_ ) { if( chrc == characteristic ) throw std::invalid_argument(std::string("GattService1::addCharacteristic '") + characteristic->getPath() + std::string("' already registered!")); @@ -78,7 +78,7 @@ void GattService1::addSubService( std::shared_ptr service ) { const std::string& srvPath = service->getPath(); - for( auto path : includes_ ) + for( const auto & path : includes_ ) { if( path == srvPath ) throw std::invalid_argument(std::string("GattService1::addSubService '") + srvPath + std::string("' already registered!"));