Fawkes API  Fawkes Development Version
clips-webview-thread.cpp
1 
2 /***************************************************************************
3  * clips-webview-thread.cpp - CLIPS introspection via webview
4  *
5  * Created: Sat Jun 15 20:01:57 2013
6  * Copyright 2006-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 #include "clips-webview-thread.h"
23 #include "clips-webview-processor.h"
24 
25 #include <webview/url_manager.h>
26 #include <webview/nav_manager.h>
27 
28 using namespace fawkes;
29 
30 #define CLIPS_URL_PREFIX "/clips"
31 
32 /** @class ClipsWebviewThread "clips-webview-thread.h"
33  * Provide introspection for CLIPS via webview.
34  * @author Tim Niemueller
35  */
36 
37 /** Constructor. */
39  : Thread("ClipsWebviewThread", Thread::OPMODE_WAITFORWAKEUP)
40 {
41 }
42 
43 
44 /** Destructor. */
46 {
47 }
48 
49 
50 void
52 {
53  web_proc_ = new ClipsWebRequestProcessor(clips_env_mgr, logger, CLIPS_URL_PREFIX);
54  webview_url_manager->register_baseurl(CLIPS_URL_PREFIX, web_proc_);
55  webview_nav_manager->add_nav_entry(CLIPS_URL_PREFIX, "CLIPS");
56 }
57 
58 
59 void
61 {
62  webview_url_manager->unregister_baseurl(CLIPS_URL_PREFIX);
63  webview_nav_manager->remove_nav_entry(CLIPS_URL_PREFIX);
64  delete web_proc_;
65 }
66 
67 
68 void
70 {
71 }
WebNavManager * webview_nav_manager
Webview navigation manager.
Definition: webview.h:52
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
WebUrlManager * webview_url_manager
Webview request processor manager.
Definition: webview.h:50
void unregister_baseurl(const char *url_prefix)
Remove a request processor.
Definition: url_manager.cpp:87
virtual void init()
Initialize the thread.
void add_nav_entry(std::string baseurl, std::string name)
Add a navigation entry.
Definition: nav_manager.cpp:61
LockPtr< CLIPSEnvManager > clips_env_mgr
CLIPS environment manager.
Definition: clips_manager.h:45
virtual void finalize()
Finalize the thread.
void remove_nav_entry(std::string baseurl)
Remove a navigation entry.
Definition: nav_manager.cpp:76
ClipsWebviewThread()
Constructor.
void register_baseurl(const char *url_prefix, WebRequestProcessor *processor)
Add a request processor.
Definition: url_manager.cpp:64
Clips web request processor.
virtual ~ClipsWebviewThread()
Destructor.