Fawkes API
Fawkes Development Version
mongodb_log_bb_thread.h
1
2
/***************************************************************************
3
* mongodb_log_bb_thread.h - MongoDB blackboard logging thread
4
*
5
* Created: Wed Dec 08 23:08:14 2010
6
* Copyright 2010-2012 Tim Niemueller [www.niemueller.de]
7
* 2012 Bastian Klingen
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef _PLUGINS_MONGODB_LOG_MONGODB_LOG_BB_THREAD_H_
24
#define _PLUGINS_MONGODB_LOG_MONGODB_LOG_BB_THREAD_H_
25
26
#include <aspect/blackboard.h>
27
#include <aspect/clock.h>
28
#include <aspect/configurable.h>
29
#include <aspect/logging.h>
30
#include <blackboard/interface_listener.h>
31
#include <blackboard/interface_observer.h>
32
#include <core/threading/thread.h>
33
#include <core/utils/lock_map.h>
34
#include <core/utils/lock_set.h>
35
#include <plugins/mongodb/aspect/mongodb.h>
36
37
#include <string>
38
39
class
MongoLogBlackboardThread
:
public
fawkes::Thread
,
40
public
fawkes::LoggingAspect
,
41
public
fawkes::ConfigurableAspect
,
42
public
fawkes::ClockAspect
,
43
public
fawkes::BlackBoardAspect
,
44
public
fawkes::MongoDBAspect
,
45
public
fawkes::BlackBoardInterfaceObserver
46
{
47
public
:
48
MongoLogBlackboardThread
();
49
virtual
~MongoLogBlackboardThread
();
50
51
virtual
void
init
();
52
virtual
void
loop
();
53
virtual
void
finalize
();
54
55
// for BlackBoardInterfaceObserver
56
virtual
void
bb_interface_created
(
const
char
*type,
const
char
*
id
)
throw
();
57
58
/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
59
protected
:
60
virtual
void
61
run
()
62
{
63
Thread::run();
64
}
65
66
private
:
67
/** Mongo Logger interface listener. */
68
class
InterfaceListener :
public
fawkes::BlackBoardInterfaceListener
69
{
70
public
:
71
InterfaceListener(
fawkes::BlackBoard
*
blackboard
,
72
fawkes::Interface
* interface,
73
mongocxx::client * mongodb,
74
std::string & database,
75
fawkes::LockSet<std::string>
&colls,
76
fawkes::Logger
*
logger
,
77
fawkes::Time
* now);
78
~InterfaceListener();
79
80
/** Get MongoDB Client.
81
* @return MongoDB client */
82
mongocxx::client *
83
mongodb_client
()
const
84
{
85
return
mongodb_;
86
}
87
88
// for BlackBoardInterfaceListener
89
virtual
void
bb_interface_data_changed(
fawkes::Interface
*interface)
throw
();
90
91
private
:
92
fawkes::BlackBoard
* blackboard_;
93
fawkes::Interface
* interface_;
94
mongocxx::client * mongodb_;
95
fawkes::Logger
* logger_;
96
std::string collection_;
97
std::string & database_;
98
fawkes::LockSet<std::string>
&collections_;
99
fawkes::Time
* now_;
100
};
101
102
fawkes::LockMap<std::string, InterfaceListener *>
listeners_;
103
fawkes::LockSet<std::string>
collections_;
104
std::string database_;
105
fawkes::Time
* now_;
106
107
std::vector<std::string> excludes_;
108
};
109
110
#endif
fawkes::MongoDBAspect
Definition:
mongodb.h:43
MongoLogBlackboardThread::MongoLogBlackboardThread
MongoLogBlackboardThread()
Constructor.
Definition:
mongodb_log_bb_thread.cpp:45
fawkes::LockMap< std::string, InterfaceListener * >
fawkes::MongoDBAspect::mongodb_client
mongocxx::client * mongodb_client
Definition:
mongodb.h:59
fawkes::LockSet< std::string >
fawkes::BlackBoardInterfaceListener
Definition:
interface_listener.h:47
MongoLogBlackboardThread::init
virtual void init()
Initialize the thread.
Definition:
mongodb_log_bb_thread.cpp:56
MongoLogBlackboardThread::finalize
virtual void finalize()
Finalize the thread.
Definition:
mongodb_log_bb_thread.cpp:113
fawkes::BlackBoard
Definition:
blackboard.h:50
MongoLogBlackboardThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
mongodb_log_bb_thread.cpp:127
MongoLogBlackboardThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition:
mongodb_log_bb_thread.h:67
MongoLogBlackboardThread::~MongoLogBlackboardThread
virtual ~MongoLogBlackboardThread()
Destructor.
Definition:
mongodb_log_bb_thread.cpp:51
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:53
fawkes::Logger
Definition:
logger.h:41
fawkes::BlackBoardAspect
Definition:
blackboard.h:38
fawkes::LoggingAspect
Definition:
logging.h:38
fawkes::BlackBoardInterfaceObserver
Definition:
interface_observer.h:42
fawkes::Interface
Definition:
interface.h:78
fawkes::Time
Definition:
time.h:98
MongoLogBlackboardThread::bb_interface_created
virtual void bb_interface_created(const char *type, const char *id)
BlackBoard interface created notification.
Definition:
mongodb_log_bb_thread.cpp:133
fawkes::Thread
Definition:
thread.h:45
fawkes::BlackBoardAspect::blackboard
BlackBoard * blackboard
Definition:
blackboard.h:49
fawkes::ConfigurableAspect
Definition:
configurable.h:38
fawkes::ClockAspect
Definition:
clock.h:40
MongoLogBlackboardThread
Definition:
mongodb_log_bb_thread.h:39
src
plugins
mongodb_log
mongodb_log_bb_thread.h
Generated by
1.8.17