diff options
author | Pierre Langlois <pierre.langlois@arm.com> | 2015-03-09 16:20:32 +0000 |
---|---|---|
committer | Pierre Langlois <pierre.langlois@arm.com> | 2016-03-04 17:48:52 +0000 |
commit | 2c1edebe30ee9e202e495c88eb31b29a54d05b01 (patch) | |
tree | c82cb9f200e05bee2e5ed7e8d37545450018678c | |
parent | 32e5852cde58198945b919cfa35beac7591f2c59 (diff) | |
download | kdbinder-2c1edebe30ee9e202e495c88eb31b29a54d05b01.tar.gz |
libkdbinder: kdbus: add KDBUS_DISALLOW_COPY_AND_ASSIGN
This commit adds a shorthand macro for deleting both the copy
constructor and the copy asignment operator. This macro is defined in
globals.h so we had to move this file into the include/ directory.
Change-Id: I83f20d40fe8ec8e1065ecda4ddbef9775b211520
-rw-r--r-- | include/kdbinder/kdbus/bus.h | 5 | ||||
-rw-r--r-- | include/kdbinder/kdbus/connection.h | 4 | ||||
-rw-r--r-- | include/kdbinder/kdbus/globals.h (renamed from libs/kdbinder/kdbus/globals.h) | 10 | ||||
-rw-r--r-- | include/kdbinder/kdbus/message.h | 4 | ||||
-rw-r--r-- | libs/kdbinder/kdbus/item.cpp | 3 | ||||
-rw-r--r-- | libs/kdbinder/kdbus/iterable.h | 4 | ||||
-rw-r--r-- | libs/kdbinder/kdbus/message.cpp | 3 |
7 files changed, 18 insertions, 15 deletions
diff --git a/include/kdbinder/kdbus/bus.h b/include/kdbinder/kdbus/bus.h index 879550e..c582976 100644 --- a/include/kdbinder/kdbus/bus.h +++ b/include/kdbinder/kdbus/bus.h @@ -16,6 +16,8 @@ #ifndef INCLUDE_KDBINDER_KDBUS_BUS_H_ #define INCLUDE_KDBINDER_KDBUS_BUS_H_ +#include <kdbinder/kdbus/globals.h> + #include <string> #include <memory> #include <cstdio> @@ -41,8 +43,7 @@ class Bus { // Note that deleting them does not do anything here, as the compiler would do // it anyway. The reason for this is that the class contains a non-copyable // member (std::unique_ptr). In any cases, explicit is better than implicit. - Bus(const Bus&) = delete; - Bus& operator=(const Bus&) = delete; + KDBUS_DISALLOW_COPY_AND_ASSIGN(Bus); bool IsAlive() const { return control_file_ != nullptr; diff --git a/include/kdbinder/kdbus/connection.h b/include/kdbinder/kdbus/connection.h index 14ea750..ef5f219 100644 --- a/include/kdbinder/kdbus/connection.h +++ b/include/kdbinder/kdbus/connection.h @@ -18,6 +18,7 @@ #include <kdbinder/kdbus/bus.h> #include <kdbinder/kdbus/message.h> +#include <kdbinder/kdbus/globals.h> // TODO: We need to include <sys/limits.h> because <vector> needs // CHAR_BIT defined. @@ -104,8 +105,7 @@ class Connection { // A Connection is not copyable as it has exclusive ownership of a // memory mapped area. - Connection(const Connection&) = delete; - Connection& operator=(const Connection&) = delete; + KDBUS_DISALLOW_COPY_AND_ASSIGN(Connection); Connection(Connection&&) = default; Connection& operator=(Connection&&) = default; diff --git a/libs/kdbinder/kdbus/globals.h b/include/kdbinder/kdbus/globals.h index 34418e5..e75c1fe 100644 --- a/libs/kdbinder/kdbus/globals.h +++ b/include/kdbinder/kdbus/globals.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBS_KDBINDER_KDBUS_GLOBALS_H_ -#define LIBS_KDBINDER_KDBUS_GLOBALS_H_ +#ifndef INCLUDE_KDBINDER_KDBUS_GLOBALS_H_ +#define INCLUDE_KDBINDER_KDBUS_GLOBALS_H_ #include <cstdint> @@ -26,6 +26,10 @@ #define KDBUS_CHECK(cond) if (!(cond)) std::terminate() #define KDBUS_STATIC_ASSERT(cond) static_assert(cond, "") +#define KDBUS_DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete + namespace android { namespace kdbus { @@ -42,4 +46,4 @@ constexpr uint64_t kAlignTo8Bit(uint64_t s) { } // namespace kdbus } // namespace android -#endif // LIBS_KDBINDER_KDBUS_GLOBALS_H_ +#endif // INCLUDE_KDBINDER_KDBUS_GLOBALS_H_ diff --git a/include/kdbinder/kdbus/message.h b/include/kdbinder/kdbus/message.h index 9c59e9c..c37ed9a 100644 --- a/include/kdbinder/kdbus/message.h +++ b/include/kdbinder/kdbus/message.h @@ -17,6 +17,7 @@ #define INCLUDE_KDBINDER_KDBUS_MESSAGE_H_ #include <kdbinder/kdbus/item.h> +#include <kdbinder/kdbus/globals.h> // TODO: We need to include <sys/limits.h> because <vector> needs // CHAR_BIT defined. @@ -53,8 +54,7 @@ class Message { Message(Message&&) = default; Message& operator=(Message&&) = default; - Message(const Message&) = delete; - Message& operator=(const Message&) = delete; + KDBUS_DISALLOW_COPY_AND_ASSIGN(Message); uint64_t get_address() const { return reinterpret_cast<uint64_t>(msg_.get()); diff --git a/libs/kdbinder/kdbus/item.cpp b/libs/kdbinder/kdbus/item.cpp index 1d70922..2351a78 100644 --- a/libs/kdbinder/kdbus/item.cpp +++ b/libs/kdbinder/kdbus/item.cpp @@ -15,12 +15,11 @@ */ #include <kdbinder/kdbus/item.h> +#include <kdbinder/kdbus/globals.h> #include <kdbus.h> #include <string> -#include "kdbus/globals.h" - namespace android { namespace kdbus { diff --git a/libs/kdbinder/kdbus/iterable.h b/libs/kdbinder/kdbus/iterable.h index ab8e4c4..1ac8d7c 100644 --- a/libs/kdbinder/kdbus/iterable.h +++ b/libs/kdbinder/kdbus/iterable.h @@ -16,12 +16,12 @@ #ifndef LIBS_KDBINDER_KDBUS_ITERABLE_H_ #define LIBS_KDBINDER_KDBUS_ITERABLE_H_ +#include <kdbinder/kdbus/globals.h> + #include <kdbus.h> #include <functional> -#include "kdbus/globals.h" - namespace android { namespace kdbus { diff --git a/libs/kdbinder/kdbus/message.cpp b/libs/kdbinder/kdbus/message.cpp index 0e0c297..054c3d9 100644 --- a/libs/kdbinder/kdbus/message.cpp +++ b/libs/kdbinder/kdbus/message.cpp @@ -16,6 +16,7 @@ #include <kdbinder/kdbus/message.h> #include <kdbinder/kdbus/item.h> +#include <kdbinder/kdbus/globals.h> #include <kdbus.h> @@ -23,8 +24,6 @@ #include <ctime> #include <vector> -#include "kdbus/globals.h" - namespace android { namespace kdbus { |