libdcp
Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
dcp::Asset Class Referenceabstract

Parent class for DCP assets, i.e. picture, sound, subtitles, closed captions, CPLs, fonts. More...

#include <asset.h>

Inheritance diagram for dcp::Asset:
dcp::Object dcp::AtmosAsset dcp::CPL dcp::FontAsset dcp::PictureAsset dcp::SoundAsset dcp::TextAsset dcp::J2KPictureAsset dcp::MPEG2PictureAsset dcp::InteropTextAsset dcp::SMPTETextAsset dcp::MonoJ2KPictureAsset dcp::StereoJ2KPictureAsset dcp::MonoMPEG2PictureAsset

Public Member Functions

 Asset ()
 
 Asset (boost::filesystem::path file)
 
 Asset (std::string id, boost::filesystem::path file)
 
virtual bool equals (std::shared_ptr< const Asset > other, EqualityOptions const &opt, NoteHandler note) const
 
virtual void add_to_assetmap (AssetMap &asset_map, boost::filesystem::path root) const
 
virtual void add_to_pkl (std::shared_ptr< PKL > pkl, boost::filesystem::path root) const
 
boost::optional< boost::filesystem::path > file () const
 
void set_file (boost::filesystem::path file) const
 
void set_file_preserving_hash (boost::filesystem::path file) const
 
void rename_file (boost::filesystem::path file)
 
std::string hash (boost::function< void(int64_t, int64_t)> progress={}) const
 
void set_hash (std::string hash)
 
void unset_hash ()
 
- Public Member Functions inherited from dcp::Object
 Object ()
 
 Object (std::string id)
 
 Object (Object const &other)
 
Objectoperator= (Object const &other)
 
std::string id () const
 

Static Protected Member Functions

static void add_file_to_assetmap (AssetMap &asset_map, boost::filesystem::path root, boost::filesystem::path file, std::string id)
 

Protected Attributes

boost::optional< boost::filesystem::path > _file
 
- Protected Attributes inherited from dcp::Object
std::string _id
 

Private Member Functions

virtual std::string pkl_type (Standard standard) const =0
 

Private Attributes

boost::optional< std::string > _hash
 

Friends

struct ::asset_test
 

Detailed Description

Parent class for DCP assets, i.e. picture, sound, subtitles, closed captions, CPLs, fonts.

Note that this class is not used for ReelAssets; those are just for the metadata that gets put into <Reel>s.

Definition at line 72 of file asset.h.

Constructor & Destructor Documentation

◆ Asset() [1/3]

Asset::Asset ( )

Create an Asset with a randomly-generated ID

Definition at line 64 of file asset.cc.

◆ Asset() [2/3]

Asset::Asset ( boost::filesystem::path  file)
explicit

Create an Asset from a given file with a randomly-generated ID

Parameters
fileFile name

Definition at line 70 of file asset.cc.

◆ Asset() [3/3]

Asset::Asset ( std::string  id,
boost::filesystem::path  file 
)

Create an Asset from a given file with a given ID

Parameters
idID
fileFile name

Definition at line 77 of file asset.cc.

Member Function Documentation

◆ file()

boost::optional<boost::filesystem::path> dcp::Asset::file ( ) const
inline
Returns
the most recent disk file used to read or write this asset, if there is one

Definition at line 100 of file asset.h.

◆ hash()

std::string dcp::Asset::hash ( boost::function< void(int64_t, int64_t)>  progress = {}) const

Calculate the hash of this asset's file, if it has not already been calculated, then return it

Parameters
progressFunction that will be called with the number of bytes calculated and the total number of bytes
Returns
the hash

◆ pkl_type()

virtual std::string dcp::Asset::pkl_type ( Standard  standard) const
privatepure virtual

◆ rename_file()

void Asset::rename_file ( boost::filesystem::path  file)

Set the file that holds this asset on disk. The new file must be exactly the same as the old one, as this function assumes that the object's hash does not change.

Parameters
fileNew file's path.

Definition at line 178 of file asset.cc.

◆ set_file()

void Asset::set_file ( boost::filesystem::path  file) const

Set the file that holds this asset on disk. Calling this function clears this object's store of its hash, so you should call ::hash after this.

Parameters
fileNew file's path.

Definition at line 163 of file asset.cc.

◆ set_file_preserving_hash()

void Asset::set_file_preserving_hash ( boost::filesystem::path  file) const

Set the file that holds this asset on disk. Calling this function preserves the object's store of its hash, so if the object already has a hash it is up to the caller to ensure that the new file has the same hash.

Parameters
fileNew file's path.

Definition at line 171 of file asset.cc.

Member Data Documentation

◆ _file

boost::optional<boost::filesystem::path> dcp::Asset::_file
mutableprotected

The most recent disk file used to read or write this asset

Definition at line 143 of file asset.h.

◆ _hash

boost::optional<std::string> dcp::Asset::_hash
mutableprivate

Hash of _file if it has been computed

Definition at line 154 of file asset.h.


The documentation for this class was generated from the following files: