|
pianod2
multisource multiuser scriptable networked music player
|
This class is derived from ResponseCollector and adds success/failure adder functions and a few variables to support this. More...
#include <response.h>


Public Types | |
| enum class | Aggregation { PESSIMISTIC , OPTIMISTIC } |
Public Member Functions | |
| void | fail (Response &&failure) |
| Add a failure response to the collection. More... | |
| template<typename ParamOne , typename ParamTwo , typename... Additional> | |
| void | fail (ParamOne &&first, ParamTwo &&second, Additional &&...more) |
| Add a failure to the failures list, after constructing it. More... | |
| void | succeed (Response &&success) |
| Add a success response to the collection. More... | |
| void | succeed () |
| Add a simple success to the list. More... | |
| template<typename ParamOne , typename ParamTwo , typename... Additional> | |
| void | succeed (ParamOne &&first, ParamTwo &&second, Additional &&...more) |
| Add a succeess to the successes list, after constructing it. More... | |
| void | operator() (Response &&r) |
| Add a success or failure response to the collection. More... | |
| template<typename ParamOne , typename... Parameters> | |
| void | operator() (ParamOne &&first, Parameters &&...more) |
| Construct a response and add it to the successes, failures or data list based on its type. More... | |
| CommandReply (Aggregation kind=Aggregation::OPTIMISTIC) | |
| Construct a response collector for status collection. More... | |
| CommandReply (Response &&initial) | |
| CommandReply (const std::exception_ptr except, const char *triggering_command=nullptr) | |
| Contruct a maningful failure response from an exception. More... | |
Public Member Functions inherited from ResponseCollector | |
| void | setNoResponse () |
| bool | allSuccess () const |
| ResponseCollector contains successes but no failures. More... | |
| bool | allFailure () const |
| ResponseCollector contains failures but no successes. More... | |
| bool | anySuccess () const |
| ResponseCollector contains at least one success, regardless of failures. More... | |
| bool | anyFailure () const |
| ResponseCollector contains at least one failure, regardless of successes. More... | |
| bool | partial () const |
| ResponseCollector contains a mix of successes and failures. More... | |
| bool | noop () const |
| ResponseCollector contains neither successes nor failures. More... | |
| bool | dataResponse () const |
| ResponseCollector is transporting data for transmission. More... | |
| bool | isNoResponse () const |
| ResponseCollector should not send a reply to a command. More... | |
| void | close () |
| Causes the connection to be closed after the response is sent. More... | |
| void | transmit (PianodConnection &, const bool json) |
| Transmit a reply. More... | |
| ResponseCollector ()=default | |
| ResponseCollector (ResponseCollector &&from)=default | |
| ResponseCollector & | operator= (ResponseCollector &&from)=default |
| ResponseCollector (Response &&initial) | |
| Initialize a response collection, and add the initial response to the appropriate collection if applicable. More... | |
| ResponseCollector (const RESPONSE_CODE response) | |
| ResponseCollector (MusicThingie *item) | |
| Implicitly wrap a music item into a data response. More... | |
| ResponseCollector (const ThingieList &things) | |
| Implicitly wrap a list of music items into a data response. More... | |
| ResponseCollector (const SongList &songs) | |
| Implicitly wrap a list of songs into a data response. More... | |
| ResponseCollector (ResponseGroup &&group) | |
| Implicitly wrap a response group into a data response. More... | |
Public Attributes | |
| ResponseGroup | information |
| Session notices going back to user. More... | |
| ResponseGroup | user_events |
| Broadcast to other same-user sessions. More... | |
| ResponseGroup | room_events |
| Broadcast to all same-room sessions. More... | |
| ResponseGroup | broadcast_events |
| Broadcast to all users, all rooms. More... | |
Public Attributes inherited from ResponseCollector | |
| ResponseGroup | information |
| Session notices going back to user. More... | |
Private Member Functions | |
| void | mergeReason (RESPONSE_CODE why) |
| Update the collection's final status. More... | |
Private Attributes | |
| RESPONSE_CODE | mixed_reason { E_PARTIAL } |
| The final response if there are both successes and failures. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ResponseCollector | |
| void | data (ResponseGroup &&group) |
| Add a record for transmission as response data. More... | |
| void | data (const ThingieList &item_list) |
| Add a list of music items for transmission as response data. More... | |
| void | data (const SongList &songs) |
| Add a list of songs for transmission as response data. More... | |
| void | data (const PlaylistList &playlists) |
| Add a list of playlists for transmission as response data. More... | |
Protected Attributes inherited from ResponseCollector | |
| RESPONSE_CODE | reason { S_NOOP } |
| The final response that will be sent. More... | |
| ResponseGroup | successes |
| Success messages. More... | |
| ResponseGroup | diagnostics |
| Details of errors encountered. More... | |
| std::vector< ResponseGroup > | data_groups |
| Complete data records destined for the client. More... | |
| ResponseGroup | data_reply |
| Discrete data responses destined for the client. More... | |
| ResponseGroup | user_events |
| Broadcast to other same-user sessions. More... | |
| ResponseGroup | room_events |
| Broadcast to all same-room sessions. More... | |
| ResponseGroup | broadcast_events |
| Broadcast to all users, all rooms. More... | |
This class is derived from ResponseCollector and adds success/failure adder functions and a few variables to support this.
The name makes its purpose clearer, the interface avoids data mixing with successes/failures, which is invalid. The cost is needing std::move() whereever we return as a ResponseCollector; when this is done, we are indeed slicing the object.
|
strong |
| CommandReply::CommandReply | ( | Aggregation | kind = Aggregation::OPTIMISTIC | ) |
Construct a response collector for status collection.
| kind | If the evemt of mixed successes/failures, an Aggregation::OPTIMISTIC collector will report success, a Aggregation::PESSIMISTIC will return failure for the final/overall status. |
|
inline |
| CommandReply::CommandReply | ( | const std::exception_ptr | except, |
| const char * | triggering_command = nullptr |
||
| ) |
Contruct a maningful failure response from an exception.
| except | An exception of any type. |
| triggering_command | The command causing the exception (for logging; may be omitted.) |

|
inline |
Add a failure to the failures list, after constructing it.

| void CommandReply::fail | ( | Response && | failure | ) |
Add a failure response to the collection.
| failure | The failure to add. |


|
private |
Update the collection's final status.
| why | The new response code being accommodated; must be a success or command error code. |


|
inline |
Construct a response and add it to the successes, failures or data list based on its type.

| void CommandReply::operator() | ( | Response && | status | ) |
Add a success or failure response to the collection.
| status | The response to add. |


|
inline |
Add a simple success to the list.

|
inline |
Add a succeess to the successes list, after constructing it.

| void CommandReply::succeed | ( | Response && | success | ) |
Add a success response to the collection.
| success | The success to add. |


| ResponseGroup ResponseCollector::broadcast_events |
Broadcast to all users, all rooms.
| ResponseGroup ResponseCollector::information |
Session notices going back to user.
|
private |
The final response if there are both successes and failures.
| ResponseGroup ResponseCollector::room_events |
Broadcast to all same-room sessions.
| ResponseGroup ResponseCollector::user_events |
Broadcast to other same-user sessions.