TracktionEngine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
engine::ProjectItemRef Class Reference

A lightweight reference that can hold either a ProjectItemID or a file path. More...

#include <tracktion_ProjectItemRef.h>

Public Member Functions

 ProjectItemRef () noexcept=default
 
 ProjectItemRef (const juce::String &pathOrID)
 Creates a ref from a string that is either a ProjectItemID or a file path.
 
 ProjectItemRef (const juce::String &pathOrID, Project &owner)
 Creates a ref from a path string with a known owner project.
 
 ProjectItemRef (ProjectItemID)
 Creates a ref from an existing ProjectItemID.
 
bool isValid () const noexcept
 
bool isProjectItemID () const noexcept
 
bool isRelativePath () const noexcept
 
bool isAbsolutePath () const noexcept
 
ProjectID getProjectID () const noexcept
 Returns the ID of the Project.
 
std::optional< ProjectItemIDgetProjectItemID () const noexcept
 Returns the ProjectItemID if this ref is ID-based, otherwise std::nullopt.
 
juce::String toIDForFilename () const noexcept
 Returns a string which can be used for filenames.
 
juce::String toString () const noexcept
 Returns the raw string value.
 
juce::ReferenceCountedObjectPtr< ProjectgetProject () const noexcept
 Returns the owner project, if one was provided at construction.
 
juce::File resolve (Engine &, const juce::File &projectFolder={}) const
 Resolves to a file.
 
bool operator== (const ProjectItemRef &) const
 
bool operator!= (const ProjectItemRef &) const
 
bool operator< (const ProjectItemRef &) const
 
bool operator== (ProjectItemID) const
 
bool operator!= (ProjectItemID) const
 

Static Public Member Functions

static ProjectItemRef fromPath (const juce::String &relativePath)
 Creates a ref from a relative path string.
 
static ProjectItemRef fromPath (const juce::String &relativePath, Project &owner)
 Creates a ref from a relative path with a known owner project.
 
static ProjectItemRef fromAbsolutePath (const juce::File &)
 Creates a ref from an absolute file.
 

Detailed Description

A lightweight reference that can hold either a ProjectItemID or a file path.

The string value is auto-detected:

Constructor & Destructor Documentation

◆ ProjectItemRef() [1/4]

engine::ProjectItemRef::ProjectItemRef ( )
defaultnoexcept

◆ ProjectItemRef() [2/4]

engine::ProjectItemRef::ProjectItemRef ( const juce::String &  pathOrID)
explicit

Creates a ref from a string that is either a ProjectItemID or a file path.

◆ ProjectItemRef() [3/4]

engine::ProjectItemRef::ProjectItemRef ( const juce::String &  pathOrID,
Project owner 
)

Creates a ref from a path string with a known owner project.

◆ ProjectItemRef() [4/4]

engine::ProjectItemRef::ProjectItemRef ( ProjectItemID  )

Creates a ref from an existing ProjectItemID.

Member Function Documentation

◆ fromPath() [1/2]

static ProjectItemRef engine::ProjectItemRef::fromPath ( const juce::String &  relativePath)
static

Creates a ref from a relative path string.

◆ fromPath() [2/2]

static ProjectItemRef engine::ProjectItemRef::fromPath ( const juce::String &  relativePath,
Project owner 
)
static

Creates a ref from a relative path with a known owner project.

◆ fromAbsolutePath()

static ProjectItemRef engine::ProjectItemRef::fromAbsolutePath ( const juce::File &  )
static

Creates a ref from an absolute file.

◆ isValid()

bool engine::ProjectItemRef::isValid ( ) const
noexcept

◆ isProjectItemID()

bool engine::ProjectItemRef::isProjectItemID ( ) const
noexcept

◆ isRelativePath()

bool engine::ProjectItemRef::isRelativePath ( ) const
noexcept

◆ isAbsolutePath()

bool engine::ProjectItemRef::isAbsolutePath ( ) const
noexcept

◆ getProjectID()

ProjectID engine::ProjectItemRef::getProjectID ( ) const
noexcept

Returns the ID of the Project.

See also
Project::getProjectId.

◆ getProjectItemID()

std::optional< ProjectItemID > engine::ProjectItemRef::getProjectItemID ( ) const
noexcept

Returns the ProjectItemID if this ref is ID-based, otherwise std::nullopt.

◆ toIDForFilename()

juce::String engine::ProjectItemRef::toIDForFilename ( ) const
noexcept

Returns a string which can be used for filenames.

This isn't meant for resolution, it will be the ProjectItemID or a hash of path.

◆ toString()

juce::String engine::ProjectItemRef::toString ( ) const
noexcept

Returns the raw string value.

◆ getProject()

juce::ReferenceCountedObjectPtr< Project > engine::ProjectItemRef::getProject ( ) const
noexcept

Returns the owner project, if one was provided at construction.

◆ resolve()

juce::File engine::ProjectItemRef::resolve ( Engine ,
const juce::File &  projectFolder = {} 
) const

Resolves to a file.

  • If ProjectItemID: looks up via engine's ProjectManager
  • If relative path: resolves against the given folder, or the owner project's default directory if no folder is provided
  • If absolute path: returns directly

◆ operator==() [1/2]

bool engine::ProjectItemRef::operator== ( const ProjectItemRef ) const

◆ operator!=() [1/2]

bool engine::ProjectItemRef::operator!= ( const ProjectItemRef ) const

◆ operator<()

bool engine::ProjectItemRef::operator< ( const ProjectItemRef ) const

◆ operator==() [2/2]

bool engine::ProjectItemRef::operator== ( ProjectItemID  ) const

◆ operator!=() [2/2]

bool engine::ProjectItemRef::operator!= ( ProjectItemID  ) const

References engine::value.


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