lemAutoRun  1.0
lemAutoRun_validate.cpp
Go to the documentation of this file.
1 /********************************************************************************************
2 
3  lemAutoRun_validate.cpp
4 
5 *********************************************************************************************
6 
7  begin : Andreas Suter, 2006/04/25
8  modfied: :
9  copyright : (C) 2007 by
10  email : andreas.suter@psi.ch
11 
12 ********************************************************************************************/
13 
14 /***************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  ***************************************************************************/
22 
23 #include <iostream>
24 using namespace std;
25 
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include <QCoreApplication>
30 #include <QObject>
31 #include <QString>
32 
33 #include <QFile>
34 #include <QTimer>
35 
36 #include "PAutoRunParser.h"
37 #include "PValidateErrorHandler.h"
38 #include "PLemAutoRun.h"
39 
40 #include "msystem.h"
41 
42 //---------------------------------------------------------------------------------------
49 int main(int argc, char *argv[])
50 {
51  // create main Qt application entry point, the last entry forces it to be a console application
52  QCoreApplication app(argc, argv, false);
53 
54  PLemAutoRun *autoRun;
55  PAutoRunParser *autoRunParser;
56  PValidateErrorHandler *errorHandler;
57  PAutoRunCmdVector *autoRunCmdVector;
58  POdbTagVector *odbTagVector;
59 
60  // check arguments
61  if (argc != 2) {
62  cout << endl << "usage: lemAutoRun_validate larFile";
63  cout << endl << " larFile is the user autorun sequence, e.g. test.lar";
64  cout << endl << endl;
65  return 0;
66  }
67 
68  // create auto run object and error handler
69  QString host = "validate";
70  QString exp = "validate";
71  autoRun = new PLemAutoRun(host, exp);
72  QString autoRunFln = QString(argv[1]);
73 
74  // try to read startup XML file
75  autoRun->ReadStartupXML();
76 
77  // create auto run sequence parser and object
78  autoRunCmdVector = new PAutoRunCmdVector();
79  odbTagVector = new POdbTagVector();
80  autoRunParser = new PAutoRunParser(autoRunFln,
81  *autoRun->GetXMLSchemaFln(),
82  *autoRun->GetXMLAutoRunValidateFln(),
83  autoRunCmdVector,
84  odbTagVector);
85 
86  errorHandler = new PValidateErrorHandler();
87 
88  // connect autoRun with errorHandler
89  QObject::connect(autoRunParser, SIGNAL(ParseError(int,int,int,int,QString)),
90  errorHandler, SLOT(HandleErrors(int,int,int,int,QString)));
91 
92  // convert user auto run sequence to the XML auto run sequence
93  autoRunParser->ConvertToXML();
94 
95  // parse the XML auto run sequence
96  autoRunParser->Parse();
97 
98  int errs = autoRunParser->GetParseErrorCounts();
99  if (errs == 0) {
100  cout << endl << "Autorun sequence OK" << endl << endl;
101  } else {
102  cout << endl << endl << "Number of errors encountered before giving up: " << errs;
103  if (errs > 5)
104  cout << endl << "You really should consider to read the manual ;-)";
105  cout << endl << endl;
106  }
107 
108  // clean up objects
109  if (autoRunParser)
110  delete autoRunParser;
111  if (odbTagVector)
112  delete odbTagVector;
113  if (autoRunCmdVector)
114  delete autoRunCmdVector;
115  if (errorHandler)
116  delete errorHandler;
117  if (autoRun)
118  delete autoRun;
119 
120  return errs;
121 }
122 
123 //---------------------------------------------------------------------------------------
124 // end
125 //---------------------------------------------------------------------------------------
int GetParseErrorCounts()
QVector< AutoRunCmd > PAutoRunCmdVector
Definition: lemAutoRun.h:233
QString * GetXMLAutoRunValidateFln()
Definition: PLemAutoRun.h:240
int main(int argc, char *argv[])
QVector< OdbTag > POdbTagVector
Definition: lemAutoRun.h:249
QString * GetXMLSchemaFln()
Definition: PLemAutoRun.h:238
void ReadStartupXML()