Fawkes API  Fawkes Development Version
rrdweb_thread.cpp
1 
2 /***************************************************************************
3  * rrdweb_thread.cpp - RRD Webview Thread
4  *
5  * Created: Tue Dec 21 01:05:45 2010
6  * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include "rrdweb_thread.h"
24 #include "rrdweb_processor.h"
25 
26 #include <webview/url_manager.h>
27 #include <webview/nav_manager.h>
28 
29 using namespace fawkes;
30 
31 #define RRD_URL_PREFIX "/rrd"
32 
33 /** @class RRDWebThread "rrd_thread.h"
34  * RRD Webview Thread.
35  * This thread queries RRD graphs from RRDManager obtained via RRDAspect
36  * and displays them on a Webview page.
37  *
38  * @author Tim Niemueller
39  */
40 
41 /** Constructor. */
43  : Thread("RRDWebThread", Thread::OPMODE_WAITFORWAKEUP)
44 {
45 }
46 
47 
48 /** Destructor. */
50 {
51 }
52 
53 
54 void
56 {
57  __processor = new RRDWebRequestProcessor(rrd_manager, logger, RRD_URL_PREFIX);
58  webview_url_manager->register_baseurl(RRD_URL_PREFIX, __processor);
59  webview_nav_manager->add_nav_entry(RRD_URL_PREFIX, "RRD Graphs");
60 }
61 
62 
63 void
65 {
66  webview_url_manager->unregister_baseurl(RRD_URL_PREFIX);
67  webview_nav_manager->remove_nav_entry(RRD_URL_PREFIX);
68  delete __processor;
69 }
70 
71 
72 void
74 {
75 }
76 
WebNavManager * webview_nav_manager
Webview navigation manager.
Definition: webview.h:52
virtual void finalize()
Finalize the thread.
RRDManager * rrd_manager
Manager class to access RRD features.
Definition: rrd.h:45
virtual void loop()
Code to execute in the thread.
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:44
RRDWebThread()
Constructor.
WebUrlManager * webview_url_manager
Webview request processor manager.
Definition: webview.h:50
virtual void init()
Initialize the thread.
void unregister_baseurl(const char *url_prefix)
Remove a request processor.
Definition: url_manager.cpp:87
virtual ~RRDWebThread()
Destructor.
void add_nav_entry(std::string baseurl, std::string name)
Add a navigation entry.
Definition: nav_manager.cpp:61
RRD web request processor.
void remove_nav_entry(std::string baseurl)
Remove a navigation entry.
Definition: nav_manager.cpp:76
void register_baseurl(const char *url_prefix, WebRequestProcessor *processor)
Add a request processor.
Definition: url_manager.cpp:64