pianod2
multisource multiuser scriptable networked music player
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Friends | List of all members
Response Class Reference

Type combining RESPONSE_CODE with a value or explanation: More...

#include <response.h>

Collaboration diagram for Response:
Collaboration graph
[legend]

Public Types

using List = std::vector< std::string >
 

Public Member Functions

bool isStatusChange () const
 
bool isDataField () const
 
bool isSuccess () const
 
bool isCommandError () const
 
bool isServerFailure () const
 
bool isUserAction () const
 
void bindUser (const class User *u) const
 Associate a user triggering the response (for user actions & yells). More...
 
void transmitLine (Football::Thingie &there, int offset=TransmitUnaltered) const
 Transmit a response using line protocol. More...
 
Parsnip::Data serialize () const
 Format a response for JSON protocol. More...
 
 Response ()=default
 
 Response (const Response &)=default
 
 Response (Response &&)=default
 
Responseoperator= (const Response &)=default
 
Responseoperator= (Response &&)=default
 
 Response (RESPONSE_CODE msg)
 
 Response (RESPONSE_CODE msg, const std::string &details)
 
 Response (RESPONSE_CODE msg, long details)
 
 Response (RESPONSE_CODE msg, double details, int precision)
 
 Response (RESPONSE_CODE msg, List &&details, Parsnip::Data &&json_details)
 
 Response (const std::string &regard, RESPONSE_CODE msg)
 
 Response (const std::string &regard, RESPONSE_CODE msg, const std::string &details)
 
 Response (const std::string &regard, RESPONSE_CODE msg, long details)
 
 Response (const std::string &regard, RESPONSE_CODE msg, double details, int precision)
 
 Response (const std::string &regard, RESPONSE_CODE msg, List &&details, Parsnip::Data &&json_details)
 
 Response (Retainer< MusicThingie * > rel, RESPONSE_CODE msg)
 
 Response (Retainer< MusicThingie * > rel, RESPONSE_CODE msg, const std::string &details)
 
 Response (Retainer< MusicThingie * > rel, RESPONSE_CODE msg, long details)
 
 Response (Retainer< MusicThingie * > rel, RESPONSE_CODE msg, double details, int precision)
 
 Response (Retainer< MusicThingie * > rel, RESPONSE_CODE msg, List &&details, Parsnip::Data &&json_details)
 
 Response (const CommandError &err)
 
 Response (const std::string &regard, const CommandError &err)
 
 Response (Retainer< MusicThingie * > rel, const CommandError &err)
 

Static Public Attributes

static constexpr int TransmitUnaltered = 0
 Transmit data as stored. More...
 
static constexpr int TransmitAsDiagnostic = -100
 Transform command errors to diagnostic codes. More...
 
static Parsnip::Data NoJsonData { nullptr }
 

Private Types

enum class  Type {
  EMPTY , STRING , LONG , DOUBLE ,
  WORDLIST
}
 

Private Attributes

RESPONSE_CODE message = NO_REPLY
 Message code, initialized to "empty" value. More...
 
Type type { Type::EMPTY }
 Type of additional data stored herein. More...
 
std::string value
 
long long_value
 
double double_value
 
int double_precision
 
List list
 
std::shared_ptr< Parsnip::Datajson_data
 Parsnip data to be used for JSON replies. More...
 
std::string regarding
 ID or name of item response is in regards to. More...
 
Retainer< MusicThingie * > related
 Music item to send, or in regards to. More...
 
const class Useruser = nullptr
 User triggering the response. More...
 

Friends

class ResponseCollector
 
class ResponseGroup
 
class CommandReply
 

Detailed Description

Type combining RESPONSE_CODE with a value or explanation:

Member Typedef Documentation

◆ List

using Response::List = std::vector<std::string>

Member Enumeration Documentation

◆ Type

enum Response::Type
strongprivate
Enumerator
EMPTY 
STRING 
LONG 
DOUBLE 
WORDLIST 

Constructor & Destructor Documentation

◆ Response() [1/21]

Response::Response ( )
default

◆ Response() [2/21]

Response::Response ( const Response )
default

◆ Response() [3/21]

Response::Response ( Response &&  )
default

◆ Response() [4/21]

Response::Response ( RESPONSE_CODE  msg)

◆ Response() [5/21]

Response::Response ( RESPONSE_CODE  msg,
const std::string &  details 
)

◆ Response() [6/21]

Response::Response ( RESPONSE_CODE  msg,
long  details 
)

◆ Response() [7/21]

Response::Response ( RESPONSE_CODE  msg,
double  details,
int  precision 
)

◆ Response() [8/21]

Response::Response ( RESPONSE_CODE  msg,
List &&  details,
Parsnip::Data &&  json_details 
)

◆ Response() [9/21]

Response::Response ( const std::string &  regard,
RESPONSE_CODE  msg 
)

◆ Response() [10/21]

Response::Response ( const std::string &  regard,
RESPONSE_CODE  msg,
const std::string &  details 
)

◆ Response() [11/21]

Response::Response ( const std::string &  regard,
RESPONSE_CODE  msg,
long  details 
)

◆ Response() [12/21]

Response::Response ( const std::string &  regard,
RESPONSE_CODE  msg,
double  details,
int  precision 
)

◆ Response() [13/21]

Response::Response ( const std::string &  regard,
RESPONSE_CODE  msg,
List &&  details,
Parsnip::Data &&  json_details 
)

◆ Response() [14/21]

Response::Response ( Retainer< MusicThingie * >  rel,
RESPONSE_CODE  msg 
)

◆ Response() [15/21]

Response::Response ( Retainer< MusicThingie * >  rel,
RESPONSE_CODE  msg,
const std::string &  details 
)

◆ Response() [16/21]

Response::Response ( Retainer< MusicThingie * >  rel,
RESPONSE_CODE  msg,
long  details 
)

◆ Response() [17/21]

Response::Response ( Retainer< MusicThingie * >  rel,
RESPONSE_CODE  msg,
double  details,
int  precision 
)

◆ Response() [18/21]

Response::Response ( Retainer< MusicThingie * >  rel,
RESPONSE_CODE  msg,
List &&  details,
Parsnip::Data &&  json_details 
)

◆ Response() [19/21]

Response::Response ( const CommandError err)

◆ Response() [20/21]

Response::Response ( const std::string &  regard,
const CommandError err 
)

◆ Response() [21/21]

Response::Response ( Retainer< MusicThingie * >  rel,
const CommandError err 
)

Member Function Documentation

◆ bindUser()

void Response::bindUser ( const class User u) const
inline

Associate a user triggering the response (for user actions & yells).

◆ isCommandError()

bool Response::isCommandError ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDataField()

bool Response::isDataField ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isServerFailure()

bool Response::isServerFailure ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isStatusChange()

bool Response::isStatusChange ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSuccess()

bool Response::isSuccess ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUserAction()

bool Response::isUserAction ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

Response& Response::operator= ( const Response )
default

◆ operator=() [2/2]

Response& Response::operator= ( Response &&  )
default

◆ serialize()

Parsnip::Data Response::serialize ( ) const

Format a response for JSON protocol.

Returns
For data responses, a Parsnip::Data containing response data, otherwise a dictionary containing event/response details.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmitLine()

void Response::transmitLine ( Football::Thingie destination,
int  offset = TransmitUnaltered 
) const

Transmit a response using line protocol.

Parameters
destinationThe place to send it.
offsetIf unspecified, sends messages as-is. Set to TransmitAsDiagnostic to send command error messages as diagnostics.

< Assemble message before tranmission so we can log it too.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ CommandReply

friend class CommandReply
friend

◆ ResponseCollector

friend class ResponseCollector
friend

◆ ResponseGroup

friend class ResponseGroup
friend

Member Data Documentation

◆ double_precision

int Response::double_precision
private

◆ double_value

double Response::double_value
private

◆ json_data

std::shared_ptr<Parsnip::Data> Response::json_data
private

Parsnip data to be used for JSON replies.

◆ list

List Response::list
private

◆ long_value

long Response::long_value
private

◆ message

RESPONSE_CODE Response::message = NO_REPLY
private

Message code, initialized to "empty" value.

◆ NoJsonData

Parsnip::Data Response::NoJsonData { nullptr }
static

◆ regarding

std::string Response::regarding
private

ID or name of item response is in regards to.

◆ related

Retainer<MusicThingie *> Response::related
private

Music item to send, or in regards to.

◆ TransmitAsDiagnostic

constexpr int Response::TransmitAsDiagnostic = -100
staticconstexpr

Transform command errors to diagnostic codes.

◆ TransmitUnaltered

constexpr int Response::TransmitUnaltered = 0
staticconstexpr

Transmit data as stored.

◆ type

Type Response::type { Type::EMPTY }
private

Type of additional data stored herein.

◆ user

const class User* Response::user = nullptr
private

User triggering the response.

◆ value

std::string Response::value
private

The documentation for this class was generated from the following files: