Fawkes API  Fawkes Development Version
mongodb_log_plugin.cpp
1 
2 /***************************************************************************
3  * mongodb_log_plugin.cpp - Fawkes MongoDB Logging Plugin
4  *
5  * Created: Wed Dec 08 23:04:33 2010
6  * Copyright 2010-2012 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #include "mongodb_log_bb_thread.h"
23 #include "mongodb_log_image_thread.h"
24 #include "mongodb_log_pcl_thread.h"
25 #include "mongodb_log_logger_thread.h"
26 #include "mongodb_log_tf_thread.h"
27 
28 #include <core/plugin.h>
29 
30 using namespace fawkes;
31 
32 /** MongoDB Logging Plugin.
33  * This plugin provides logging of BlackBoard data to MongoDB.
34  *
35  * @author Tim Niemueller
36  */
38 {
39  public:
40  /** Constructor.
41  * @param config Fawkes configuration
42  */
43  MongoLogPlugin(Configuration *config) : Plugin(config)
44  {
45  bool enable_bb = true;
46  try {
47  enable_bb = config->get_bool("/plugins/mongodb-log/enable-blackboard");
48  } catch (Exception &e) {}
49  if (enable_bb) {
50  thread_list.push_back(new MongoLogBlackboardThread());
51  }
52 
53  bool enable_pcls = true;
54  try {
55  enable_pcls = config->get_bool("/plugins/mongodb-log/enable-pointclouds");
56  } catch (Exception &e) {}
57  if (enable_pcls) {
58  thread_list.push_back(new MongoLogPointCloudThread());
59  }
60 
61  bool enable_images = true;
62  try {
63  enable_images = config->get_bool("/plugins/mongodb-log/enable-images");
64  } catch (Exception &e) {}
65  if (enable_images) {
66  thread_list.push_back(new MongoLogImagesThread());
67  }
68 
69  bool enable_logger = true;
70  try {
71  enable_logger = config->get_bool("/plugins/mongodb-log/enable-logger");
72  } catch (Exception &e) {}
73  if (enable_logger) {
74  thread_list.push_back(new MongoLogLoggerThread());
75  }
76 
77  bool enable_tf = true;
78  try {
79  enable_tf = config->get_bool("/plugins/mongodb-log/enable-transforms");
80  } catch (Exception &e) {}
81  if (enable_tf) {
82  thread_list.push_back(new MongoLogTransformsThread());
83  }
84 
85  if (thread_list.empty()) {
86  throw Exception("MongoLogPlugin: no logging thread enabled");
87  }
88 
89  std::string database = config->get_string("/plugins/mongodb-log/database");
90  config->set_string("/plugins/mongorrd/databases/mongodb-log", database);
91  }
92 
93 
95  {
96  try {
97  config->erase("/plugins/mongorrd/databases/mongodb-log");
98  } catch (fawkes::Exception &e) {} // ignore
99  }
100 
101 };
102 
103 
104 PLUGIN_DESCRIPTION("Logging of BlackBoard data to MongoDB")
105 EXPORT_PLUGIN(MongoLogPlugin)
Plugin interface class.
Definition: plugin.h:33
Thread that provides a logger writing to MongoDB.
Fawkes library namespace.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual void erase(const char *path)=0
Erase the given value from the configuration.
Base class for exceptions in Fawkes.
Definition: exception.h:36
MongoDB transforms logging thread.
Thread to store point clouds to MongoDB.
MongoDB Logging Thread.
Thread to export Fawkes images to MongoDB.
MongoLogPlugin(Configuration *config)
Constructor.
MongoDB Logging Plugin.
Interface for configuration handling.
Definition: config.h:67
virtual void set_string(const char *path, std::string &s)=0
Set new value in configuration of type string.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.