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
MongoDB transforms logging thread.
virtual ~MongoLogTransformsThread()
Destructor.
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize the thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void loop()
Code to execute in the thread.
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:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Thread aspect to access MongoDB.
Definition: mongodb.h:39
Mutex mutual exclusion lock.
Definition: mutex.h:33
Thread class encapsulation of pthreads.
Definition: thread.h:46
Time wait utility.
Definition: wait.h:33
Thread aspect to access the transform system.
Definition: tf.h:39
Fawkes library namespace.