libdcp
Public Member Functions | Private Attributes | List of all members
dcp::Ref Class Reference

A reference to an asset which is identified by a universally-unique identifier (UUID) More...

#include <ref.h>

Public Member Functions

 Ref (std::string id)
 
 Ref (std::shared_ptr< Asset > asset)
 
void set_id (std::string id)
 
void resolve (std::vector< std::shared_ptr< Asset >> assets)
 
std::string id () const
 
std::shared_ptr< Assetasset () const
 
Assetoperator-> () const
 
bool resolved () const
 

Private Attributes

std::string _id
 ID; will always be known.
 
std::shared_ptr< Asset_asset
 shared_ptr to the thing, may be null.
 

Detailed Description

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 vector of assets. The shared_ptr will be set up using any object on the vector which has a matching ID.

Definition at line 65 of file ref.h.

Constructor & Destructor Documentation

◆ Ref() [1/2]

dcp::Ref::Ref ( std::string  id)
inlineexplicit

Initialise a Ref with an ID but no shared_ptr

Definition at line 69 of file ref.h.

◆ Ref() [2/2]

dcp::Ref::Ref ( std::shared_ptr< Asset asset)
inlineexplicit

Initialise a Ref with a shared_ptr to an asset

Definition at line 74 of file ref.h.

Member Function Documentation

◆ asset()

std::shared_ptr<Asset> dcp::Ref::asset ( ) const
inline
Returns
a shared_ptr to the thing; an UnresolvedRefError is thrown if the shared_ptr is not known

Definition at line 98 of file ref.h.

◆ id()

std::string dcp::Ref::id ( ) const
inline
Returns
the ID of the thing that we are pointing to

Definition at line 91 of file ref.h.

◆ operator->()

Asset* dcp::Ref::operator-> ( ) const
inline

operator-> to access the shared_ptr; an UnresolvedRefError is thrown if the shared_ptr is not known

Definition at line 109 of file ref.h.

◆ resolve()

void Ref::resolve ( std::vector< std::shared_ptr< Asset >>  assets)

Look through a list of assets and copy a shared_ptr to any asset which matches the ID of this one

Definition at line 49 of file ref.cc.

◆ resolved()

bool dcp::Ref::resolved ( ) const
inline
Returns
true if a shared_ptr is known for this Ref

Definition at line 118 of file ref.h.

◆ set_id()

void dcp::Ref::set_id ( std::string  id)
inline

Set the ID of this Ref

Definition at line 80 of file ref.h.


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