1 | #include "abstractSoftware.h" |
---|
2 | #include "dataManager.h" |
---|
3 | #include <algorithm> |
---|
4 | #include <iostream> |
---|
5 | |
---|
6 | abstractSoftware::abstractSoftware() |
---|
7 | { |
---|
8 | dataManager_ = NULL; |
---|
9 | nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); |
---|
10 | } |
---|
11 | |
---|
12 | abstractSoftware::abstractSoftware(string inputFileName, sectionToExecute* sect, dataManager* data) |
---|
13 | { |
---|
14 | inputFileName_ = inputFileName; |
---|
15 | sectionToExecute_ = sect; |
---|
16 | dataManager_ = data; |
---|
17 | nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | bool abstractSoftware::ComputationLimitsOk_deprecated() const |
---|
22 | { |
---|
23 | /* if (numeroDeb_deprecated_ < 1 || numeroFin_deprecated__ < 1 || numeroDeb_deprecated_ > dataManager_->getBeamLineSize() || numeroFin_deprecated__ > dataManager_->getBeamLineSize() ) { |
---|
24 | consoleMessage(" abstractSoftware::initComputationLimit : num of element out of limits in software " + getName() ); |
---|
25 | return false; |
---|
26 | } else { |
---|
27 | return true; |
---|
28 | } |
---|
29 | */ |
---|
30 | return true; |
---|
31 | } |
---|
32 | |
---|
33 | void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b) |
---|
34 | { |
---|
35 | // std::cout << " abstractSoftware::registerElement soft : " << nameOfSoftware_.getString() << std::endl; |
---|
36 | if (b == TBoolIgnore) { |
---|
37 | // std::cout << " abstractSoftware::registerElement j'enregistre element " << nomdel << " ignore " << std::endl; |
---|
38 | ignoredElements_.push_back(nomdel); |
---|
39 | } else if (b == TBoolOk) { |
---|
40 | // std::cout << " abstractSoftware::registerElement j'enregistre element " << nomdel << " OK " << std::endl; |
---|
41 | acceptedElements_.push_back(nomdel); |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel) |
---|
46 | { |
---|
47 | |
---|
48 | //xx |
---|
49 | if (acceptedElements_.size() == 0 && nameOfSoftware_ != nomDeLogiciel::unknownSoftware) { |
---|
50 | return TBoolError; |
---|
51 | } |
---|
52 | |
---|
53 | if (std::find(acceptedElements_.begin(),acceptedElements_.end(),typdel) != acceptedElements_.end()) { |
---|
54 | return TBoolOk; |
---|
55 | } |
---|
56 | |
---|
57 | if (ignoredElements_.size() == 0) { |
---|
58 | return TBoolError; |
---|
59 | } |
---|
60 | |
---|
61 | if (std::find(ignoredElements_.begin(),ignoredElements_.end(),typdel) != ignoredElements_.end()) { |
---|
62 | return TBoolIgnore; |
---|
63 | } |
---|
64 | |
---|
65 | return TBoolOk; |
---|
66 | } |
---|
67 | |
---|
68 | bool abstractSoftware::launchJob(string commandLine, string& resul) |
---|
69 | { |
---|
70 | bool ExecuteStatus = true; |
---|
71 | |
---|
72 | FILE* pp = popen(commandLine.c_str(), "r"); |
---|
73 | ostringstream sortie; |
---|
74 | if (pp == NULL) { |
---|
75 | sortie << " launching failed : " << commandLine << endl; |
---|
76 | ExecuteStatus = false; |
---|
77 | } else { |
---|
78 | // on copie la sortie dans le fichier assigne |
---|
79 | char buf[132]; |
---|
80 | while (fgets(buf, sizeof buf, pp)) |
---|
81 | { |
---|
82 | sortie << buf; |
---|
83 | } |
---|
84 | pclose(pp); |
---|
85 | } |
---|
86 | resul = sortie.str(); |
---|
87 | return ExecuteStatus; |
---|
88 | } |
---|