29 #include <arcs/arcsapplicationcomponent.h>
30 #include <arcs/arcsxmlhandler.h>
31 #include <arcs/arcslog.h>
185 void usage(
char* name)
187 std::cout << name <<
" [OPTION]... [XML_FILE]..." << std::endl
189 std::cout <<
" -h, --help : print this help" << std::endl << std::endl;
190 std::cout <<
"Overriding application mode : " << std::endl << std::endl;
191 std::cout <<
" -b, --mode-base : simple loop based applications."
193 std::cout <<
" -e, --mode-event : event loop based console applications."
195 std::cout <<
" -g, --mode-gui : event loop based GUI applications."
197 std::cout <<
" -t, --mode-thread : threaded application." << std::endl;
198 std::cout <<
" -te, --mode-thread-event: threaded event based application." << std::endl <<std::endl;
199 std::cout <<
"Defining options:" << std::endl;
200 std::cout <<
" -d, --define vars : define constants" << std::endl;
201 std::cout <<
" -p, --profile file : define a profile" << std::endl;
202 std::cout <<
" -o, --profile-out : define a file where to dump profile" << std::endl;
203 std::cout <<
" -l [0-2] : define output log mode - 0, none; 1, console (default); 2, html" << std::endl;
207 void parseOptions(
int argc,
char* argv[],
ARCS::ARCSAppFlag & flag, QString & constantList, QString & xmlfile, QString & profile, QString& profileOut)
212 for(i=1; i < argc; i++)
214 QString current(argv[i]);
216 if (current ==
"-h" || current ==
"--help")
219 if (current ==
"-b" || current ==
"--mode-base")
222 if (current ==
"-e" || current ==
"--mode-event")
225 if (current ==
"-g" || current ==
"--mode-gui")
228 if (current ==
"-t" || current ==
"--mode-thread")
231 if (current ==
"-te" || current ==
"--mode-thread-event")
244 if (current ==
"-d" || current ==
"--define")
248 constantList = argv[i+1];
254 if (current ==
"-p" || current ==
"--profile")
264 if (current ==
"-o" || current ==
"--profile-out")
268 profileOut = argv[i+1];
284 QStringList lst = arglist.split(
":");
285 for (i=0; i < lst.count(); i++)
287 QStringList lst_2 = lst[i].split(
"=");
288 if (lst_2.count() == 2)
290 std::cout <<
"Overriding constant " << qPrintable(lst_2[0])
291 <<
" with value " << qPrintable(lst_2[1]) << std::endl;
301 int main(
int argc,
char* argv[])
308 QString constantList;
310 parseOptions(argc,argv, flag, constantList, xmlfile,profileFile,profileOut);
312 if (xmlfile.isEmpty())
323 std::cerr <<
"An error occured when trying to load the application" << std::endl;
327 std::cout <<
"Application " << qPrintable(xmlfile) <<
" loaded." << std::endl
328 <<
"==================================================" << std::endl;
330 if (!profileFile.isEmpty())
333 if (xmlHandler->
openFile(profileFile))
334 if (! xmlHandler->parseProfile(app->
getContext()))
335 std::cerr <<
"Could not read profile file." << std::endl;
340 if (!constantList.isEmpty())
341 parseConstants(constantList, app);
346 if (!profileOut.isEmpty())
350 if (!xmlHandler->
saveFile(profileOut))
351 std::cerr <<
"Could not write profile file." << std::endl;
ARCSAppFlag
Flags to specify in which mode applications should start.
For applications running with Qt Widgets.
void changeConstant(QString name, QString representation)
This hack allows to change the value of a constant in the constant pool.
This class represents an application.
void setCurrentMode(ARCS::ARCSAppFlag flag)
bool openFile(QString s)
Opens a file given its path. The file should describe either an application or a composite component...
None of the application mode has been selected so far.
For applications nested in a thread.
static ARCSLog * getInstance()
returns the only instance of the logging system that is available
bool saveFile(QString s)
Saves a file given its path. The file will describe either an application or a composite component...
virtual bool loadFile(QString fn)
Defines a way to load a component description from a file.
ARCSContext * getContext()
For applications nested in a thread running with an event loop.
For applications requiring event loops.
This is an XML Handler for all ARCS native XML formats.