removed warnings under g++ 2.7.0
[dyninst.git] / visiClients / barchart / barChartDriver.C
1 // barChartDriver.C
2
3 /* $Log: barChartDriver.C,v $
4 /* Revision 1.7  1995/09/22 19:25:04  tamches
5 /* removed warnings under g++ 2.7.0
6 /*
7  * Revision 1.6  1995/08/06  22:11:13  tamches
8  * barChart now uses tcl2c.
9  * Now needs no command-line args.
10  *
11  * Revision 1.5  1995/07/06  18:55:31  tamches
12  * Now contains a main program suitable for tk4.0
13  *
14  * Revision 1.4  1994/10/13  00:52:36  tamches
15  * Minor additions to support a new command related to sorting
16  * of resources
17  *
18  * Revision 1.3  1994/10/10  23:08:43  tamches
19  * preliminary changes on the way to swapping the x and y axes
20  *
21  * Revision 1.2  1994/09/29  20:05:36  tamches
22  * minor cvs fixes
23  *
24  * Revision 1.1  1994/09/29  19:50:51  tamches
25  * initial implementation.
26  * entrypoint for barchart C++ program.  we create new tcl
27  * commands (which will eventually call back to barChartTcl.C
28  * and from there barChart.C) and then launch barChart.tcl.
29  *
30 */
31
32 #include <assert.h>
33 #include <stdlib.h>
34 #include <iostream.h>
35
36 #include <tclclean.h>
37 #include <tkclean.h>
38 #include "dg2.h"
39 #include "barChartTcl.h"
40
41 void panic(const char *msg) {
42    cerr << msg << endl;
43    exit(5);
44 }
45
46 Tcl_Interp *MainInterp = NULL; // needed by Dg
47
48 int main(int argc, char **) {
49    // argc should be 3.  The first argv is of course the program name.
50    // The second is "-f".  The third is a full-path-name to the barchart tcl file.
51    if (argc == 2)
52       panic("barChart: argc should be 1");
53
54    if (argc > 3)
55       panic("barChart: argc should be at most 3");
56
57    if (argc == 3)
58       cout << "barChart notice: due to tcl2c, argc should be just 1 (was 3)...ignoring parameters" << endl;
59
60 //   char *tclFileName = argv[2];
61
62    MainInterp = Tcl_CreateInterp();
63    assert(MainInterp);
64
65    Tk_Window mainTkWindow = Tk_CreateMainWindow(MainInterp, NULL,
66                                                 "barChart",
67                                                 "BarChart"
68                                                 );
69    if (mainTkWindow == NULL) {
70       cerr << "Could not Tk_CreateMainWindow()!" << endl;
71       cerr << MainInterp->result << endl;
72       exit(5);
73    }
74
75    if (TCL_OK != Tcl_Init(MainInterp)) {
76       cerr << "Could not Tcl_Init: " << MainInterp->result << endl;
77       exit(5);
78    }
79
80    if (TCL_OK != Tk_Init(MainInterp)) {
81       cerr << "Could not Tk_Init: " << MainInterp->result << endl;
82       exit(5);
83    }
84
85    if (TCL_OK != Dg2_Init(MainInterp)) {
86       cerr << "Could not Dg2_Init: " << MainInterp->result << endl;
87       exit(5);
88    }
89
90 //   tcl_RcFileName = "~/.wishrc";
91    Tcl_SetVar(MainInterp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
92
93    // Install our new tcl commands
94    Tcl_CreateCommand(MainInterp, "resizeCallback", resizeCallbackCommand,
95                      NULL, // ClientData
96                      deleteDummyProc);
97
98    Tcl_CreateCommand(MainInterp, "exposeCallback", exposeCallbackCommand,
99                      NULL, // ClientData
100                      deleteDummyProc);
101
102    Tcl_CreateCommand(MainInterp, "resourcesAxisHasChanged", resourcesAxisHasChangedCommand,
103                      NULL, // ClientData
104                      deleteDummyProc);
105
106    Tcl_CreateCommand(MainInterp, "metricsAxisHasChanged", metricsAxisHasChangedCommand,
107                      NULL, // ClientData
108                      deleteDummyProc);
109
110    Tcl_CreateCommand(MainInterp, "newScrollPosition", newScrollPositionCommand,
111                      NULL, // ClientData
112                      deleteDummyProc);
113
114    Tcl_CreateCommand(MainInterp, "dataFormatHasChanged", dataFormatHasChangedCommand,
115                      NULL, // ClientData
116                      deleteDummyProc);
117
118    Tcl_CreateCommand(MainInterp, "rethinkIndirectResourcesCallback", rethinkIndirectResourcesCommand,
119                      NULL, // ClientData
120                      deleteDummyProc);
121
122    Tcl_CreateCommand(MainInterp, "launchBarChart", launchBarChartCommand,
123                      NULL, // ClientData
124                      deleteLaunchBarChartCommand);
125
126 //   if (TCL_ERROR == Tcl_EvalFile(MainInterp, tclFileName)) {
127 //      cerr << "barChart: Tcl_EvalFile() on \"" << tclFileName << "\" failed." << endl;
128 //      cerr << MainInterp->result << endl;
129 //      exit(5);
130 //   }
131
132    // Krishna's tcl2c stuff gets loaded here:
133    // (initialize_tcl_sources() was auto-generated by 'tcl2c')
134    extern int initialize_tcl_sources(Tcl_Interp *);
135    if (TCL_OK != initialize_tcl_sources(MainInterp)) {
136       cerr << "barChart: could not initialize_tcl_sources: " << MainInterp->result << endl;
137       exit(5);
138    }
139    cout << "barChart: initialize_tcl_sources successful!" << endl;
140
141    Tk_MainLoop(); // returns when all tk windows are closed
142
143    
144 }