Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
impl_registry.cpp File Reference

Implementation of the name-keyed registry of implementation selectors. More...

#include "shamalgs/impl_registry.hpp"
#include "shambase/exception.hpp"
#include "shambase/memory.hpp"
#include "shamcomm/logs.hpp"
#include "shamcomm/worldInfo.hpp"
#include <functional>
#include <map>
#include <stdexcept>
#include <utility>
Include dependency graph for impl_registry.cpp:

Go to the source code of this file.

Namespaces

namespace  shamalgs
 namespace to contain everything implemented by shamalgs

Functions

void shamalgs::impl_registry::register_impl (std::string name, IImplVariant &impl)
 Register an implementation selector under name.
std::vector< std::string > shamalgs::impl_registry::get_registered_algs ()
 Get the names of every registered algorithm, sorted.
std::vector< std::string > shamalgs::impl_registry::get_default_impl_list (std::string_view alg)
 Get the list of available implementations of alg, as config json strings.
std::string shamalgs::impl_registry::get_current_impl (std::string_view alg)
 Get the current implementation of alg as a config json string, "null" if unset.
bool shamalgs::impl_registry::is_impl_set (std::string_view alg)
 Whether an implementation of alg has been selected yet.
void shamalgs::impl_registry::set_impl (std::string_view alg, std::string_view impl)
 Select the implementation of alg from a config json string.
void shamalgs::impl_registry::autoselect_impl (std::string_view alg, const sham::DeviceScheduler_ptr &sched)
 Select the default implementation of alg for the device behind sched.

Detailed Description

Implementation of the name-keyed registry of implementation selectors.

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file impl_registry.cpp.

Function Documentation

◆ autoselect_impl()

void shamalgs::impl_registry::autoselect_impl ( std::string_view alg,
const sham::DeviceScheduler_ptr & sched )

Select the default implementation of alg for the device behind sched.

Exceptions
std::runtime_errorif sched is null

Definition at line 99 of file impl_registry.cpp.

Here is the call graph for this function:

◆ get_current_impl()

std::string shamalgs::impl_registry::get_current_impl ( std::string_view alg)

Get the current implementation of alg as a config json string, "null" if unset.

Definition at line 86 of file impl_registry.cpp.

◆ get_default_impl_list()

std::vector< std::string > shamalgs::impl_registry::get_default_impl_list ( std::string_view alg)

Get the list of available implementations of alg, as config json strings.

Definition at line 82 of file impl_registry.cpp.

◆ get_registered_algs()

std::vector< std::string > shamalgs::impl_registry::get_registered_algs ( )

Get the names of every registered algorithm, sorted.

Definition at line 73 of file impl_registry.cpp.

◆ is_impl_set()

bool shamalgs::impl_registry::is_impl_set ( std::string_view alg)

Whether an implementation of alg has been selected yet.

Definition at line 90 of file impl_registry.cpp.

◆ register_impl()

void shamalgs::impl_registry::register_impl ( std::string name,
IImplVariant & impl )

Register an implementation selector under name.

The registry stores the address of impl, which must therefore outlive every later use of the registry (in practice, a namespace-scope global). There is no unregister.

Exceptions
std::invalid_argumentif name is already registered (nothing is stored then)

Definition at line 64 of file impl_registry.cpp.

Here is the call graph for this function:

◆ set_impl()

void shamalgs::impl_registry::set_impl ( std::string_view alg,
std::string_view impl )

Select the implementation of alg from a config json string.

Definition at line 92 of file impl_registry.cpp.

Here is the call graph for this function: