23 #include "laser_filter_plugin.h"
25 #include "filter_thread.h"
27 #include <core/threading/barrier.h>
32 using namespace fawkes;
50 std::set<std::string> configs;
51 std::set<std::string> ignored_configs;
52 std::map<std::string, LaserFilterThread *>
threads;
54 std::string prefix =
"/plugins/laser-filter/";
57 std::auto_ptr<Configuration::ValueIterator> i(config->
search(prefix.c_str()));
59 std::string cfg_name = std::string(i->
path()).substr(prefix.length());
60 cfg_name = cfg_name.substr(0, cfg_name.find(
"/"));
62 if ( (configs.find(cfg_name) == configs.end()) &&
63 (ignored_configs.find(cfg_name) == ignored_configs.end()) ) {
65 std::string cfg_prefix = prefix + cfg_name +
"/";
69 active = config->
get_bool((cfg_prefix +
"active").c_str());
76 threads[cfg_name] = thread;
77 configs.insert(cfg_name);
80 ignored_configs.insert(cfg_name);
93 throw Exception(
"No active laser filters configured, aborting");
98 std::map<std::string, std::list<std::string> > inputs;
99 std::map<std::string, std::list<std::string> > outputs;
100 std::set<std::string>::iterator c, d;
102 for (c = configs.begin(); c != configs.end(); ++c) {
103 std::string cinp = prefix + *c +
"/in/";
104 std::list<std::string> cinputs;
105 std::auto_ptr<Configuration::ValueIterator> in(config->
search(cinp.c_str()));
112 std::string coutp = prefix + *c +
"/out/";
113 std::list<std::string> coutputs;
114 std::auto_ptr<Configuration::ValueIterator> out(config->
search(coutp.c_str()));
115 while (out->
next()) {
121 inputs[*c] = cinputs;
122 outputs[*c] = coutputs;
129 bool has_deps =
false;
130 for (c = configs.begin(); c != configs.end(); ++c) {
134 std::list<LaserFilterThread *> depthreads;
136 std::list<std::string>::iterator i, o;
137 std::list<std::string> &cinputs = inputs[*c];
138 for (i = cinputs.begin(); i != cinputs.end(); ++i) {
141 for (d = configs.begin(); d != configs.end(); ++d) {
142 if (*c == *d)
continue;
145 std::list<std::string> &coutputs = outputs[*d];
146 for (o = coutputs.begin(); o != coutputs.end(); ++o) {
152 depthreads.push_back(threads[*d]);
159 if (! depthreads.empty()) {
162 threads[*c]->set_wait_threads(depthreads);
170 std::map<std::string, LaserFilterThread *>::iterator t;
171 __barrier =
new Barrier(threads.size());
172 for (t = threads.begin(); t != threads.end(); ++t) {
173 t->second->set_wait_barrier(__barrier);
178 ThreadList::iterator t;
187 LaserFilterPlugin::~LaserFilterPlugin()
193 PLUGIN_DESCRIPTION(
"Filter laser data in blackboard")
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
virtual bool next()=0
Check if there is another element and advance to this if possible.
ThreadList & threads()
Get a list of threads.
virtual bool is_string() const =0
Check if current value is a string.
Base class for exceptions in Fawkes.
ThreadList thread_list
Thread list member.
virtual std::string get_string() const =0
Get string value.
virtual const char * path() const =0
Path of value.
void push_back(Thread *thread)
Add thread to the end.
Laser filter plugin for Fawkes.
LaserFilterPlugin(fawkes::Configuration *config)
Constructor.
Interface for configuration handling.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...