Fawkes API  Fawkes Development Version
mongodb_log_tf_thread.h
1 
2 /***************************************************************************
3  * mongodb_log_tf_thread.h - MongoDB transforms logging thread
4  *
5  * Created: Tue Dec 11 14:55:53 2012 (Freiburg)
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 #ifndef _PLUGINS_MONGODB_LOG_MONGODB_LOG_TF_THREAD_H_
23 #define _PLUGINS_MONGODB_LOG_MONGODB_LOG_TF_THREAD_H_
24 
25 #include <aspect/blackboard.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <aspect/tf.h>
30 #include <core/threading/thread.h>
31 #include <plugins/mongodb/aspect/mongodb.h>
32 #include <utils/time/time.h>
33 
34 #include <string>
35 #include <vector>
36 
37 namespace fawkes {
38 class TimeWait;
39 }
40 
42  public fawkes::LoggingAspect,
44  public fawkes::ClockAspect,
46  public fawkes::MongoDBAspect,
48 {
49 public:
51  virtual ~MongoLogTransformsThread();
52 
53  virtual void init();
54  virtual bool prepare_finalize_user();
55  virtual void loop();
56  virtual void finalize();
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  void store(std::vector<fawkes::tf::TimeCacheInterfacePtr> &caches,
68  std::vector<fawkes::Time> & from,
69  std::vector<fawkes::Time> & to);
70 
71 private:
72  fawkes::Mutex * mutex_;
73  fawkes::TimeWait * wait_;
74  std::string database_;
75  std::string collection_;
76  float cfg_storage_interval_;
77  std::vector<fawkes::Time> last_tf_range_end_;
78 };
79 
80 #endif
fawkes::MongoDBAspect
Definition: mongodb.h:43
fawkes::Mutex
Definition: mutex.h:38
MongoLogTransformsThread::~MongoLogTransformsThread
virtual ~MongoLogTransformsThread()
Destructor.
Definition: mongodb_log_tf_thread.cpp:55
MongoLogTransformsThread
Definition: mongodb_log_tf_thread.h:41
MongoLogTransformsThread::MongoLogTransformsThread
MongoLogTransformsThread()
Constructor.
Definition: mongodb_log_tf_thread.cpp:46
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
fawkes::TransformAspect
Definition: tf.h:43
MongoLogTransformsThread::finalize
virtual void finalize()
Finalize the thread.
Definition: mongodb_log_tf_thread.cpp:96
MongoLogTransformsThread::loop
virtual void loop()
Code to execute in the thread.
Definition: mongodb_log_tf_thread.cpp:103
fawkes::Thread
Definition: thread.h:45
fawkes::TimeWait
Definition: wait.h:38
fawkes::ConfigurableAspect
Definition: configurable.h:38
MongoLogTransformsThread::init
virtual void init()
Initialize the thread.
Definition: mongodb_log_tf_thread.cpp:60
fawkes::ClockAspect
Definition: clock.h:40
MongoLogTransformsThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: mongodb_log_tf_thread.h:61
MongoLogTransformsThread::prepare_finalize_user
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
Definition: mongodb_log_tf_thread.cpp:89