00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "bbsync_plugin.h"
00024 #include "sync_thread.h"
00025
00026 #include <set>
00027
00028 using namespace fawkes;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 BlackBoardSynchronizationPlugin::BlackBoardSynchronizationPlugin(Configuration *config)
00042 : Plugin(config)
00043 {
00044 std::set<std::string> peers;
00045 std::set<std::string> ignored_peers;
00046
00047 std::string prefix = "/fawkes/bbsync/";
00048 std::string peers_prefix = prefix + "peers/";
00049
00050 Configuration::ValueIterator *i = config->search(peers_prefix.c_str());
00051 while (i->next()) {
00052 std::string peer = std::string(i->path()).substr(peers_prefix.length());
00053 peer = peer.substr(0, peer.find("/"));
00054
00055 if ( (peers.find(peer) == peers.end()) &&
00056 (ignored_peers.find(peer) == ignored_peers.end()) ) {
00057
00058 std::string peer_prefix = peers_prefix + peer + "/";
00059
00060 bool active = true;
00061 try {
00062 active = config->get_bool((peer_prefix + "active").c_str());
00063 } catch (Exception &e) {}
00064
00065 if (active) {
00066
00067 BlackBoardSynchronizationThread *sync_thread;
00068 sync_thread = new BlackBoardSynchronizationThread(prefix, peer_prefix, peer);
00069 peers.insert(peer);
00070 thread_list.push_back(sync_thread);
00071 } else {
00072
00073 ignored_peers.insert(peer);
00074 }
00075 }
00076 }
00077 delete i;
00078
00079 if ( thread_list.empty() ) {
00080 throw Exception("No synchronization peers configured, aborting");
00081 } else {
00082 }
00083 }
00084
00085 PLUGIN_DESCRIPTION("Synchronize with remote Fawkes BlackBoards")
00086 EXPORT_PLUGIN(BlackBoardSynchronizationPlugin)