38 bool has_option(
char** argv_begin,
char** argv_end,
const std::string& option) {
return std::find(argv_begin, argv_end, option) != argv_end; }
40 std::string
get_option(
char** argv_begin,
char** argv_end,
const std::string& option)
42 char** it = std::find(argv_begin, argv_end, option);
43 if (it != argv_end && ++it != argv_end)
return std::string(*it);
50 PRINT_INFO(
"The following options are available:");
51 PRINT_INFO(
"-s\tSet gRPC server hostname, e.g. -s localhost:50051");
52 PRINT_INFO(
"-m\tLoad protobuf message file of type corboParameters, e.g. -m path/to/file.cparams");
55 int main(
int argc,
char** argv)
64 std::string hostname =
get_option(argv, argv + argc,
"-s");
65 if (hostname.empty()) hostname =
"localhost:50051";
67 std::string proto_msg_path =
get_option(argv, argv + argc,
"-m");
71 if (!proto_msg_path.empty())
75 PRINT_INFO(
"Loaded default parameters from file " << proto_msg_path);
79 PRINT_ERROR(
"Cannot load default parameters from file " << proto_msg_path);
83 PRINT_DEBUG_WARN(
"corbo IS COMPILED WITH DEBUG FLAGS: PLEASE EXPECT LARGE COMPUTATION TIMES!");
85 master.
start(hostname);
std::string get_option(char **argv_begin, char **argv_end, const std::string &option)
General service client for rpc communication.
int main(int argc, char **argv)
void start(const std::string &server_address, bool blocking=true)
Start master server (blocking call)
#define PRINT_DEBUG_WARN(msg)
Print message in debug mode with warning-color-code.
bool loadFromFile(const std::string &filename)
bool has_option(char **argv_begin, char **argv_end, const std::string &option)
#define PRINT_INFO(msg)
Print msg-stream.
#define PRINT_ERROR(msg)
Print msg-stream as error msg.