AsmGrader 0.0.0
Loading...
Searching...
No Matches
asmgrader::GlobalRegistrar Class Reference

A global singleton registrar. Used with Assignments for now. More...

#include <global_registrar.hpp>

Public Member Functions

void add_test (std::unique_ptr< TestBase > test) noexcept
 Registers the test to be made accessible.
 
template<typename Func >
requires (std::is_void_v<std::invoke_result_t<Func, Assignment>>)
void for_each_assignment (Func &&fun)
 
template<typename Func >
requires (!std::is_void_v<std::invoke_result_t<Func, Assignment>>)
std::vector< std::invoke_result_t< Func, Assignment > > for_each_assignment (Func &&fun)
 
auto get_assignments () noexcept
 
std::optional< std::reference_wrapper< Assignment > > get_assignment (std::string_view name)
 
template<typename... MetadataAttrs>
Assignmentfind_or_create_assignment (metadata::Metadata< MetadataAttrs... > metadata)
 Find the assignment corresponding to the Assignment attribute of metadata, or create a new assignment if one does not exist.
 
std::vector< std::string_view > get_assignment_names ()
 Obtain a list of all assignment names.
 
std::size_t get_num_registered () const
 

Static Public Member Functions

static GlobalRegistrarget () noexcept
 Safe global singleton pattern (first intro. by Scott Meyers for C++, I think)
 

Detailed Description

A global singleton registrar. Used with Assignments for now.

Construct this class with the assignment we want to register, and that assignement will be made accessible at the CLI-level, premitting the user to run the grader on that assignment.

add might be better named register if not for the fact for it being a reserved keyword.

Member Function Documentation

◆ add_test()

void asmgrader::GlobalRegistrar::add_test ( std::unique_ptr< TestBase > test)
noexcept

Registers the test to be made accessible.

◆ find_or_create_assignment()

template<typename... MetadataAttrs>
Assignment & asmgrader::GlobalRegistrar::find_or_create_assignment ( metadata::Metadata< MetadataAttrs... > metadata)

Find the assignment corresponding to the Assignment attribute of metadata, or create a new assignment if one does not exist.

◆ for_each_assignment() [1/2]

template<typename Func >
requires (std::is_void_v<std::invoke_result_t<Func, Assignment>>)
void asmgrader::GlobalRegistrar::for_each_assignment ( Func && fun)

◆ for_each_assignment() [2/2]

template<typename Func >
requires (!std::is_void_v<std::invoke_result_t<Func, Assignment>>)
std::vector< std::invoke_result_t< Func, Assignment > > asmgrader::GlobalRegistrar::for_each_assignment ( Func && fun)

◆ get()

GlobalRegistrar & asmgrader::GlobalRegistrar::get ( )
staticnoexcept

Safe global singleton pattern (first intro. by Scott Meyers for C++, I think)

◆ get_assignment()

std::optional< std::reference_wrapper< Assignment > > asmgrader::GlobalRegistrar::get_assignment ( std::string_view name)
inline

◆ get_assignment_names()

std::vector< std::string_view > asmgrader::GlobalRegistrar::get_assignment_names ( )

Obtain a list of all assignment names.

◆ get_assignments()

auto asmgrader::GlobalRegistrar::get_assignments ( )
inlinenoexcept

◆ get_num_registered()

std::size_t asmgrader::GlobalRegistrar::get_num_registered ( ) const

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