EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
echomap::PartialProject Class Reference

A Project with semantics for expressing an incomplete set of owned Signal objects. More...

#include <PartialProject.hpp>

Inheritance diagram for echomap::PartialProject:
[legend]

Public Member Functions

 PartialProject (std::string_view project_name={})
void indicate_unloaded_signal (std::unique_ptr< SignalFactory > &&factory)
 Provide the factory for an unloaded Signal.
void add_vfs_mapping_for_unavailable_signal (const std::filesystem::path &external, std::filesystem::path &&internal)
 Provide a VFS mapping for a previously indicated unloaded Signal.
auto observe_unloaded_signals () const noexcept
 Provide an observing view to the unloaded signals.
auto take_unloaded_factories () noexcept
 Provide a view to the mutable unloaded SignalFactory objects.
Public Member Functions inherited from echomap::Project
 Project (std::string_view project_name={})
 Creates a new named Project.
const Signaladd_signal (std::shared_ptr< Signal > &&signal)
 Transfers ownership of a Signal into the Project.
const Sensoradd_sensor (std::unique_ptr< Sensor > &&sensor)
 Transfers ownership of a Sensor into the Project.
void add_association (const Signal &signal, const Sensor &sensor)
 Creates a new association between a Signal and Sensor.
void add_association (id_type signal_id, id_type sensor_id)
 Creates a new association between a Signal and Sensor.
auto observe_signals () const noexcept
 Provides a transformed view for stored Signal objects in the Project.
auto share_signals () const noexcept
 Provides a view of Signal objects detained in shared-ownership containers.
size_t get_sensors_count () const noexcept
 Checks if any Sensor objects are owned by the Project.
auto observe_sensors () const noexcept
 Provides a transformed view for stored Sensor objects in the Project.
auto observe_associations () const
 Provides a transformed view for defined channel mappings.
Sensorget_mutable_sensor (id_type sensor_id)
 Retrieve a mutable reference to the Sensor with the given ID.
Public Member Functions inherited from echomap::Object< Project >
 ~Object ()=default
 Non-virtual base destructor.
id_type get_id () const noexcept
bool is_valid () const noexcept
void set_name (const std::string_view new_name)
std::string_view get_name () const noexcept
const char * get_imgui_name () const noexcept
 Object (const Object &)=delete
Object & operator= (const Object &)=delete
bool operator== (const Object &other) const noexcept
 Determine shallow equality between two Object instances.

Private Attributes

std::map< std::filesystem::path, std::pair< std::optional< std::filesystem::path >, std::vector< std::unique_ptr< SignalFactory > > > > unloaded_signals
 Provides a mapping between stated paths of externally sourced signals, and paths in the WebAssembly VFS.

Additional Inherited Members

Static Public Member Functions inherited from echomap::Project
static ImPlot3DPoint get_sensor_point (int idx, const void *project_instance) noexcept
Static Public Member Functions inherited from echomap::Object< Project >
static std::string_view get_class_name () noexcept
Protected Member Functions inherited from echomap::Object< Project >
void move_identity_from (Object &&other) noexcept
 Helper for derived classes to provide move-assignment operations.

Detailed Description

A Project with semantics for expressing an incomplete set of owned Signal objects.

In addition to the regular Project, the PartialProject detains a number of SignalFactory objects that are reserved to construct Signal instances once their external sources become available. This is useful in WebAssembly environments to model mappings between the Signal path specified in the Project metadata, and a mapping to the Wasm VFS path.

Definition at line 31 of file PartialProject.hpp.

Constructor & Destructor Documentation

◆ PartialProject()

echomap::PartialProject::PartialProject ( std::string_view project_name = {})
explicit

Definition at line 19 of file PartialProject.cpp.

21 :
22 Project(project_name)
23{
24}
Project(std::string_view project_name={})
Creates a new named Project.
Definition Project.cpp:15

Member Function Documentation

◆ add_vfs_mapping_for_unavailable_signal()

void echomap::PartialProject::add_vfs_mapping_for_unavailable_signal ( const std::filesystem::path & external,
std::filesystem::path && internal )

Provide a VFS mapping for a previously indicated unloaded Signal.

Parameters
externalThe external source path of the Signal.
internalThe VFS-mapped path to use for the Signal.
Exceptions
std::runtime_errorThere was no unloaded Signal sourced by the given external path.

Definition at line 57 of file PartialProject.cpp.

61{
62 const auto map_it = unloaded_signals.find(external);
63
64 if (map_it == unloaded_signals.end())
65 throw std::runtime_error(std::format("Provided VFS mapping for unknown path {}.", external.c_str()));
66
67 map_it->second.first.emplace(std::move(internal));
68}
std::map< std::filesystem::path, std::pair< std::optional< std::filesystem::path >, std::vector< std::unique_ptr< SignalFactory > > > > unloaded_signals
Provides a mapping between stated paths of externally sourced signals, and paths in the WebAssembly V...
T format(T... args)

◆ indicate_unloaded_signal()

void echomap::PartialProject::indicate_unloaded_signal ( std::unique_ptr< SignalFactory > && factory)

Provide the factory for an unloaded Signal.

An unloaded Signal is an externally sourced Signal defined by the Project, but whose sample data was not available at the time of the Project load, and has not yet been fully loaded.

Parameters
factoryThe SignalFactory prepared to construct the Signal, once the data becomes available.
Exceptions
std::runtime_errorThe given SignalFactory did not define an external source.
std::runtime_errorCould not take ownership of the SignalFactory for some implementation-defined reason.

Definition at line 28 of file PartialProject.cpp.

31{
32 if (!factory->observe_signal().observe_source().has_value())
33 throw std::runtime_error("Attempted to defer load of a Signal with no external source.");
34
35 const auto& source = *factory->observe_signal().observe_source();
36
37 auto file_group_it = unloaded_signals.find(source.path);
38
39 if (file_group_it == unloaded_signals.end()) {
40 decltype(unloaded_signals)::mapped_type pair{{}, std::vector<std::unique_ptr<SignalFactory>>(source.channel)};
41 const auto [it, success] = unloaded_signals.emplace(source.path, std::move(pair));
42
43 if (!success)
44 throw std::runtime_error("Could not register VFS channel mappings.");
45
46 file_group_it = it;
47 }
48
49 auto& group_factories = file_group_it->second.second;
50
51 if (group_factories.size() < source.channel)
52 group_factories.resize(source.channel);
53
54 group_factories[source.channel - 1] = std::move(factory);
55}

◆ observe_unloaded_signals()

auto echomap::PartialProject::observe_unloaded_signals ( ) const
inlinenodiscardnoexcept

Provide an observing view to the unloaded signals.

Returns
An observing view of the unloaded signals structure including:
  • Key: the external path;
  • Value:
    1. Optionally, a VFS mapping to the internal path of the Signal source;
    2. The SignalFactory responsible for constructing the Signal once its data becomes available.

Definition at line 84 of file PartialProject.hpp.

85 {
86 return unloaded_signals | std::views::all;
87 }

◆ take_unloaded_factories()

auto echomap::PartialProject::take_unloaded_factories ( )
inlinenodiscardnoexcept

Provide a view to the mutable unloaded SignalFactory objects.

For a description of the viewed values, see observe_unloaded_signals. Following this operation, ownership of the unloaded factories are transferred to the caller and their corresponding entries removed from the underlying storage.

Returns
A mutating view of the unloaded Signal SignalFactory objects.

Definition at line 98 of file PartialProject.hpp.

99 {
100 return std::exchange(unloaded_signals, {}) | std::views::values | std::views::as_rvalue;
101 }
T exchange(T... args)

Member Data Documentation

◆ unloaded_signals

Provides a mapping between stated paths of externally sourced signals, and paths in the WebAssembly VFS.

The key indicates the path of the referenced file. The value composes an optional mapping of the corresponding path in the VFS and a channel map of factories responsible for constructing the Signal of the file channel.

Definition at line 42 of file PartialProject.hpp.


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