8 #include "tclap/CmdLine.h"
10 #include <g3log/g3log.hpp>
11 #include <g3log/logworker.hpp>
18 using Function = std::function<int()>;
20 class FunctionRegister :
public map<string, Function>
24 bool is_valid(
string const& fname)
const {
return find(fname) != end(); }
27 void list(ostream& os)
const
29 map<string, Function>::const_iterator itor;
30 os <<
" The available tests are:" << endl << endl;
31 for (itor = begin(); itor != end(); itor++) {
32 os << (*itor).first << endl;
39 int main(
int argc,
char* argv[])
46 std::unique_ptr<g3::LogWorker> g3log{g3::LogWorker::createLogWorker()};
47 g3log->addDefaultLogger(argv[0], logPath);
48 g3::initializeLogging(g3log.get());
49 cout <<
"Process the log with \"cut -f 2 -d ] <logfile>\" to get a clean output." << endl;
54 TCLAP::CmdLine cmd(
"Driver for object tracer demos",
' ',
"1.0");
55 TCLAP::ValueArg<string> exec_arg(
"",
"exec",
"Demo to execute",
false,
"",
"string", cmd);
56 cmd.parse(argc, static_cast<const char* const*>(argv));
58 LOG(INFO) <<
"Starting main program ...";
63 FunctionRegister f_reg;
76 if (exec_arg.isSet()) {
77 choice = exec_arg.getValue();
81 ios_base::iostate old_state = cin.exceptions();
82 cin.exceptions(ios_base::eofbit);
84 cout <<
"Select a demo by name: ";
86 if (f_reg.is_valid(choice)) {
89 cout <<
"error on input: invalid demo name" << endl;
92 cin.exceptions(old_state);
98 if (!f_reg.is_valid(choice)) {
106 cout << endl <<
"Exiting ... " << endl;
108 }
catch (TCLAP::ArgException& e) {
109 cerr <<
"error: " << e.error() <<
" for arg " << e.argId() <<
" " << endl;
110 }
catch (exception& e) {
111 cerr << endl <<
"Caught std exception" << endl;
112 cerr << e.what() << endl <<
"Exiting ..." << endl;
114 cerr << endl <<
"Caught unknown exception. Exiting ..." << endl;
int app_essentialops()
Demo prog for features of ctor/dtor.
Header for object tracer demo routines.
Implementation for exception.
int app_exception()
Demo prog for ctor/dtor features in class derivation.
int app_poly1()
Demonstrates late binding.
int app_copy()
Demo prog to demonstrate deep & shallow copy operations.
Extremely simple Exception root class.
int app_poly2()
Demonstrates late binding.
int app_fcalls()
Demo prog for features of essential ops.
int app_hierarchies()
Demo prog for ctor/dtor features in class derivation.
int main(int argc, char *argv[])