Fawkes API  Fawkes Development Version
clips_navgraph_thread.h
1 
2 /***************************************************************************
3  * clips_navgraph_thread.h - NavGraph feature for CLIPS
4  *
5  * Created: Wed Oct 09 19:26:41 2013
6  * Copyright 2006-2013 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 #ifndef _PLUGINS_CLIPS_NAVGRAPH_CLIPS_NAVGRAPH_THREAD_H_
24 #define _PLUGINS_CLIPS_NAVGRAPH_CLIPS_NAVGRAPH_THREAD_H_
25 
26 #include <aspect/configurable.h>
27 #include <aspect/logging.h>
28 #include <core/threading/thread.h>
29 #include <navgraph/aspect/navgraph.h>
30 #include <navgraph/navgraph.h>
31 #include <plugins/clips/aspect/clips_feature.h>
32 
33 #include <map>
34 #include <string>
35 #include <vector>
36 
37 namespace fawkes {
38 class NavGraphStaticListEdgeConstraint;
39 }
40 
42  public fawkes::LoggingAspect,
45  public fawkes::CLIPSFeature,
48 {
49 public:
51  virtual ~ClipsNavGraphThread();
52 
53  virtual void init();
54  virtual void loop();
55  virtual void finalize();
56 
57  // for CLIPSFeature
58  virtual void clips_context_init(const std::string & env_name,
60  virtual void clips_context_destroyed(const std::string &env_name);
61 
62  virtual void graph_changed() throw();
63 
64  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
65 protected:
66  virtual void
67  run()
68  {
69  Thread::run();
70  }
71 
72 private:
73  void clips_navgraph_load(fawkes::LockPtr<CLIPS::Environment> &clips);
74  void clips_navgraph_block_edge(std::string env_name, std::string from, std::string to);
75  void clips_navgraph_unblock_edge(std::string env_name, std::string from, std::string to);
76 
77 private:
78  std::map<std::string, fawkes::LockPtr<CLIPS::Environment>> envs_;
79 
81 };
82 
83 #endif
ClipsNavGraphThread
Provide protobuf functionality to CLIPS environment.
Definition: clips_navgraph_thread.h:48
ClipsNavGraphThread::ClipsNavGraphThread
ClipsNavGraphThread()
Constructor.
Definition: clips_navgraph_thread.cpp:38
fawkes::LockPtr< CLIPS::Environment >
ClipsNavGraphThread::init
virtual void init()
Initialize the thread.
Definition: clips_navgraph_thread.cpp:51
ClipsNavGraphThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: clips_navgraph_thread.h:67
ClipsNavGraphThread::finalize
virtual void finalize()
Finalize the thread.
Definition: clips_navgraph_thread.cpp:60
fawkes::NavGraph::ChangeListener
Topological graph change listener.
Definition: navgraph.h:179
ClipsNavGraphThread::loop
virtual void loop()
Code to execute in the thread.
Definition: clips_navgraph_thread.cpp:201
fawkes
Fawkes library namespace.
fawkes::LoggingAspect
Thread aspect to log output.
Definition: logging.h:33
fawkes::NavGraphAspect
Thread aspect to access NavGraph.
Definition: navgraph.h:36
fawkes::CLIPSFeature
CLIPS feature maintainer.
Definition: clips_feature.h:42
ClipsNavGraphThread::clips_context_destroyed
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
Definition: clips_navgraph_thread.cpp:94
ClipsNavGraphThread::graph_changed
virtual void graph_changed()
Function called if the graph has been changed.
Definition: clips_navgraph_thread.cpp:188
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
fawkes::ConfigurableAspect
Thread aspect to access configuration data.
Definition: configurable.h:33
ClipsNavGraphThread::~ClipsNavGraphThread
virtual ~ClipsNavGraphThread()
Destructor.
Definition: clips_navgraph_thread.cpp:46
ClipsNavGraphThread::clips_context_init
virtual void clips_context_init(const std::string &env_name, fawkes::LockPtr< CLIPS::Environment > &clips)
Initialize a CLIPS context to use the provided feature.
Definition: clips_navgraph_thread.cpp:70
fawkes::CLIPSFeatureAspect
Thread aspect to provide a feature to CLIPS environments.
Definition: clips_feature.h:58
fawkes::NavGraphStaticListEdgeConstraint
Constraint that holds a list of edges to block.
Definition: static_list_edge_constraint.h:35