source: trunk/FACT++/gui/fact.cc@ 10543

Last change on this file since 10543 was 10518, checked in by tbretz, 14 years ago
Added latest changes, which includes almost a complete FTM support and implements root-plots.
File size: 3.9 KB
Line 
1#include "FactGui.h"
2
3#include "src/Configuration.h"
4
5/*
6 Extract usage clause(s) [if any] for SYNOPSIS.
7 Translators: "Usage" and "or" here are patterns (regular expressions) which
8 are used to match the usage synopsis in program output. An example from cp
9 (GNU coreutils) which contains both strings:
10 Usage: cp [OPTION]... [-T] SOURCE DEST
11 or: cp [OPTION]... SOURCE... DIRECTORY
12 or: cp [OPTION]... -t DIRECTORY SOURCE...
13 */
14void PrintUsage()
15{
16 cout << "\n"
17 "The console connects to all available Dim Servers and allows to "
18 "easily access all of their commands.\n"
19 "\n"
20 "Usage: test3 [-c type] [OPTIONS]\n"
21 " or: test3 [OPTIONS]\n"
22 "\n"
23 "Options:\n"
24 "The following describes the available commandline options. "
25 "For further details on how command line option are parsed "
26 "and in which order which configuration sources are accessed "
27 "please refer to the class reference of the Configuration class.";
28 cout << endl;
29
30}
31
32void PrintHelp()
33{
34 cout << "\n"
35 "The default is that the program is started without user interaction. "
36 "All actions are supposed to arrive as DimCommands. Using the -c "
37 "option, a local shell can be initialized. With h or help a short "
38 "help message about the usuage can be brought to the screen."
39 << endl;
40
41 /*
42 cout << "bla bla bla" << endl << endl;
43 cout << endl;
44 cout << "Environment:" << endl;
45 cout << "environment" << endl;
46 cout << endl;
47 cout << "Examples:" << endl;
48 cout << "test exam" << endl;
49 cout << endl;
50 cout << "Files:" << endl;
51 cout << "files" << endl;
52 cout << endl;
53 */
54}
55
56/*
57 The first line of the --version information is assumed to be in one
58 of the following formats:
59
60 <version>
61 <program> <version>
62 {GNU,Free} <program> <version>
63 <program> ({GNU,Free} <package>) <version>
64 <program> - {GNU,Free} <package> <version>
65
66 and separated from any copyright/author details by a blank line.
67
68 Handle multi-line bug reporting sections of the form:
69
70 Report <program> bugs to <addr>
71 GNU <package> home page: <url>
72 ...
73*/
74void PrintVersion(const char *name)
75{
76 cout <<
77 name << " - "PACKAGE_STRING"\n"
78 "\n"
79 "Written by Thomas Bretz et al.\n"
80 "\n"
81 "Report bugs to <"PACKAGE_BUGREPORT">\n"
82 "Home page: "PACKAGE_URL"\n"
83 "\n"
84 "Copyright (C) 2011 by the FACT Collaboration.\n"
85 "This is free software; see the source for copying conditions.\n"
86 << endl;
87}
88
89
90void SetupConfiguration(Configuration &conf)
91{
92 po::options_description config("Program options");
93 config.add_options()
94 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
95 ;
96
97 conf.AddEnv("dns", "DIM_DNS_NODE");
98
99 conf.AddOptions(config);
100}
101
102int main(int argc, const char* argv[])
103{
104 Configuration conf(argv[0]);
105 conf.SetPrintUsage(PrintUsage);
106 SetupConfiguration(conf);
107
108 po::variables_map vm;
109 try
110 {
111 vm = conf.Parse(argc, argv);
112 }
113 catch (std::exception &e)
114 {
115#if BOOST_VERSION > 104000
116 po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
117 if (MO)
118 cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
119 else
120#endif
121 cout << "Error: " << e.what() << endl;
122 cout << endl;
123
124 return -1;
125 }
126
127 if (conf.HasPrint())
128 return -1;
129
130 if (conf.HasVersion())
131 {
132 PrintVersion(argv[0]);
133 return -1;
134 }
135
136 if (conf.HasHelp())
137 {
138 PrintHelp();
139 return -1;
140 }
141
142 // To allow overwriting of DIM_DNS_NODE set 0 to 1
143 setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
144
145
146 QApplication app(argc, const_cast<char**>(argv));
147
148 FactGui gui;
149 gui.show();
150
151 return app.exec();
152}
Note: See TracBrowser for help on using the repository browser.