forked from aymara/lima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestProcessUnitFramework.cpp
122 lines (97 loc) · 4.39 KB
/
testProcessUnitFramework.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright 2002-2019 CEA LIST
This file is part of LIMA.
LIMA is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LIMA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with LIMA. If not, see <http://www.gnu.org/licenses/>
*/
/***************************************************************************
* Copyright (C) 2004 by CEA - LIST *
* *
***************************************************************************/
#include "common/LimaCommon.h"
#include "dummyProcessUnits.h"
#include "common/AbstractFactoryPattern/AmosePluginsManager.h"
#include "common/AbstractFactoryPattern/SimpleFactory.h"
#include "common/ProcessUnitFramework/AnalysisContent.h"
#include "common/tools/LimaMainTaskRunner.h"
#include "common/XMLConfigurationFiles/moduleConfigurationStructure.h"
#include "common/XMLConfigurationFiles/groupConfigurationStructure.h"
#include <QtCore/QTimer>
#include <QtCore/QCoreApplication>
using namespace std;
using namespace Lima;
SimpleFactory<DummyProcessUnit,DreamingProcessUnit> dreamingFactory("DreamingProcessUnit");
SimpleFactory<DummyProcessUnit,ZenProcessUnit> zenFactory("ZenProcessUnit");
SimpleFactory<DummyProcessUnit,DummyProcessUnitPipeline> pipFactory("ProcessUnitPipeline");
//****************************************************************************
int run(int aargc, char** aargv);
int main(int argc, char** argv)
{
QCoreApplication a(argc, argv);
// Task parented to the application so that it
// will be deleted by the application.
LimaMainTaskRunner* task = new LimaMainTaskRunner(argc, argv, run, &a);
// This will cause the application to exit when
// the task signals finished.
QObject::connect(task, SIGNAL(finished(int)), &a, SLOT(quit()));
// This will run the task from the application event loop.
QTimer::singleShot(0, task, SLOT(run()));
return a.exec();
}
int run(int argc, char** argv)
{
LIMA_UNUSED(argc);
LIMA_UNUSED(argv);
QsLogging::initQsLog();
// Necessary to initialize factories
Lima::AmosePluginsManager::single();
cout << "dummy program, just to instantiate templates from ProcessUnitFramework" << endl;
// build fake moduleconfigurationstructure
Common::XMLConfigurationFiles::ModuleConfigurationStructure modconf("carpet");
{
modconf.addGroupNamed("myDreamer");
Common::XMLConfigurationFiles::GroupConfigurationStructure& groupConf=modconf.getGroupNamed("myDreamer");
groupConf.addAttribute("class","DreamingProcessUnit");
}
{
modconf.addGroupNamed("otherDreamer");
Common::XMLConfigurationFiles::GroupConfigurationStructure& groupConf=modconf.getGroupNamed("otherDreamer");
groupConf.addAttribute("class","DreamingProcessUnit");
}
{
modconf.addGroupNamed("myZen");
Common::XMLConfigurationFiles::GroupConfigurationStructure& groupConf=modconf.getGroupNamed("myZen");
groupConf.addAttribute("class","ZenProcessUnit");
}
{
modconf.addGroupNamed("myPipeline");
Common::XMLConfigurationFiles::GroupConfigurationStructure& groupConf=modconf.getGroupNamed("myPipeline");
groupConf.addAttribute("class","ProcessUnitPipeline");
groupConf.addListNamed("processUnitSequence");
groupConf.addItemInListNamed("myDreamer","processUnitSequence");
groupConf.addItemInListNamed("otherDreamer","processUnitSequence");
groupConf.addItemInListNamed("myZen","processUnitSequence");
groupConf.addItemInListNamed("myDreamer","processUnitSequence");
}
DummyProcessUnit::Manager manager(modconf);
DummyProcessUnit* pip=manager.getObject("myPipeline");
if (pip==0) {
cerr << "FAILED : Getting myPipeline failed !!" << endl;
return -1;
}
AnalysisContent ac;
if (pip->process(ac) != SUCCESS_ID) {
cerr << "FAILED : Getting myPipeline failed !!" << endl;
return -1;
}
cout << "test is OK. Have a good day, and remember to wash your teeth after diner ..." << endl;
return 0;
}