diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-12-16 20:20:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-12-16 20:20:47 +0000 |
| commit | ff896d5f5ec20e1371b423bb746c32fa55cc126a (patch) | |
| tree | bcd6f76709753812c8a988ad43c1f7b8727c6f28 /src | |
| parent | 7a8bf6efd00161b1ce7bb160bd50a0c11c28d792 (diff) | |
Ref does not need to be a template since it's always used for Asset.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 4 | ||||
| -rw-r--r-- | src/cpl.h | 2 | ||||
| -rw-r--r-- | src/dcp.cc | 12 | ||||
| -rw-r--r-- | src/dcp.h | 2 | ||||
| -rw-r--r-- | src/interop_subtitle_asset.cc | 4 | ||||
| -rw-r--r-- | src/interop_subtitle_asset.h | 2 | ||||
| -rw-r--r-- | src/reel.cc | 12 | ||||
| -rw-r--r-- | src/reel.h | 2 | ||||
| -rw-r--r-- | src/reel_asset.cc | 4 | ||||
| -rw-r--r-- | src/reel_asset.h | 6 | ||||
| -rw-r--r-- | src/reel_mono_picture_asset.h | 11 | ||||
| -rw-r--r-- | src/reel_picture_asset.h | 7 | ||||
| -rw-r--r-- | src/reel_sound_asset.h | 5 | ||||
| -rw-r--r-- | src/reel_stereo_picture_asset.h | 12 | ||||
| -rw-r--r-- | src/reel_subtitle_asset.h | 2 | ||||
| -rw-r--r-- | src/ref.h | 48 | ||||
| -rw-r--r-- | src/util.h | 15 | ||||
| -rw-r--r-- | src/wscript | 1 |
18 files changed, 79 insertions, 72 deletions
@@ -236,10 +236,10 @@ CPL::add (DecryptedKDM const & kdm) } void -CPL::resolve_refs (list<shared_ptr<Object> > objects) +CPL::resolve_refs (list<shared_ptr<Asset> > assets) { BOOST_FOREACH (shared_ptr<Reel> i, _reels) { - i->resolve_refs (objects); + i->resolve_refs (assets); } } @@ -111,7 +111,7 @@ public: boost::shared_ptr<const CertificateChain> ) const; - void resolve_refs (std::list<boost::shared_ptr<Object> >); + void resolve_refs (std::list<boost::shared_ptr<Asset> >); protected: /** @return type string for PKLs for this asset */ @@ -181,7 +181,15 @@ DCP::read (bool keep_going, ReadErrors* errors) } BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { - i->resolve_refs (list_of_type<Asset, Object> (other_assets)); + i->resolve_refs (other_assets); + } +} + +void +DCP::resolve_refs (list<shared_ptr<Asset> > assets) +{ + BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { + i->resolve_refs (assets); } } @@ -429,7 +437,7 @@ DCP::assets () const BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { assets.push_back (i); BOOST_FOREACH (shared_ptr<const ReelAsset> j, i->reel_assets ()) { - shared_ptr<Asset> o = j->asset_ref().object (); + shared_ptr<Asset> o = j->asset_ref().asset (); assets.push_back (o); /* More Interop special-casing */ shared_ptr<InteropSubtitleAsset> sub = dynamic_pointer_cast<InteropSubtitleAsset> (o); @@ -97,6 +97,8 @@ public: boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> () ); + void resolve_refs (std::list<boost::shared_ptr<Asset> > assets); + private: /** Write the PKL file. diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index 4ba24a19..a2742b78 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -181,9 +181,9 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const } void -InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Object> > objects) +InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Asset> > assets) { - BOOST_FOREACH (shared_ptr<Object> i, objects) { + BOOST_FOREACH (shared_ptr<Asset> i, assets) { shared_ptr<FontAsset> font = dynamic_pointer_cast<FontAsset> (i); if (!font) { continue; diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h index fe38a0c9..399878d4 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_subtitle_asset.h @@ -51,7 +51,7 @@ public: std::string xml_as_string () const; void write (boost::filesystem::path path) const; - void resolve_fonts (std::list<boost::shared_ptr<Object> > objects); + void resolve_fonts (std::list<boost::shared_ptr<Asset> > assets); void add_font_assets (std::list<boost::shared_ptr<Asset> >& assets); /** Set the reel number or sub-element identifier diff --git a/src/reel.cc b/src/reel.cc index 3c3c7892..ddab12d3 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -165,23 +165,23 @@ Reel::add (shared_ptr<ReelAsset> asset) } void -Reel::resolve_refs (list<shared_ptr<Object> > objects) +Reel::resolve_refs (list<shared_ptr<Asset> > assets) { if (_main_picture) { - _main_picture->asset_ref().resolve (objects); + _main_picture->asset_ref().resolve (assets); } if (_main_sound) { - _main_sound->asset_ref().resolve (objects); + _main_sound->asset_ref().resolve (assets); } if (_main_subtitle) { - _main_subtitle->asset_ref().resolve (objects); + _main_subtitle->asset_ref().resolve (assets); /* Interop subtitle handling is all special cases */ - shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().object ()); + shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().asset ()); if (iop) { - iop->resolve_fonts (objects); + iop->resolve_fonts (assets); } } } @@ -81,7 +81,7 @@ public: void add (DecryptedKDM const &); - void resolve_refs (std::list<boost::shared_ptr<Object> >); + void resolve_refs (std::list<boost::shared_ptr<Asset> >); private: boost::shared_ptr<ReelPictureAsset> _main_picture; diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 46e0bd3c..ecaaa1fc 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -96,7 +96,7 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration)); a->add_child("EntryPoint")->add_child_text (raw_convert<string> (_entry_point)); a->add_child("Duration")->add_child_text (raw_convert<string> (_duration)); - a->add_child("Hash")->add_child_text (_asset_ref.object()->hash ()); + a->add_child("Hash")->add_child_text (_asset_ref.asset()->hash ()); } pair<string, string> @@ -149,7 +149,7 @@ ReelAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, NoteH } if (_asset_ref.resolved () && other->_asset_ref.resolved ()) { - return _asset_ref->equals (other->_asset_ref.object (), opt, note); + return _asset_ref->equals (other->_asset_ref.asset(), opt, note); } return true; diff --git a/src/reel_asset.h b/src/reel_asset.h index 6c501abf..9211fbd1 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -59,12 +59,12 @@ public: virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, NoteHandler) const; /** @return a Ref to our actual asset */ - Ref<Asset> const & asset_ref () const { + Ref const & asset_ref () const { return _asset_ref; } /** @return a Ref to our actual asset */ - Ref<Asset>& asset_ref () { + Ref & asset_ref () { return _asset_ref; } @@ -98,7 +98,7 @@ protected: /** Reference to the asset (MXF or XML file) that this reel entry * applies to. */ - Ref<Asset> _asset_ref; + Ref _asset_ref; private: std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset diff --git a/src/reel_mono_picture_asset.h b/src/reel_mono_picture_asset.h index 54450233..da2eb087 100644 --- a/src/reel_mono_picture_asset.h +++ b/src/reel_mono_picture_asset.h @@ -25,6 +25,7 @@ #define LIBDCP_REEL_MONO_PICTURE_ASSET_H #include "reel_picture_asset.h" +#include "mono_picture_asset.h" namespace dcp { @@ -40,6 +41,16 @@ public: ReelMonoPictureAsset (boost::shared_ptr<MonoPictureAsset> asset, int64_t entry_point); ReelMonoPictureAsset (boost::shared_ptr<const cxml::Node>); + /** @return the MonoPictureAsset that this object refers to */ + boost::shared_ptr<const MonoPictureAsset> mono_asset () const { + return boost::dynamic_pointer_cast<const MonoPictureAsset> (_asset_ref.asset ()); + } + + /** @return the MonoPictureAsset that this object refers to */ + boost::shared_ptr<MonoPictureAsset> mono_asset () { + return boost::dynamic_pointer_cast<MonoPictureAsset> (_asset_ref.asset ()); + } + private: std::string cpl_node_name () const; }; diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h index 15b01b74..39ef3431 100644 --- a/src/reel_picture_asset.h +++ b/src/reel_picture_asset.h @@ -44,8 +44,13 @@ public: virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, NoteHandler) const; /** @return the PictureAsset that this object refers to */ + boost::shared_ptr<const PictureAsset> asset () const { + return boost::dynamic_pointer_cast<const PictureAsset> (_asset_ref.asset ()); + } + + /** @return the PictureAsset that this object refers to */ boost::shared_ptr<PictureAsset> asset () { - return boost::dynamic_pointer_cast<PictureAsset> (_asset_ref.object ()); + return boost::dynamic_pointer_cast<PictureAsset> (_asset_ref.asset ()); } /** @return picture frame rate */ diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index 8f39e8a0..3158f8a0 100644 --- a/src/reel_sound_asset.h +++ b/src/reel_sound_asset.h @@ -42,12 +42,12 @@ public: /** @return the SoundAsset that this object refers to */ boost::shared_ptr<SoundAsset> asset () { - return boost::dynamic_pointer_cast<SoundAsset> (_asset_ref.object ()); + return boost::dynamic_pointer_cast<SoundAsset> (_asset_ref.asset ()); } /** @return the SoundAsset that this object refers to */ boost::shared_ptr<const SoundAsset> asset () const { - return boost::dynamic_pointer_cast<const SoundAsset> (_asset_ref.object ()); + return boost::dynamic_pointer_cast<const SoundAsset> (_asset_ref.asset ()); } private: @@ -56,4 +56,3 @@ private: }; } - diff --git a/src/reel_stereo_picture_asset.h b/src/reel_stereo_picture_asset.h index 72b225bc..3c68f887 100644 --- a/src/reel_stereo_picture_asset.h +++ b/src/reel_stereo_picture_asset.h @@ -25,6 +25,7 @@ #define LIBDCP_REEL_STEREO_PICTURE_ASSET_H #include "reel_picture_asset.h" +#include "stereo_picture_asset.h" namespace dcp { @@ -40,6 +41,16 @@ public: ReelStereoPictureAsset (boost::shared_ptr<StereoPictureAsset> content, int64_t entry_point); ReelStereoPictureAsset (boost::shared_ptr<const cxml::Node>); + /** @return the StereoPictureAsset that this object refers to */ + boost::shared_ptr<const StereoPictureAsset> stereo_asset () const { + return boost::dynamic_pointer_cast<const StereoPictureAsset> (_asset_ref.asset ()); + } + + /** @return the StereoPictureAsset that this object refers to */ + boost::shared_ptr<StereoPictureAsset> stereo_asset () { + return boost::dynamic_pointer_cast<StereoPictureAsset> (_asset_ref.asset ()); + } + private: std::string cpl_node_name () const; std::pair<std::string, std::string> cpl_node_attribute (Standard standard) const; @@ -48,4 +59,3 @@ private: } #endif - diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h index d4f11cfa..272b18f5 100644 --- a/src/reel_subtitle_asset.h +++ b/src/reel_subtitle_asset.h @@ -41,7 +41,7 @@ public: ReelSubtitleAsset (boost::shared_ptr<const cxml::Node>); boost::shared_ptr<SubtitleAsset> asset () const { - return boost::dynamic_pointer_cast<SubtitleAsset> (_asset_ref.object ()); + return boost::dynamic_pointer_cast<SubtitleAsset> (_asset_ref.asset ()); } private: @@ -25,7 +25,7 @@ #define LIBDCP_REF_H #include "exceptions.h" -#include "object.h" +#include "asset.h" #include "util.h" #include <boost/shared_ptr.hpp> #include <string> @@ -33,17 +33,16 @@ namespace dcp { /** @class Ref - * @brief A reference to an object which is identified by a universally-unique identifier (UUID). + * @brief A reference to an asset which is identified by a universally-unique identifier (UUID). * * This class is a `pointer' to a thing. It will always know the * UUID of the thing, and it may have a shared_ptr to the C++ object * which represents the thing. * * If the Ref does not have a shared_ptr it may be given one by - * calling resolve() with a list of objects. The shared_ptr will be + * calling resolve() with a list of assets. The shared_ptr will be * set up using any object on the list which has a matching ID. */ -template<class T> class Ref { public: @@ -52,10 +51,10 @@ public: : _id (id) {} - /** Initialise a Ref with a shared_ptr to an object */ - Ref (boost::shared_ptr<T> object) - : _id (object->id ()) - , _object (object) + /** Initialise a Ref with a shared_ptr to an asset */ + Ref (boost::shared_ptr<Asset> asset) + : _id (asset->id ()) + , _asset (asset) {} /** Set the ID of this Ref */ @@ -64,20 +63,7 @@ public: _id = id; } - /** Look through a list of objects and copy a shared_ptr to any object - * which matches the ID of this one. - */ - void resolve (std::list<boost::shared_ptr<Object> > objects) - { - typename std::list<boost::shared_ptr<Object> >::iterator i = objects.begin(); - while (i != objects.end() && !ids_equal ((*i)->id(), _id)) { - ++i; - } - - if (i != objects.end ()) { - _object = boost::dynamic_pointer_cast<T> (*i); - } - } + void resolve (std::list<boost::shared_ptr<Asset> > assets); /** @return the ID of the thing that we are pointing to */ std::string id () const { @@ -87,33 +73,33 @@ public: /** @return a shared_ptr to the thing; an UnresolvedRefError is thrown * if the shared_ptr is not known. */ - boost::shared_ptr<T> object () const { - if (!_object) { + boost::shared_ptr<Asset> asset () const { + if (!_asset) { throw UnresolvedRefError (_id); } - return _object; + return _asset; } /** operator-> to access the shared_ptr; an UnresolvedRefError is thrown * if the shared_ptr is not known. */ - T * operator->() const { - if (!_object) { + Asset * operator->() const { + if (!_asset) { throw UnresolvedRefError (_id); } - return _object.get (); + return _asset.get (); } /** @return true if a shared_ptr is known for this Ref */ bool resolved () const { - return static_cast<bool>(_object); + return static_cast<bool>(_asset); } private: - std::string _id; ///< ID; will always be known - boost::shared_ptr<T> _object; ///< shared_ptr to the thing, may be null. + std::string _id; ///< ID; will always be known + boost::shared_ptr<Asset> _asset; ///< shared_ptr to the thing, may be null. }; } @@ -65,21 +65,6 @@ extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length extern std::string private_key_fingerprint (std::string key); extern xmlpp::Node* find_child (xmlpp::Node const * node, std::string name); -template <class F, class T> -std::list<boost::shared_ptr<T> > -list_of_type (std::list<boost::shared_ptr<F> > const & from) -{ - std::list<boost::shared_ptr<T> > out; - for (typename std::list<boost::shared_ptr<F> >::const_iterator i = from.begin(); i != from.end(); ++i) { - boost::shared_ptr<T> check = boost::dynamic_pointer_cast<T> (*i); - if (check) { - out.push_back (check); - } - } - - return out; -} - } #endif diff --git a/src/wscript b/src/wscript index 33802785..16a17381 100644 --- a/src/wscript +++ b/src/wscript @@ -43,6 +43,7 @@ def build(bld): reel_sound_asset.cc reel_stereo_picture_asset.cc reel_subtitle_asset.cc + ref.cc rgb_xyz.cc smpte_load_font_node.cc smpte_subtitle_asset.cc |
