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 <core/threading/thread.h>
26 #include <utils/time/time.h>
27 #include <aspect/logging.h>
28 #include <aspect/configurable.h>
29 #include <aspect/clock.h>
30 #include <aspect/blackboard.h>
31 #include <aspect/tf.h>
32 #include <plugins/mongodb/aspect/mongodb.h>
33 
34 #include <string>
35 #include <vector>
36 
37 namespace fawkes {
38  class TimeWait;
39 }
40 
42 : public fawkes::Thread,
43  public fawkes::LoggingAspect,
45  public fawkes::ClockAspect,
47  public fawkes::MongoDBAspect,
49 {
50  public:
52  virtual ~MongoLogTransformsThread();
53 
54  virtual void init();
55  virtual bool prepare_finalize_user();
56  virtual void loop();
57  virtual void finalize();
58 
59  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
60  protected: virtual void run() { Thread::run(); }
61 
62  private:
63  void store(std::vector<fawkes::tf::TimeCacheInterfacePtr> &caches,
64  std::vector<fawkes::Time> &from, std::vector<fawkes::Time> &to);
65 
66  private:
67  fawkes::Mutex *mutex_;
68  fawkes::TimeWait *wait_;
69  std::string database_;
70  std::string collection_;
71  float cfg_storage_interval_;
72  std::vector<fawkes::Time> last_tf_range_end_;
73 };
74 
75 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to access the transform system.
Definition: tf.h:42
Thread aspect to access MongoDB.
Definition: mongodb.h:40
MongoDB transforms logging thread.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Mutex mutual exclusion lock.
Definition: mutex.h:32
Time wait utility.
Definition: wait.h:32
virtual void run()
Stub to see name in backtrace for easier debugging.