diff options
-rw-r--r-- | include/libcamera/class.h | 18 | ||||
-rw-r--r-- | src/libcamera/class.cpp | 57 |
2 files changed, 75 insertions, 0 deletions
diff --git a/include/libcamera/class.h b/include/libcamera/class.h index cb278e58..920624d8 100644 --- a/include/libcamera/class.h +++ b/include/libcamera/class.h @@ -12,6 +12,24 @@ namespace libcamera { #ifndef __DOXYGEN__ +#define LIBCAMERA_DISABLE_COPY(klass) \ + klass(const klass &) = delete; \ + klass &operator=(const klass &) = delete; + +#define LIBCAMERA_DISABLE_MOVE(klass) \ + klass(klass &&) = delete; \ + klass &operator=(klass &&) = delete; + +#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) \ + LIBCAMERA_DISABLE_COPY(klass) \ + LIBCAMERA_DISABLE_MOVE(klass) +#else +#define LIBCAMERA_DISABLE_COPY(klass) +#define LIBCAMERA_DISABLE_MOVE(klass) +#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass) +#endif + +#ifndef __DOXYGEN__ #define LIBCAMERA_DECLARE_PRIVATE(klass) \ public: \ class Private; \ diff --git a/src/libcamera/class.cpp b/src/libcamera/class.cpp index ce230be9..340b7de7 100644 --- a/src/libcamera/class.cpp +++ b/src/libcamera/class.cpp @@ -18,6 +18,63 @@ namespace libcamera { /** + * \def LIBCAMERA_DISABLE_COPY + * \brief Disable copy construction and assignment of the \a klass + * \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonCopyable + * { + * public: + * NonCopyable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_COPY(NonCopyable) + * }; + * \endcode + */ + +/** + * \def LIBCAMERA_DISABLE_MOVE + * \brief Disable move construction and assignment of the \a klass + * \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonMoveable + * { + * public: + * NonMoveable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_MOVE(NonMoveable) + * }; + * \endcode + */ + +/** + * \def LIBCAMERA_DISABLE_COPY_AND_MOVE + * \brief Disable copy and move construction and assignment of the \a klass + * \param klass The name of the class + * + * Example usage: + * \code{.cpp} + * class NonCopyableNonMoveable + * { + * public: + * NonCopyableNonMoveable(); + * ... + * + * private: + * LIBCAMERA_DISABLE_COPY_AND_MOVE(NonCopyableNonMoveable) + * }; + * \endcode + */ + +/** * \def LIBCAMERA_DECLARE_PRIVATE * \brief Declare private data for a public class * \param klass The public class name |