Dispatch Challenge
Syncmultiplethreadssharingaresource
Classes | Typedefs | Functions | Variables
main_no_debug.cpp File Reference
#include <iostream>
#include <map>
#include <string>
#include <functional>
#include <exception>
#include <vector>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
Include dependency graph for main_no_debug.cpp:

Go to the source code of this file.

Classes

class  Controller
 controller class of functions to "dispatch" from Command Dispatcher More...
 
class  CommandDispatcher
 

Typedefs

typedef std::function< bool(rapidjson::Value &)> CommandHandler
 

Functions

void exceptionPrinter (const char *excpt)
 EXCEPTION HANDLER function. More...
 
int main ()
 

Variables

bool g_done = false
 
bool TEST_ALL = true
 test all functionality before prompting user More...
 
bool VERBOSE = false
 turn on verbose messages More...
 
auto fail_command
 
auto help_command
 
auto help_command_fail
 
auto exit_command
 
auto exit_command_fail
 
auto sum_command
 
auto sum_command_long
 
auto sum_command_floats
 
auto sum_command_fail_1
 
auto sum_command_fail_2
 
auto mean_command
 
auto mean_command_fraction
 
auto mean_command_long
 
auto query_payload_command
 
auto query_payload_command_2
 

Typedef Documentation

◆ CommandHandler

typedef std::function<bool(rapidjson::Value &)> CommandHandler

Definition at line 537 of file main_no_debug.cpp.

Function Documentation

◆ exceptionPrinter()

void exceptionPrinter ( const char *  excpt)

EXCEPTION HANDLER function.

Parameters
excpta const char* containing a message

Prints to standard out

Warning
NOT thread-safe; must be called within a thread-safe scope

Definition at line 52 of file main_no_debug.cpp.

◆ main()

int main ( )
Note
exit_command commented out to allow fallthrough to user prompt. If uncommented, exit_command will successfully exit program prior to user prompt. Ok to uncomment if desired.
The "//

Definition at line 718 of file main_no_debug.cpp.

Variable Documentation

◆ exit_command

auto exit_command
Initial value:
= R"(
{
"command":"exit",
"payload": {
"reason":"Exiting program on user request."
}
}
)"

Definition at line 91 of file main_no_debug.cpp.

◆ exit_command_fail

auto exit_command_fail
Initial value:
= R"(
{
"command":"exit",
"payload": {
"booga":"gooba"
}
}
)"

Definition at line 100 of file main_no_debug.cpp.

◆ fail_command

auto fail_command
Initial value:
= R"(
{
"command":"fail",
"payload": {
"Does not":"really matter what is in here."
}
}
)"

Definition at line 63 of file main_no_debug.cpp.

◆ g_done

bool g_done = false

Definition at line 35 of file main_no_debug.cpp.

◆ help_command

auto help_command
Initial value:
= R"(
{
"command":"help",
"payload": {
"usage":"Enter json command in 'command':'<command>','payload': { // json payload of arguments }"
}
}
)"

Definition at line 73 of file main_no_debug.cpp.

◆ help_command_fail

auto help_command_fail
Initial value:
= R"(
{
"command":"help",
"payload": {
"reason":"Not usage."
}
}
)"

Definition at line 82 of file main_no_debug.cpp.

◆ mean_command

auto mean_command
Initial value:
= R"(
{
"command": "mean_ints",
"payload": {
"addends": [1, 2, 3, 4, 5]
}
}
)"

Definition at line 155 of file main_no_debug.cpp.

◆ mean_command_fraction

auto mean_command_fraction
Initial value:
= R"(
{
"command": "mean_ints",
"payload": {
"addends": [1, 2, 2]
}
}
)"

Definition at line 164 of file main_no_debug.cpp.

◆ mean_command_long

auto mean_command_long
Initial value:
= R"(
{
"command": "mean_ints",
"payload": {
"addends": [1, 2, 3, 4, 5, 100, 999999999, -1, 0, -999]
}
}
)"

Definition at line 173 of file main_no_debug.cpp.

◆ query_payload_command

auto query_payload_command
Initial value:
= R"(
{
"command": "query_payload",
"payload": {
"well": "formed",
"json": "test",
"a": [1,2,3,4],
"number1": 1,
"number2": 34.7,
"b": [
"something":"more",
"here":"too"
]
}
}
)"

Definition at line 184 of file main_no_debug.cpp.

◆ query_payload_command_2

auto query_payload_command_2
Initial value:
= R"(
{
"command": "query_payload",
"payload": {
"hello": "world",
"t": true ,
"f": false,
"n": null,
"i": 123,
"pi": 3.1416,
"a": [1, 2, 3, 4]
}
}
)"

Definition at line 201 of file main_no_debug.cpp.

◆ sum_command

auto sum_command
Initial value:
= R"(
{
"command": "sum_ints",
"payload": {
"addends": [1, 2, 3]
}
}
)"

Definition at line 109 of file main_no_debug.cpp.

◆ sum_command_fail_1

auto sum_command_fail_1
Initial value:
= R"(
{
"command": "sum_ints",
"payload": {
"addends": ["apples", "oranges", "turtles"]
}
}
)"

Definition at line 136 of file main_no_debug.cpp.

◆ sum_command_fail_2

auto sum_command_fail_2
Initial value:
= R"(
{
"command": "sum_ints",
"payload": {
"well":"formed",
"json":"test"
}
}
)"

Definition at line 145 of file main_no_debug.cpp.

◆ sum_command_floats

auto sum_command_floats
Initial value:
= R"(
{
"command": "sum_ints",
"payload": {
"addends": [1, 2, 3, 4.5, 5.0, 100.1, 999999999.1, -1.1, 0, -999.1]
}
}
)"

Definition at line 127 of file main_no_debug.cpp.

◆ sum_command_long

auto sum_command_long
Initial value:
= R"(
{
"command": "sum_ints",
"payload": {
"addends": [1, 2, 3, 4, 5, 100, 999999999, -1, 0, -999]
}
}
)"

Definition at line 118 of file main_no_debug.cpp.

◆ TEST_ALL

bool TEST_ALL = true

test all functionality before prompting user

Definition at line 39 of file main_no_debug.cpp.

◆ VERBOSE

bool VERBOSE = false

turn on verbose messages

Definition at line 40 of file main_no_debug.cpp.