LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
cli_run.h File Reference

The CLI's argument vector, reachable in-process. More...

#include <string>
#include <vector>
Include dependency graph for cli_run.h:

Go to the source code of this file.

Classes

struct  line::cli::Request
 One invocation: the argument vector, plus what a pipe would have carried. More...
struct  line::cli::Response
 What one invocation produced. More...

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::cli

Functions

Response line::cli::run (const Request &req)
 Run one invocation and return what it produced.
int line::cli::main_body (int argc, char **argv)
 The binary's main, so line_cli_main.cpp stays ten lines.

Detailed Description

The CLI's argument vector, reachable in-process.

line-cli is the only place in this port that serves the WHOLE vocabulary: every solver, every -a analysis, every input format and the --api registry. The in-process facade (line/solvers/solver.h) is deliberately a facade – double only, avg_table() and a handful of siblings – so a host that wants a response-time CDF, a layered solve or a state probability has had no route but to spawn the binary. This header is that route.

THE VOCABULARY IS argv, AND THAT IS THE POINT. parse_args accepts about a hundred and twenty flags and gains more with every solver; a struct mirroring them would be a second parser to keep in step, and every host binding would have to learn it. Passing the argument vector verbatim means a host that can build a command line can reach everything the command line reaches, on the day the flag lands rather than on the day someone widens a struct.

WHAT THIS ADDS OVER system("line-cli ...") is the three things a subprocess cannot give: the JSON documents arrive as separate strings rather than as text to be scanned for a brace, stdout and stderr are captured instead of escaping into the host's console, and an error arrives with the stable identifier of line/io/marshal.h rather than as prose on fd 2.

REENTRANCY IS THE CALLER'S TO SERIALIZE. line_cli.cpp holds file-scope state (the output format, the two input-format flags, the verbosity and the buffered stdin text) and the capture redirects process-global file descriptors, so two concurrent run() calls would interfere. run() resets every one of those before it dispatches, so SEQUENTIAL calls are independent; concurrent ones need a lock the caller holds. The C ABI in r/capi/ takes one, and that is the intended arrangement rather than a workaround.

Definition in file cli_run.h.