![]() |
Dripline-Cpp
v2.4.2
Dripline Implementation in C++
|
Basic Dripline object capable of receiving and acting on messages. More...
#include <endpoint.hh>
Public Member Functions | |
endpoint (const std::string &a_name) | |
endpoint (const endpoint &a_orig) | |
endpoint (endpoint &&a_orig) | |
virtual | ~endpoint () |
endpoint & | operator= (const endpoint &a_orig) |
endpoint & | operator= (endpoint &&a_orig) |
snake_case_mv_referrable (std::string, name) | |
snake_case_mv_referrable (service_ptr_t, service) | |
reply_ptr_t | submit_request_message (const request_ptr_t a_request) |
Directly submit a request message to this endpoint. More... | |
void | submit_reply_message (const reply_ptr_t a_reply) |
Directly submit a reply message to this endpoint. More... | |
void | submit_alert_message (const alert_ptr_t a_alert) |
Directly submit an alert message to this endpoint. More... | |
virtual reply_ptr_t | on_request_message (const request_ptr_t a_request) |
Default request handler; passes request to initial request functions. More... | |
virtual void | on_reply_message (const reply_ptr_t a_reply) |
virtual void | on_alert_message (const alert_ptr_t a_alert) |
virtual reply_ptr_t | do_run_request (const request_ptr_t a_request) |
virtual reply_ptr_t | do_get_request (const request_ptr_t a_request) |
virtual reply_ptr_t | do_set_request (const request_ptr_t a_request) |
virtual reply_ptr_t | do_cmd_request (const request_ptr_t a_request) |
void | sort_message (const message_ptr_t a_request) |
uuid_t | enable_lockout (const scarab::param_node &a_tag) |
enable lockout with randomly-generated key More... | |
uuid_t | enable_lockout (const scarab::param_node &a_tag, uuid_t a_key) |
enable lockout with user-supplied key More... | |
bool | disable_lockout (const uuid_t &a_key, bool a_force=false) |
bool | is_locked () const |
bool | check_key (const uuid_t &a_key) const |
Protected Member Functions | |
virtual void | send_reply (reply_ptr_t a_reply) const |
bool | authenticate (const uuid_t &a_key) const |
Returns true if the server is unlocked or if it's locked and the key matches the lockout key; returns false otherwise. More... | |
snake_case_mv_referrable (scarab::param_node, lockout_tag) | |
snake_case_mv_accessible (uuid_t, lockout_key) | |
Private Member Functions | |
reply_ptr_t | __do_run_request (const request_ptr_t a_request) |
reply_ptr_t | __do_get_request (const request_ptr_t a_request) |
reply_ptr_t | __do_set_request (const request_ptr_t a_request) |
reply_ptr_t | __do_cmd_request (const request_ptr_t a_request) |
reply_ptr_t | handle_lock_request (const request_ptr_t a_request) |
reply_ptr_t | handle_unlock_request (const request_ptr_t a_request) |
reply_ptr_t | handle_is_locked_request (const request_ptr_t a_request) |
reply_ptr_t | handle_set_condition_request (const request_ptr_t a_request) |
reply_ptr_t | handle_ping_request (const request_ptr_t a_request) |
virtual reply_ptr_t | __do_handle_set_condition_request (const request_ptr_t a_request) |
Default set-condition: no action taken; override for different behavior. More... | |
Basic Dripline object capable of receiving and acting on messages.
This class encapsulates the basic behavior of a Dripline endpoint. It can receive and handle messages, and in particular can act on the different request message operations.
An implementation of a particular endpoint should be a class that inherits from endpoint
.
An endpoint typically operates as part of a service, and it maintains a link to that service that is primarily used to send messages.
The main behaviors of the endpoint will be broken down by section:
Messages can be submitted directly to an endpoint using submit_request_message()
, submit_reply_message()
, and submit_alert_message()
. submit_request_message()
will return a reply_package_ptr
to be used to get the endpoint's reply.
Basic request handling is performed by the on_request_message()
function. This can be overridden, but in most cases should not need to be. This function performs the following tasks:
__do_[OP]_request()
function according to the request's operation type.__do_[OP]_request()
functionEach message operation is handled in two functions: __do_[OP]_request()
and do_[OP]_request()
. The former takes care of built-in Dripline-standard behavior and should not be overridden. Endpoint-specific behavior should be implemented by overriding the latter.
__do_get_request()
: handles get-is-locked if relevant; otherwise calls do_get_request().
do_get_request()`: override this to add get-handling behavior. Default sends an error reply.
__do_set_request()
: authenticates the lockout key, then calls do_set_request().
do_set_request()`: override this to add set-handling behavior. Default sends an error reply.
__do_cmd_request()
: authenticates the lockout key. If relevant, handles cmd-lock, cmd-unlock, cmd-set-condition, and cmd-ping; otherwise calls do_cmd_request()
. do_cmd_request()
: override this to add get-handling behavior. Default sends an error reply.
Alert handling can be enabled by overridding the function on_alert_message()
. By default these are not handled.
Reply handling can be enabled by overriding the function on_reply_message()
. By default these are not handled.
These functions implement the basic lockout functionality that's part of the Dripline standard: enabling and disabling the lock, checking the lock, and validating a key.
There are a few types of requests that are built into the Dripline standard, and these are handled by endpoint
:
Type: OP_CMD
; Specifier: lock
– set the lockout for this endpoint using the provided lockout key Type: OP_CMD
; Specifier: unlock
– disables the lockout for this endpoint Type: OP_GET
; Specifier: is-locked
– checks whether this endpoint is locked out Type: OP_CMD
; Specifier: set-condition
– set a particular "condition" for the endpoint. The default behavior is to do nothing, which can be overridden with the function __do_handle_set_condition_request()
. Type: OP_CMD
; Specifier: ping
– send a simple acknowledgement of receipt of the request
Definition at line 95 of file endpoint.hh.
endpoint | ( | const std::string & | a_name | ) |
Definition at line 30 of file endpoint.cc.
Definition at line 38 of file endpoint.cc.
Definition at line 45 of file endpoint.cc.
|
virtual |
Definition at line 52 of file endpoint.cc.
|
private |
Definition at line 336 of file endpoint.cc.
|
private |
Definition at line 301 of file endpoint.cc.
|
inlineprivatevirtual |
Default set-condition: no action taken; override for different behavior.
Definition at line 246 of file endpoint.hh.
|
private |
Definition at line 285 of file endpoint.cc.
|
private |
Definition at line 320 of file endpoint.cc.
|
protected |
Returns true if the server is unlocked or if it's locked and the key matches the lockout key; returns false otherwise.
Definition at line 400 of file endpoint.cc.
|
inline |
Definition at line 241 of file endpoint.hh.
bool disable_lockout | ( | const uuid_t & | a_key, |
bool | a_force = false |
||
) |
Definition at line 391 of file endpoint.cc.
|
inlinevirtual |
Reimplemented in hub, and simple_service.
Definition at line 226 of file endpoint.hh.
|
inlinevirtual |
Reimplemented in hub, oscillator_ep_iq, oscillator_ep_quadrature, oscillator_ep_in_phase, oscillator_ep_amplitude, oscillator_ep_frequency, and simple_service.
Definition at line 216 of file endpoint.hh.
|
inlinevirtual |
Reimplemented in hub, and simple_service.
Definition at line 211 of file endpoint.hh.
|
inlinevirtual |
Reimplemented in hub, oscillator_ep_amplitude, oscillator_ep_frequency, and simple_service.
Definition at line 221 of file endpoint.hh.
|
inline |
enable lockout with randomly-generated key
Definition at line 231 of file endpoint.hh.
enable lockout with user-supplied key
Definition at line 382 of file endpoint.cc.
|
private |
Definition at line 442 of file endpoint.cc.
|
private |
Definition at line 407 of file endpoint.cc.
|
private |
Definition at line 452 of file endpoint.cc.
|
private |
Definition at line 437 of file endpoint.cc.
|
private |
Definition at line 421 of file endpoint.cc.
|
inline |
Definition at line 236 of file endpoint.hh.
|
virtual |
Default alert handler; throws a dripline_error. Override this to enable handling of alerts.
Definition at line 280 of file endpoint.cc.
|
virtual |
Default reply handler; throws a dripline_error. Override this to enable handling of replies.
Definition at line 275 of file endpoint.cc.
|
virtual |
Default request handler; passes request to initial request functions.
Reimplemented in service.
Definition at line 88 of file endpoint.cc.
Definition at line 55 of file endpoint.cc.
Definition at line 64 of file endpoint.cc.
|
protectedvirtual |
Reimplemented in service.
Definition at line 232 of file endpoint.cc.
|
protected |
snake_case_mv_referrable | ( | std::string | , |
name | |||
) |
snake_case_mv_referrable | ( | service_ptr_t | , |
service | |||
) |
|
protected |
void sort_message | ( | const message_ptr_t | a_request | ) |
Calls the appropriate request handler on a message object. Message type is explicitly checked within this function. Note that you cannot get the reply_ptr_t using this method if you submit a request. This is really intended for use when handling messages received by a parent object.
Definition at line 212 of file endpoint.cc.
void submit_alert_message | ( | const alert_ptr_t | a_alert | ) |
Directly submit an alert message to this endpoint.
Definition at line 78 of file endpoint.cc.
void submit_reply_message | ( | const reply_ptr_t | a_reply | ) |
Directly submit a reply message to this endpoint.
Definition at line 83 of file endpoint.cc.
reply_ptr_t submit_request_message | ( | const request_ptr_t | a_request | ) |
Directly submit a request message to this endpoint.
Definition at line 73 of file endpoint.cc.