Fawkes API  Fawkes Development Version
mongodb_thread.h
1 
2 /***************************************************************************
3  * mongodb_thread.h - MongoDB thread
4  *
5  * Created: Sun Dec 05 23:25:20 2010
6  * Copyright 2006-2015 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_MONGODB_THREAD_H_
23 #define __PLUGINS_MONGODB_MONGODB_THREAD_H_
24 
25 #include <plugins/mongodb/aspect/mongodb_conncreator.h>
26 #include <plugins/mongodb/aspect/mongodb_inifin.h>
27 #include <core/threading/thread.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/aspect_provider.h>
32 
33 // from MongoDB
34 #include <mongo/client/dbclient.h>
35 
36 #include <vector>
37 #include <list>
38 #include <string>
39 #include <cstdlib>
40 
42 : public fawkes::Thread,
43  public fawkes::LoggingAspect,
45  public fawkes::ClockAspect,
48 {
49  public:
50  MongoDBThread();
51  virtual ~MongoDBThread();
52 
53  virtual void init();
54  virtual void loop();
55  virtual void finalize();
56 
57  virtual mongo::DBClientBase * create_client(const char *config_name = 0);
58  virtual void delete_client(mongo::DBClientBase *client);
59 
60  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
61  protected: virtual void run() { Thread::run(); }
62 
63  private:
64  class ClientConf;
65  std::map<std::string, ClientConf *> __configs;
66 
67  fawkes::MongoDBAspectIniFin __mongodb_aspect_inifin;
68 };
69 
70 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
virtual void finalize()
Finalize the thread.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Client configuration.
virtual ~MongoDBThread()
Destructor.
virtual void loop()
Code to execute in the thread.
MongoDB Thread.
MongoDBAspect initializer/finalizer.
Thread aspect to log output.
Definition: logging.h:35
Interface for a MongoDB connection creator.
Thread aspect provide a new aspect.
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual mongo::DBClientBase * create_client(const char *config_name=0)
Create a new MongoDB client.
MongoDBThread()
Constructor.
virtual void delete_client(mongo::DBClientBase *client)
Delete a client.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void init()
Initialize the thread.