diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-12 14:16:27 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-12 14:16:27 +0000 |
| commit | 1bcf0b11634647a2a6b99330b2854704e5c1bc38 (patch) | |
| tree | 941c8515af2eb63647f61c3dfd5ee2cd876cf6f3 /src | |
| parent | 315f98667668ba59b80033429acf10fb3f4e13fe (diff) | |
Small cleanup.
Diffstat (limited to 'src')
| -rw-r--r-- | src/reel_asset.h | 11 | ||||
| -rw-r--r-- | src/reel_mono_picture_asset.h | 4 | ||||
| -rw-r--r-- | src/reel_picture_asset.h | 4 | ||||
| -rw-r--r-- | src/reel_sound_asset.h | 4 | ||||
| -rw-r--r-- | src/reel_stereo_picture_asset.h | 4 | ||||
| -rw-r--r-- | src/reel_subtitle_asset.h | 2 |
6 files changed, 20 insertions, 9 deletions
diff --git a/src/reel_asset.h b/src/reel_asset.h index 9211fbd1..4ad5b85b 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -85,6 +85,17 @@ public: } protected: + + template <class T> + boost::shared_ptr<T> asset_of_type () const { + return boost::dynamic_pointer_cast<T> (_asset_ref.asset ()); + } + + template <class T> + boost::shared_ptr<T> asset_of_type () { + return boost::dynamic_pointer_cast<T> (_asset_ref.asset ()); + } + /** @return the node name that this asset uses in the CPL's <Reel> node * e.g. MainPicture, MainSound etc. */ diff --git a/src/reel_mono_picture_asset.h b/src/reel_mono_picture_asset.h index da2eb087..4acc8296 100644 --- a/src/reel_mono_picture_asset.h +++ b/src/reel_mono_picture_asset.h @@ -43,12 +43,12 @@ public: /** @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 asset_of_type<const MonoPictureAsset> (); } /** @return the MonoPictureAsset that this object refers to */ boost::shared_ptr<MonoPictureAsset> mono_asset () { - return boost::dynamic_pointer_cast<MonoPictureAsset> (_asset_ref.asset ()); + return asset_of_type<MonoPictureAsset> (); } private: diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h index 39ef3431..1611221f 100644 --- a/src/reel_picture_asset.h +++ b/src/reel_picture_asset.h @@ -45,12 +45,12 @@ public: /** @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 asset_of_type<const PictureAsset> (); } /** @return the PictureAsset that this object refers to */ boost::shared_ptr<PictureAsset> asset () { - return boost::dynamic_pointer_cast<PictureAsset> (_asset_ref.asset ()); + return asset_of_type<PictureAsset> (); } /** @return picture frame rate */ diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index 3158f8a0..fd1a63fe 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.asset ()); + return asset_of_type<SoundAsset> (); } /** @return the SoundAsset that this object refers to */ boost::shared_ptr<const SoundAsset> asset () const { - return boost::dynamic_pointer_cast<const SoundAsset> (_asset_ref.asset ()); + return asset_of_type<const SoundAsset> (); } private: diff --git a/src/reel_stereo_picture_asset.h b/src/reel_stereo_picture_asset.h index 3c68f887..03bb6fd0 100644 --- a/src/reel_stereo_picture_asset.h +++ b/src/reel_stereo_picture_asset.h @@ -43,12 +43,12 @@ public: /** @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 asset_of_type<const StereoPictureAsset> (); } /** @return the StereoPictureAsset that this object refers to */ boost::shared_ptr<StereoPictureAsset> stereo_asset () { - return boost::dynamic_pointer_cast<StereoPictureAsset> (_asset_ref.asset ()); + return asset_of_type<StereoPictureAsset> (); } private: diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h index 272b18f5..fa25bf9d 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.asset ()); + return asset_of_type<SubtitleAsset> (); } private: |
