main_thread.h

00001 
00002 /***************************************************************************
00003  *  main_thread.h - Fawkes main thread
00004  *
00005  *  Created: Thu Nov  2 16:46:37 2006
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __FAWKES_MAIN_THREAD_H_
00025 #define __FAWKES_MAIN_THREAD_H_
00026 
00027 #include <core/threading/thread.h>
00028 #include <aspect/mainloop/employer.h>
00029 #include <aspect/logger/employer.h>
00030 
00031 #include <list>
00032 #include <string>
00033 
00034 namespace fawkes {
00035   class ArgumentParser;
00036   class LocalBlackBoard;
00037   class Configuration;
00038   class SQLiteConfiguration;
00039   class ConfigNetworkHandler;
00040   class MultiLogger;
00041   class NetworkLogger;
00042   class Clock;
00043   class TimeWait;
00044   class AspectIniFin;
00045   class PluginManager;
00046   class Time;
00047   class PluginNetworkHandler;
00048   class InterruptibleBarrier;
00049   class Mutex;
00050 }
00051 class FawkesThreadManager;
00052 class FawkesNetworkManager;
00053 
00054 class FawkesMainThread
00055 : public fawkes::Thread,
00056   public fawkes::MainLoopEmployer,
00057   public fawkes::LoggerEmployer
00058 {
00059  public:
00060   FawkesMainThread(fawkes::ArgumentParser *argp);
00061   virtual ~FawkesMainThread();
00062 
00063   virtual void once();
00064   virtual void loop();
00065 
00066   virtual void set_mainloop_thread(fawkes::Thread *mainloop_thread);
00067 
00068   virtual void add_logger(fawkes::Logger *logger);
00069   virtual void remove_logger(fawkes::Logger *logger);
00070 
00071  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00072  protected: virtual void run() { Thread::run(); }
00073 
00074  private:
00075   void destruct();
00076 
00077   fawkes::ArgumentParser       *__argp;
00078   fawkes::Configuration        *__config;
00079   fawkes::ConfigNetworkHandler *__config_nethandler;
00080   fawkes::LocalBlackBoard      *__blackboard;
00081   fawkes::MultiLogger          *__multi_logger;
00082   fawkes::NetworkLogger        *__network_logger;
00083   fawkes::Clock                *__clock;
00084   fawkes::TimeWait             *__time_wait;
00085   fawkes::AspectIniFin         *__aspect_inifin;
00086 
00087   fawkes::Thread               *__mainloop_thread;
00088   fawkes::Mutex                *__mainloop_mutex;
00089   fawkes::InterruptibleBarrier *__mainloop_barrier;
00090 
00091   fawkes::SQLiteConfiguration  *__sqlite_conf;
00092   FawkesThreadManager          *__thread_manager;
00093   fawkes::PluginManager        *__plugin_manager;
00094   fawkes::PluginNetworkHandler *__plugin_nethandler;
00095   fawkes::Mutex                *__plugin_mutex;
00096   FawkesNetworkManager         *__network_manager;
00097 
00098   std::list<std::string>        __recovered_threads;
00099   unsigned int                  __desired_loop_time_usec;
00100   float                         __desired_loop_time_sec;
00101   unsigned int                  __max_thread_time_usec;
00102   unsigned int                  __max_thread_time_nanosec;
00103   fawkes::Time                 *__loop_start;
00104   fawkes::Time                 *__loop_end;
00105   bool                          __enable_looptime_warnings;
00106 };
00107 
00108 #endif

Generated on Tue Feb 22 13:31:28 2011 for Fawkes API by  doxygen 1.4.7