controller class of functions to "dispatch" from Command Dispatcher
More...
|
static bool | help (rapidjson::Value &payload) |
| command handler for help More...
|
|
static bool | exit (rapidjson::Value &payload) |
| command handler for exit More...
|
|
static bool | query_payload (rapidjson::Value &payload) |
| command handler for query_payload More...
|
|
static bool | sum_ints (rapidjson::Value &payload) |
| command handler for sum_ints More...
|
|
static bool | mean_ints (rapidjson::Value &payload) |
| command handler for mean_ints More...
|
|
controller class of functions to "dispatch" from Command Dispatcher
Definition at line 218 of file main.cpp.
◆ exit()
static bool Controller::exit |
( |
rapidjson::Value & |
payload | ) |
|
|
inlinestatic |
command handler for exit
- Parameters
-
payload | a JSON string possibly containing a reason |
- Returns
- true if command handled successfully
- Todo:
- change cout call to shared_print?
Definition at line 263 of file main.cpp.
◆ help()
static bool Controller::help |
( |
rapidjson::Value & |
payload | ) |
|
|
inlinestatic |
command handler for help
- Parameters
-
payload | a JSON string possibly containing a "usage" message |
- Exceptions
-
exception | if JSON contains no value "usage" |
- Returns
- true if command handled successfully
- Todo:
- change cout call to shared_print?
Definition at line 232 of file main.cpp.
◆ mean_ints()
static bool Controller::mean_ints |
( |
rapidjson::Value & |
payload | ) |
|
|
inlinestatic |
command handler for mean_ints
- Todo:
- mean_int is an almost identical function to sum_ints. May be more efficient to break large amount of functionality out into a private member function. Will need to figure out division of labor if so.
- Parameters
-
payload | a JSON string possibly containing an array value |
- Returns
- true if command handled successfully, otherwise generate exception
- Exceptions
-
exception | when payload contains no value "addends" |
exception | when addends is not an array |
exception | when no integers in array |
This function looks for an array named "addends". If it exists, it traverses it, and prints the mean of all integers present in the array. All non-integer members of the array are ignored.
- Bug:
- verify that this cannot convert int to float
Definition at line 429 of file main.cpp.
◆ query_payload()
static bool Controller::query_payload |
( |
rapidjson::Value & |
payload | ) |
|
|
inlinestatic |
◆ sum_ints()
static bool Controller::sum_ints |
( |
rapidjson::Value & |
payload | ) |
|
|
inlinestatic |
command handler for sum_ints
- Parameters
-
payload | a JSON string possibly containing an array value |
- Returns
- true if command handled successfully, otherwise generate exception
- Exceptions
-
exception | when payload contains no value "addends" |
exception | when addends is not an array |
exception | when no integers in array |
This function looks for an array named "addends". If it exists, it traverses it and prints the sum of all integers present in the array. All non-integer members of the array are ignored.
Definition at line 345 of file main.cpp.
◆ summation()
template<typename T >
static auto Controller::summation |
( |
vector< T > |
collection | ) |
-> T |
|
inlinestaticprivate |
summation function for sum_ints() and mean_ints()
- Todo:
- write additional member functions to handle other number types such as float, double, or Uint64.
- Parameters
-
collection | a vector of numbers to add together |
- Returns
- sum of numbers of same type as vector passed in.
This function takes in a vector of numbers and addes them together. It supports all number types in C++ including int, float, etc. It was written to accomodate future functions like sum_int and mean_int that take in other types of numbers.
- Todo:
- maybe change cerr call to shared error print?
Definition at line 516 of file main.cpp.
The documentation for this class was generated from the following file: