From f719ac027aeccf8061175874079ef9a48e3c5897 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 6 Dec 2019 13:28:13 +1100 Subject: [PATCH] improved Footage class semantics Set const functions to const and use DISABLE_COPY_MOVE instead of manually deleting copy and move constructors. --- app/project/item/footage/footage.cpp | 16 ++++++------- app/project/item/footage/footage.h | 35 +++++++--------------------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index b82bc16ce..ec33d94dc 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -35,7 +35,7 @@ Footage::~Footage() ClearStreams(); } -const Footage::Status& Footage::status() +const Footage::Status& Footage::status() const { return status_; } @@ -56,7 +56,7 @@ void Footage::Clear() set_status(kUnprobed); } -const QString &Footage::filename() +const QString &Footage::filename() const { return filename_; } @@ -66,7 +66,7 @@ void Footage::set_filename(const QString &s) filename_ = s; } -const QDateTime &Footage::timestamp() +const QDateTime &Footage::timestamp() const { return timestamp_; } @@ -85,17 +85,17 @@ void Footage::add_stream(StreamPtr s) streams_.last()->set_footage(this); } -StreamPtr Footage::stream(int index) +StreamPtr Footage::stream(int index) const { return streams_.at(index); } -const QList &Footage::streams() +const QList &Footage::streams() const { return streams_; } -int Footage::stream_count() +int Footage::stream_count() const { return streams_.size(); } @@ -105,7 +105,7 @@ Item::Type Footage::type() const return kFootage; } -const QString &Footage::decoder() +const QString &Footage::decoder() const { return decoder_; } @@ -139,7 +139,7 @@ QIcon Footage::icon() return olive::icon::Image; } - /* fall through */ + /* fall-through */ case kInvalid: return olive::icon::Error; } diff --git a/app/project/item/footage/footage.h b/app/project/item/footage/footage.h index 53775a467..2059e0544 100644 --- a/app/project/item/footage/footage.h +++ b/app/project/item/footage/footage.h @@ -24,6 +24,7 @@ #include #include +#include "common/constructors.h" #include "common/rational.h" #include "project/item/item.h" #include "project/item/footage/audiostream.h" @@ -59,25 +60,7 @@ public: */ virtual ~Footage() override; - /** - * @brief Deleted copy constructor - */ - Footage(const Footage& other) = delete; - - /** - * @brief Deleted move constructor - */ - Footage(Footage&& other) = delete; - - /** - * @brief Deleted copy assignment - */ - Footage& operator=(const Footage& other) = delete; - - /** - * @brief Deleted move assignment - */ - Footage& operator=(Footage&& other) = delete; + DISABLE_COPY_MOVE(Footage) /** * @brief Check the ready state of this Footage object @@ -86,7 +69,7 @@ public: * * If the Footage has been successfully probed, this will return TRUE. */ - const Status& status(); + const Status& status() const; /** * @brief Set ready state @@ -114,7 +97,7 @@ public: /** * @brief Return the current filename of this Footage object */ - const QString& filename(); + const QString& filename() const; /** * @brief Set the filename @@ -134,7 +117,7 @@ public: * The file's last modified timestamp is stored for potential organization in the ProjectExplorer. It can be * retrieved here. */ - const QDateTime& timestamp(); + const QDateTime& timestamp() const; /** * @brief Set the last modified time/date @@ -172,17 +155,17 @@ public: * * The stream at the index provided */ - StreamPtr stream(int index); + StreamPtr stream(int index) const; /** * @brief Returns a list of the streams in this Footage */ - const QList& streams(); + const QList& streams() const; /** * @brief Retrieve total number of streams in this Footage file */ - int stream_count(); + int stream_count() const; /** * @brief Item::Type() override @@ -198,7 +181,7 @@ public: * * A decoder ID */ - const QString& decoder(); + const QString& decoder() const; /** * @brief Used by decoders when they Probe to attach itself to this Footage