00001
00002 #include "cafe/Permute.hpp"
00003
00004 #include "cafe/Config.hpp"
00005 #include "cafe/ParseRun.hpp"
00006
00007 #include <vector>
00008 #include <string>
00009 #include <algorithm>
00010
00011 namespace cafe {
00012
00013
00014 Permute::Permute(const char *name)
00015 : Controller(name, std::list<Processor*>())
00016 {
00017 using namespace std;
00018
00019 Config config(name);
00020 vector<string> runs = config.getVString("Run"," ,");
00021
00022 if(!runs.empty()) {
00023
00024 sort(runs.begin(), runs.end());
00025 do {
00026 string key(name);
00027 string result;
00028 for(vector<string>::iterator it = runs.begin();
00029 it != runs.end();
00030 ++it) {
00031 key += "_";
00032 key += *it;
00033
00034 result += " ";
00035 result += *it;
00036 }
00037
00038 result += " ";
00039 result += "Passed";
00040
00041
00042
00043
00044
00045
00046
00047 config.set(key + ".Run", result);
00048 config.set(key + ".Directory", key);
00049 add(new Controller(key.c_str()));
00050
00051 } while(next_permutation(runs.begin(), runs.end()));
00052 }
00053 }
00054
00055 bool Permute::processEvent(cafe::Event& event)
00056 {
00057 for(std::list<Processor*>::iterator it = _processors.begin();
00058 it != _processors.end();
00059 ++it) {
00060 (*it)->incEventCount();
00061 (*it)->processEvent(event);
00062 }
00063 return true;
00064 }
00065
00066 Permute::~Permute()
00067 {}
00068
00069 }
00070
00071 ClassImp(cafe::Permute)