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::SubtitleAsset dcp::MonoPictureAsset dcp::StereoPictureAsset dcp::InteropSubtitleAsset dcp::SMPTESubtitleAsset

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 opt, NoteHandler note) const
 
virtual void write_to_assetmap (xmlpp::Node *node, 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
 
std::string hash (boost::function< void(float)> progress={}) const
 
void set_hash (std::string hash)
 
- Public Member Functions inherited from dcp::Object
 Object ()
 
 Object (std::string id)
 
 Object (Object const &)=delete
 
Objectoperator= (Object const &)=delete
 
std::string id () const
 

Static Protected Member Functions

static void write_file_to_assetmap (xmlpp::Node *node, 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 69 of file asset.h.

Constructor & Destructor Documentation

◆ Asset() [1/3]

Asset::Asset ( )

Create an Asset with a randomly-generated ID

Definition at line 62 of file asset.cc.

◆ Asset() [2/3]

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

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

Parameters
fileFile name

◆ Asset() [3/3]

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

Create an Asset from a given file with a given ID

Parameters
idID
fileFile name

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 97 of file asset.h.

◆ hash()

std::string dcp::Asset::hash ( boost::function< void(float)>  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 a parameter between 0 and 1 to indicate progress in the calculation
Returns
the hash

◆ pkl_type()

virtual std::string dcp::Asset::pkl_type ( Standard  standard) const
privatepure virtual
Returns
type string for PKLs for this asset

Implemented in dcp::PictureAsset, dcp::FontAsset, dcp::CPL, dcp::SMPTESubtitleAsset, dcp::InteropSubtitleAsset, and dcp::AtmosAsset.

◆ 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 165 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 122 of file asset.h.

◆ _hash

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

Hash of _file if it has been computed

Definition at line 133 of file asset.h.


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