X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fasset_reader.h;fp=src%2Fasset_reader.h;h=859c88f3ef99dd442a3a2e9d15cd3c0368f5fb35;hb=6c37cc1979b2a01205a888c4c98f3334685ee8dd;hp=d1e0f10e8faacf9e35ed2952a7d9e08c6b2d5c05;hpb=b75d977a38f039fd68ed5d4055ae70b4bf631603;p=libdcp.git diff --git a/src/asset_reader.h b/src/asset_reader.h index d1e0f10e..859c88f3 100644 --- a/src/asset_reader.h +++ b/src/asset_reader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of libdcp. @@ -31,34 +31,40 @@ files in the program, then also delete it here. */ + #ifndef LIBDCP_ASSET_READER_H #define LIBDCP_ASSET_READER_H -#include "dcp_assert.h" + #include "asset.h" #include "crypto_context.h" +#include "dcp_assert.h" #include -#include #include + namespace dcp { + template -class AssetReader : public boost::noncopyable +class AssetReader { public: explicit AssetReader (Asset const * asset, boost::optional key, Standard standard) - : _crypto_context (new DecryptionContext (key, standard)) + : _crypto_context (new DecryptionContext(key, standard)) { _reader = new R (); - DCP_ASSERT (asset->file ()); - Kumu::Result_t const r = _reader->OpenRead (asset->file()->string().c_str()); - if (ASDCP_FAILURE (r)) { + DCP_ASSERT (asset->file()); + auto const r = _reader->OpenRead (asset->file()->string().c_str()); + if (ASDCP_FAILURE(r)) { delete _reader; - boost::throw_exception (FileError ("could not open MXF file for reading", asset->file().get(), r)); + boost::throw_exception (FileError("could not open MXF file for reading", asset->file().get(), r)); } } + AssetReader (AssetReader const&) = delete; + AssetReader& operator== (AssetReader const&) = delete; + ~AssetReader () { delete _reader; @@ -66,7 +72,7 @@ public: std::shared_ptr get_frame (int n) const { - return std::shared_ptr (new F (_reader, n, _crypto_context)); + return std::shared_ptr (new F(_reader, n, _crypto_context)); } R* reader () const { @@ -74,10 +80,12 @@ public: } protected: - R* _reader; + R* _reader = nullptr; std::shared_ptr _crypto_context; }; + } + #endif