forked from douglascraigschmidt/CPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (31 loc) · 1.16 KB
/
Copy pathmain.cpp
File metadata and controls
39 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <functional>
#include <algorithm>
#include <memory>
#include "Options.h"
#include "Reactor.h"
#include "Expression_Tree_Event_Handler.h"
int
main (int argc, char *argv[])
{
// Create Options singleton to parse command line options.
std::auto_ptr<Options> options (Options::instance ());
// Parse the command-line options.
if (!options->parse_args (argc, argv))
return 0;
// Create Reactor singleton to run application event loop.
std::auto_ptr<Reactor> reactor (Reactor::instance ());
// Dynamically allocate the appropriate event handler based on the
// command-line options.
Expression_Tree_Event_Handler *tree_event_handler =
Expression_Tree_Event_Handler::make_handler (options->verbose ());
// Register the event handler with the reactor. The reactor is
// responsible for triggering the deletion of the event handler
reactor->register_input_handler (tree_event_handler);
// Run the reactor's event loop, which drives all the processing via
// callbacks to registered event handlers.
reactor->run_event_loop ();
// The std::auto_ptr destructors automatically destroy the
// singletons.
return 0;
}