TracktionEngine
Loading...
Searching...
No Matches
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< ProjectItemID > getProjectItemID () 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< Project > getProject () 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:

  • If it parses as a valid ProjectItemID (hex/hex format), it's treated as an ID
  • If it's an absolute file path, it's treated as such
  • Otherwise it's treated as a relative path (resolved against a project folder)

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.

References ProjectItemRef().

◆ ProjectItemRef() [3/4]

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

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

References ProjectItemRef().

◆ ProjectItemRef() [4/4]

engine::ProjectItemRef::ProjectItemRef ( ProjectItemID )

Creates a ref from an existing ProjectItemID.

References ProjectItemRef().

Member Function Documentation

◆ fromPath() [1/2]

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

Creates a ref from a relative path string.

References fromPath(), and ProjectItemRef().

Referenced by fromPath(), and fromPath().

◆ fromPath() [2/2]

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

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

References fromPath(), and ProjectItemRef().

◆ fromAbsolutePath()

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

Creates a ref from an absolute file.

References fromAbsolutePath(), and ProjectItemRef().

Referenced by fromAbsolutePath().

◆ isValid()

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

References isValid().

Referenced by isValid().

◆ isProjectItemID()

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

References isProjectItemID().

Referenced by isProjectItemID().

◆ isRelativePath()

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

References isRelativePath().

Referenced by isRelativePath().

◆ isAbsolutePath()

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

References isAbsolutePath().

Referenced by isAbsolutePath().

◆ getProjectID()

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

Returns the ID of the Project.

See also
Project::getProjectId.

References getProjectID().

Referenced by getProjectID().

◆ getProjectItemID()

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

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

References getProjectItemID().

Referenced by getProjectItemID().

◆ 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.

References toIDForFilename().

Referenced by toIDForFilename().

◆ toString()

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

Returns the raw string value.

References toString().

Referenced by toString().

◆ getProject()

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

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

References getProject().

Referenced by getProject().

◆ 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

References resolve().

Referenced by resolve().

◆ operator==() [1/2]

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

References ProjectItemRef().

◆ operator!=() [1/2]

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

References ProjectItemRef().

◆ operator<()

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

References ProjectItemRef().

◆ operator==() [2/2]

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

◆ operator!=() [2/2]

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

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