|
pianod2
multisource multiuser scriptable networked music player
|
Dispatcher based on Parsnip template, customized for pianod by adding help support. More...
#include <interpreter.h>


Public Types | |
| using | HelpList = std::vector< std::string > |
Public Types inherited from Parsnip::Dispatcher< ResponseCollector, PianodConnection & > | |
| using | ReturnType = ResponseCollector |
| using | ContextType = PianodConnection & |
| using | ExecutorType = std::function< ReturnType(Parser::CommandId, const Parsnip::Data &, ContextType)> |
Public Member Functions | |
| PianodDispatcher (const Parsnip::ParserRef &parser, const PianodSchemaRef &schema) | |
| Construct a dispatcher for Pianod. More... | |
| void | addHandler (const Parsnip::Parser::Definitions &defs, class PianodInterpreter *interpreter) |
| Add a handler to/for which commands will be dispatched. More... | |
| void | rewriteJsonRequest (Parsnip::Data &request) const |
| Rewrite the JSON request, wrapping the actual command in any as-user, in-room, and with-source specifications. More... | |
| ResponseCollector | jsonRequest (const Parsnip::Data &request, PianodConnection &context) const |
| Dispatch a JSON request for execution. More... | |
| ResponseCollector | redispatch (const Parsnip::Data &options, PianodConnection &context) const |
| Dispatch a command or request embedded within another command. More... | |
| const HelpList | getHelp (std::vector< std::string > search) |
| Request help for all interpreters which a dispatcher handles. More... | |
Public Member Functions inherited from Parsnip::Dispatcher< ResponseCollector, PianodConnection & > | |
| Dispatcher (const ParserRef &parser) | |
| Construct a dispatcher. More... | |
| void | addHandler (const Parser::Definitions &defs, const ExecutorType &handler) |
| Register handlers with the dispatcher. More... | |
| void | addHandler (const Parser::Definitions &defs, Interpreter< ResponseCollector, PianodConnection & > *interpreter) |
| Register handlers with the dispatcher. More... | |
| void | addStatements (const Parser::Definitions &defs, ExecutorType handler) |
| Add statements to the parser and register their related handler. More... | |
| ReturnType | operator() (Parser::CommandId command_id, const Parsnip::Data ¶meters, PianodConnection & context) const |
| Dispatch a command to the executor/handler function. More... | |
| ReturnType | operator() (Parser::StringType command, ContextType context) const |
| Parse and dispatch a command to the executor/handler function. More... | |
Private Types | |
| using | base_type = Parsnip::Dispatcher< ResponseCollector, PianodConnection & > |
Private Attributes | |
| PianodSchemaRef | schema |
| std::vector< class PianodInterpreter * > | interpreters |
| List of all associated interpreters. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Parsnip::Dispatcher< ResponseCollector, PianodConnection & > | |
| const ParserRef | parser |
Dispatcher based on Parsnip template, customized for pianod by adding help support.
|
private |
| using PianodDispatcher::HelpList = std::vector<std::string> |
| PianodDispatcher::PianodDispatcher | ( | const Parsnip::ParserRef & | parser, |
| const PianodSchemaRef & | schema_in | ||
| ) |
Construct a dispatcher for Pianod.
| parser | A parser for the pianod command set. |
| schema_in | A schema fr the pianod request set. |
| void PianodDispatcher::addHandler | ( | const Parsnip::Parser::Definitions & | defs, |
| class PianodInterpreter * | interpreter | ||
| ) |
Add a handler to/for which commands will be dispatched.
| defs | The list of commands the interpreter will handle. |
| interpreter | The interpreter instance. |


| const std::vector< std::string > PianodDispatcher::getHelp | ( | std::vector< std::string > | search | ) |
Request help for all interpreters which a dispatcher handles.
| search | Search criteria. |


| ResponseCollector PianodDispatcher::jsonRequest | ( | const Parsnip::Data & | request, |
| PianodConnection & | context | ||
| ) | const |
Dispatch a JSON request for execution.
| request | The request to dispatch. |
| context | The request's context. |


| ResponseCollector PianodDispatcher::redispatch | ( | const Parsnip::Data & | options, |
| PianodConnection & | context | ||
| ) | const |
Dispatch a command or request embedded within another command.
I.e., ADD USER, IN ROOM, or WITH SOURCE.
| options | The options provided to one of the aforementioned commands. |
| context | The request's context. |


| void PianodDispatcher::rewriteJsonRequest | ( | Parsnip::Data & | request | ) | const |
Rewrite the JSON request, wrapping the actual command in any as-user, in-room, and with-source specifications.
| request | The request, rewritten on return if required. |


|
private |
List of all associated interpreters.
|
private |