LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
api_dispatch.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_REG_API_DISPATCH_H
6
#define LINE_REG_API_DISPATCH_H
7
8
/**
9
* @file
10
* @ingroup line_reg
11
* Direct invocation of a single API function from named JSON arguments.
12
*
13
* This is the entry point behind the CLI's --api flag and the one a pybind11
14
* or MEX gateway should call, so that all hosts share one dispatch table and
15
* one conversion policy (include/line/reg/api_json.h).
16
*
17
* Three refusals, all explicit and all by name, because the port is
18
* incremental and a caller must never be able to mistake "not wired" for a
19
* result:
20
* - a name absent from the registry is not ported to C++ at all;
21
* - a name in the registry but not in the dispatch table is ported and
22
* tested but not yet exposed over this boundary;
23
* - an arithmetic the registry does not list for that function is refused
24
* naming the modes it does list.
25
* No path returns an empty result, a zero, or a value from a different
26
* arithmetic than the caller asked for.
27
*/
28
29
#include <string>
30
#include <vector>
31
32
#include "
line/reg/api_json.h
"
33
#include "
line/reg/registry.h
"
34
35
namespace
line
{
36
namespace
reg
{
37
38
/** The arithmetic a call runs at: Real also carries the precision tier. */
39
struct
ArithSpec
{
40
Arith
mode
=
Arith::Double
;
41
unsigned
digits
= 0;
///< significant decimal digits, Real only
42
43
/** Canonical text, e.g. "double", "exact", "real:50". */
44
std::string
str
()
const
;
45
};
46
47
/**
48
* Parse --arith. Accepts "double", "exact" and "real:<digits>"; anything else
49
* is an InputError listing the accepted forms. The port instantiates the
50
* high-precision backend at three fixed tiers (50, 100, 200 digits), so a
51
* request between tiers is rounded UP to the next one -- never down, so a
52
* caller never silently receives less precision than asked -- and str()
53
* reports the tier actually used. Above 200 digits the call is refused.
54
*/
55
ArithSpec
parse_arith
(
const
std::string& text);
56
57
/** Names exposed over this boundary, sorted; a subset of the registry. */
58
std::vector<std::string>
api_exposed_functions
();
59
60
/** True when the named function has a dispatch entry. */
61
bool
api_is_exposed
(
const
std::string& name);
62
63
/**
64
* Invoke one API function.
65
*
66
* @param name MATLAB function name, e.g. "pfqn_ca"
67
* @param arith text of --arith, e.g. "exact" or "real:50"
68
* @param args object keyed by the MATLAB parameter names
69
* @return {"function", "arith", "results"}, results keyed by the MATLAB output
70
* names and encoded per the policy in api_json.h
71
* @throws UnsupportedError, InputError, NumericError
72
*/
73
Json
api_invoke
(
const
std::string& name,
const
std::string& arith,
const
Json
& args);
74
75
/** Human-readable rendering of the object api_invoke returns, for -o readable. */
76
std::string
api_render_readable
(
const
Json
& result);
77
78
}
// namespace reg
79
}
// namespace line
80
81
#endif
// LINE_REG_API_DISPATCH_H
api_json.h
The one conversion policy between JSON and the templated API layer.
line::reg
Definition
api_dispatch.h:36
line::reg::Json
nlohmann::json Json
Definition
api_json.h:63
line::reg::api_render_readable
std::string api_render_readable(const Json &result)
Human-readable rendering of the object api_invoke returns, for -o readable.
Definition
api_dispatch.cpp:2950
line::reg::parse_arith
ArithSpec parse_arith(const std::string &text)
Parse –arith.
Definition
api_dispatch.cpp:196
line::reg::api_exposed_functions
std::vector< std::string > api_exposed_functions()
Names exposed over this boundary, sorted; a subset of the registry.
Definition
api_dispatch.cpp:2847
line::reg::api_is_exposed
bool api_is_exposed(const std::string &name)
True when the named function has a dispatch entry.
Definition
api_dispatch.cpp:2853
line::reg::api_invoke
Json api_invoke(const std::string &name, const std::string &arith, const Json &args)
Invoke one API function.
Definition
api_dispatch.cpp:2857
line
Definition
aoi_dist2ph.h:52
line::Arith
Arith
Definition
registry.h:26
line::Arith::Double
@ Double
Definition
registry.h:26
registry.h
Coverage registry of the C++ port.
line::reg::ArithSpec
The arithmetic a call runs at: Real also carries the precision tier.
Definition
api_dispatch.h:39
line::reg::ArithSpec::str
std::string str() const
Canonical text, e.g.
Definition
api_dispatch.cpp:187
line::reg::ArithSpec::mode
Arith mode
Definition
api_dispatch.h:40
line::reg::ArithSpec::digits
unsigned digits
significant decimal digits, Real only
Definition
api_dispatch.h:41
include
line
reg
api_dispatch.h
Generated by
1.18.0