|
|
using | ReturnType = DispatchReturnType |
| |
|
using | ContextType = DispatchContextType |
| |
|
using | ExecutorType = std::function< ReturnType(Parser::CommandId, const Parsnip::Data &, ContextType)> |
| |
|
| | Dispatcher (const ParserRef &parser) |
| | Construct a dispatcher.
|
| |
| void | addHandler (const Parser::Definitions &defs, const ExecutorType &handler) |
| | Register handlers with the dispatcher.
|
| |
| void | addHandler (const Parser::Definitions &defs, Interpreter< DispatchReturnType, DispatchContextType > *interpreter) |
| | Register handlers with the dispatcher.
|
| |
| void | addStatements (const Parser::Definitions &defs, ExecutorType handler) |
| | Add statements to the parser and register their related handler.
|
| |
| ReturnType | operator() (Parser::CommandId command_id, const Parsnip::Data ¶meters, DispatchContextType context) const |
| | Dispatch a command to the executor/handler function.
|
| |
| ReturnType | operator() (Parser::StringType command, ContextType context) const |
| | Parse and dispatch a command to the executor/handler function.
|
| |
◆ Dispatcher()
template<typename DispatchReturnType , typename DispatchContextType >
| Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::Dispatcher |
( |
const ParserRef & |
par | ) |
|
Construct a dispatcher.
- Parameters
-
| par | A parser for evaluating command lines to be dispatched. |
◆ addHandler() [1/2]
template<typename DispatchReturnType , typename DispatchContextType >
| void Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::addHandler |
( |
const Parser::Definitions & |
defs, |
|
|
const ExecutorType & |
handler |
|
) |
| |
Register handlers with the dispatcher.
If assertions aren't enabled, keeps a secondary map to ensure statements are not redefined with different handlers.
- Parameters
-
| defs | The statements handled by the handler. |
| handler | Something to call when dispatching to defined statements. |
◆ addHandler() [2/2]
template<typename DispatchReturnType , typename DispatchContextType >
| void Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::addHandler |
( |
const Parser::Definitions & |
defs, |
|
|
Interpreter< DispatchReturnType, DispatchContextType > * |
interpreter |
|
) |
| |
|
inline |
Register handlers with the dispatcher.
- Parameters
-
| defs | The statements handled by the handler. |
| interpreter | An Interpreter whose interpret routine will be used as the handler. |
◆ addStatements()
template<typename DispatchReturnType , typename DispatchContextType >
| void Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::addStatements |
( |
const Parser::Definitions & |
defs, |
|
|
ExecutorType |
handler |
|
) |
| |
Add statements to the parser and register their related handler.
- Parameters
-
| defs | The statements to add and register. |
| handler | Something to call when dispatching to defined statements. |
◆ operator()() [1/2]
template<typename DispatchReturnType , typename DispatchContextType >
| DispatchReturnType Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::operator() |
( |
Parser::CommandId |
command_id, |
|
|
const Parsnip::Data & |
parameters, |
|
|
DispatchContextType |
context |
|
) |
| const |
Dispatch a command to the executor/handler function.
- Parameters
-
| command_id | Identifier for the requested handler. |
| parameters | Details passed to the handler. |
| context | The caller's context. |
- Returns
- Whatever value is returned by the handler.
◆ operator()() [2/2]
template<typename DispatchReturnType , typename DispatchContextType >
| DispatchReturnType Parsnip::Dispatcher< DispatchReturnType, DispatchContextType >::operator() |
( |
Parser::StringType |
command, |
|
|
ContextType |
context |
|
) |
| const |
Parse and dispatch a command to the executor/handler function.
- Parameters
-
| command | The command line to parse & execute. |
| context | The caller's context. |
- Returns
- Whatever value is returned by the handler.
The documentation for this class was generated from the following file: