[Fawkes Git] branch/bschaepers/asp-aspect: 5 revs updated. (0.5.0-3374-g56eb16f)

Bjoern Schaepers bjoern.schaepers at rwth-aachen.de
Mon Oct 31 16:28:12 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, bschaepers/asp-aspect has been updated
        to  56eb16f2a00b20fc1ebfa9dfdf6cad041422b741 (commit)
       via  04a5ca3f12b5d110402b6cbd331a47b3b7b29069 (commit)
       via  e6df00eb58b7a64ae286dc20b6a867c5c28c6273 (commit)
       via  fb56ce34f7a4c8c6fdba5f3752d69bb7d4c59ebc (commit)
       via  70b60407fb70c9e6fbbb5b0a7ba2a679e590be4f (commit)
      from  10dd8ee45c19379b016a50499e7683cdb0590fde (commit)

http://git.fawkesrobotics.org/fawkes.git/bschaepers/asp-aspect

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 70b60407fb70c9e6fbbb5b0a7ba2a679e590be4f
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Thu Oct 27 16:57:30 2016 +0200
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Thu Oct 27 16:57:30 2016 +0200

    ASP-Aspect: Added ClingoControlManager
    
    Similar to CLIPSEnvManager.
    Not yet used by the aspects.

http://git.fawkesrobotics.org/fawkes.git/commit/70b6040
http://trac.fawkesrobotics.org/changeset/70b6040

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit fb56ce34f7a4c8c6fdba5f3752d69bb7d4c59ebc
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Sat Oct 29 11:50:46 2016 +0200
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sat Oct 29 11:50:46 2016 +0200

    ASP-Aspect: Added ClingoManagerAspect.
    
    Still not in use.

http://git.fawkesrobotics.org/fawkes.git/commit/fb56ce3
http://trac.fawkesrobotics.org/changeset/fb56ce3

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit e6df00eb58b7a64ae286dc20b6a867c5c28c6273
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Sun Oct 30 13:57:12 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sun Oct 30 13:57:12 2016 +0100

    ASP-Aspect: Prepared aspect and inifin for the control manager.

http://git.fawkesrobotics.org/fawkes.git/commit/e6df00e
http://trac.fawkesrobotics.org/changeset/e6df00e

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 04a5ca3f12b5d110402b6cbd331a47b3b7b29069
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Sun Oct 30 20:52:38 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sun Oct 30 20:52:38 2016 +0100

    ASPAspect: Use the clingo control manager for the aspects.

http://git.fawkesrobotics.org/fawkes.git/commit/04a5ca3
http://trac.fawkesrobotics.org/changeset/04a5ca3

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 56eb16f2a00b20fc1ebfa9dfdf6cad041422b741
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Mon Oct 31 16:26:27 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Mon Oct 31 16:26:27 2016 +0100

    ASP-Aspect: Added access wrapper class.
    
    This way the model symbols are stored next to the clingo control and
    user of the control manager have access to the symbols and not only the
    solver.

http://git.fawkesrobotics.org/fawkes.git/commit/56eb16f
http://trac.fawkesrobotics.org/changeset/56eb16f

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/plugins/asp/Makefile                           |   12 +-
 src/plugins/asp/asp.files                          |    8 +
 src/plugins/asp/asp_thread.cpp                     |   21 +-
 src/plugins/asp/asp_thread.h                       |    8 +-
 src/plugins/asp/aspect/Makefile                    |   10 +-
 src/plugins/asp/aspect/asp.cpp                     |   30 ++-
 src/plugins/asp/aspect/asp.h                       |   17 +-
 src/plugins/asp/aspect/asp_inifin.cpp              |   54 ++--
 src/plugins/asp/aspect/asp_inifin.h                |    8 +-
 src/plugins/asp/aspect/clingo_access.cpp           |  356 ++++++++++++++++++++
 src/plugins/asp/aspect/clingo_access.h             |   82 +++++
 src/plugins/asp/aspect/clingo_control_manager.cpp  |  108 ++++++
 .../{asp_inifin.h => clingo_control_manager.h}     |   32 +-
 .../asp/aspect/clingo_manager.cpp}                 |   44 ++--
 src/plugins/asp/aspect/{asp.h => clingo_manager.h} |   29 +-
 src/plugins/asp/aspect/clingo_manager_inifin.cpp   |   91 +++++
 .../{asp_inifin.h => clingo_manager_inifin.h}      |   22 +-
 17 files changed, 800 insertions(+), 132 deletions(-)
 create mode 100644 src/plugins/asp/aspect/clingo_access.cpp
 create mode 100644 src/plugins/asp/aspect/clingo_access.h
 create mode 100644 src/plugins/asp/aspect/clingo_control_manager.cpp
 copy src/plugins/asp/aspect/{asp_inifin.h => clingo_control_manager.h} (59%)
 copy src/{libs/navgraph/aspect/navgraph.cpp => plugins/asp/aspect/clingo_manager.cpp} (57%)
 copy src/plugins/asp/aspect/{asp.h => clingo_manager.h} (70%)
 create mode 100644 src/plugins/asp/aspect/clingo_manager_inifin.cpp
 copy src/plugins/asp/aspect/{asp_inifin.h => clingo_manager_inifin.h} (68%)


- *Diffs* -------------------------------------------------------------

- *commit* 70b60407fb70c9e6fbbb5b0a7ba2a679e590be4f - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Thu Oct 27 16:57:30 2016 +0200
Subject: ASP-Aspect: Added ClingoControlManager

 src/plugins/asp/asp.files                          |    2 +
 src/plugins/asp/aspect/clingo_control_manager.cpp  |  116 ++++++++++++++++++++
 .../asp/aspect/{asp.h => clingo_control_manager.h} |   37 +++---
 3 files changed, 136 insertions(+), 19 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/asp.files b/src/plugins/asp/asp.files
index df59585..41a8afd 100644
--- a/src/plugins/asp/asp.files
+++ b/src/plugins/asp/asp.files
@@ -7,5 +7,7 @@ asp_thread.cpp
 aspect/Makefile
 aspect/asp.h
 aspect/asp.cpp
+aspect/clingo_control_manager.h
+aspect/clingo_control_manager.cpp
 aspect/asp_inifin.h
 aspect/asp_inifin.cpp

- *commit* fb56ce34f7a4c8c6fdba5f3752d69bb7d4c59ebc - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Sat Oct 29 11:50:46 2016 +0200
Subject: ASP-Aspect: Added ClingoManagerAspect.

 src/plugins/asp/asp.files                          |    8 ++-
 .../asp/aspect/clingo_manager.cpp}                 |   44 +++++-----
 src/plugins/asp/aspect/{asp.h => clingo_manager.h} |   29 ++----
 src/plugins/asp/aspect/clingo_manager_inifin.cpp   |   91 ++++++++++++++++++++
 .../{asp_inifin.h => clingo_manager_inifin.h}      |   22 +++---
 5 files changed, 138 insertions(+), 56 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/asp.files b/src/plugins/asp/asp.files
index 41a8afd..3c8dad7 100644
--- a/src/plugins/asp/asp.files
+++ b/src/plugins/asp/asp.files
@@ -7,7 +7,11 @@ asp_thread.cpp
 aspect/Makefile
 aspect/asp.h
 aspect/asp.cpp
-aspect/clingo_control_manager.h
-aspect/clingo_control_manager.cpp
 aspect/asp_inifin.h
 aspect/asp_inifin.cpp
+aspect/clingo_control_manager.h
+aspect/clingo_control_manager.cpp
+aspect/clingo_manager.h
+aspect/clingo_manager.cpp
+aspect/clingo_manager_inifin.h
+aspect/clingo_manager_inifin.cpp

- *commit* e6df00eb58b7a64ae286dc20b6a867c5c28c6273 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Sun Oct 30 13:57:12 2016 +0100
Subject: ASP-Aspect: Prepared aspect and inifin for the control manager.

 src/plugins/asp/aspect/asp.cpp        |   13 ++++++++---
 src/plugins/asp/aspect/asp.h          |    4 ++-
 src/plugins/asp/aspect/asp_inifin.cpp |   34 +++++++++++++++++++++++++++++---
 src/plugins/asp/aspect/asp_inifin.h   |    6 +++++
 4 files changed, 48 insertions(+), 9 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/asp.cpp b/src/plugins/asp/aspect/asp.cpp
index 3163f22..7650e4a 100644
--- a/src/plugins/asp/aspect/asp.cpp
+++ b/src/plugins/asp/aspect/asp.cpp
@@ -36,14 +36,19 @@ namespace fawkes {
  * @ingroup Aspects
  * @author Björn Schäpers
  *
- * @property fawkes:LockPtr<Clingo::Control> ASPAspect::ClingoControl
- * Clingo Control for exclusive usage.
+ * @property ASPAspect::ControlName
+ * @brief The name for the control in the manager.
+ *
+ * @property ASPAspect::ClingoControl
+ * @brief Clingo Control for exclusive usage.
  */
 
 
-/** Constructor.
+/**
+ * Constructor.
+ * @param[in] controlName The desired control name.
  */
-ASPAspect::ASPAspect(void)
+ASPAspect::ASPAspect(const std::string&& controlName) : ControlName(std::move(controlName))
 {
 	add_aspect("ASPAspect");
 	return;
diff --git a/src/plugins/asp/aspect/asp.h b/src/plugins/asp/aspect/asp.h
index e356fa7..72782e0 100644
--- a/src/plugins/asp/aspect/asp.h
+++ b/src/plugins/asp/aspect/asp.h
@@ -41,6 +41,8 @@ namespace fawkes {
 class ASPAspect : public virtual Aspect
 {
 	private:
+	const std::string ControlName;
+
 	void init_ASPAspect(LockPtr<Clingo::Control> clingoControl);
 	void finalize_ASPAspect();
 
@@ -48,7 +50,7 @@ class ASPAspect : public virtual Aspect
 	LockPtr<Clingo::Control> ClingoControl;
 
 	public:
-	ASPAspect(void);
+	ASPAspect(const std::string&& controlName);
 	virtual ~ASPAspect(void);
 
 	friend class ASPAspectIniFin;
diff --git a/src/plugins/asp/aspect/asp_inifin.cpp b/src/plugins/asp/aspect/asp_inifin.cpp
index 2a39bf7..c6f1887 100644
--- a/src/plugins/asp/aspect/asp_inifin.cpp
+++ b/src/plugins/asp/aspect/asp_inifin.cpp
@@ -21,33 +21,48 @@
  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
  */
 
-#include "asp.h"
-#include "asp_inifin.h"
 #include <clingo.hh>
 #include <core/threading/thread_finalizer.h>
 #include <logging/logger.h>
 
+#include "asp.h"
+#include "asp_inifin.h"
+#include "clingo_control_manager.h"
+
 namespace fawkes {
 #if 0 /* just to make Emacs auto-indent happy */
 }
 #endif
 
-/** @class ASPAspectIniFin <plugins/asp/aspect/asp_inifin.h>
+/**
+ * @class ASPAspectIniFin <plugins/asp/aspect/asp_inifin.h>
  * ASPAspect initializer/finalizer.
  * This initializer/finalizer will provide the ASP node handle to threads with the ASPAspect.
  * @author Björn Schäpers
  *
  * @property ASPAspectIniFin::Log
  * @brief The logger used for Clingo Output.
+ *
+ * @property ASPAspectIniFin::CtrlMgr
+ * @brief The control manager.
  */
 
-/** Constructor.
+/**
+ * Constructor.
  */
 ASPAspectIniFin::ASPAspectIniFin(void) : AspectIniFin("ASPAspect"), Log(nullptr)
 {
 	return;
 }
 
+/**
+ * @brief Destructor.
+ */
+ASPAspectIniFin::~ASPAspectIniFin(void)
+{
+	return;
+}
+
 void
 ASPAspectIniFin::init(Thread *thread)
 {
@@ -103,4 +118,15 @@ ASPAspectIniFin::setLogger(Logger *logger)
 	return;
 }
 
+/**
+ * @brief Sets the control manager.
+ * @param[in] ctrlMgr The new control manager.
+ */
+void
+ASPAspectIniFin::setControlManager(const LockPtr<ClingoControlManager>& ctrlMgr)
+{
+	CtrlMgr = ctrlMgr;
+	return;
+}
+
 } // end namespace fawkes
diff --git a/src/plugins/asp/aspect/asp_inifin.h b/src/plugins/asp/aspect/asp_inifin.h
index d112084..1563622 100644
--- a/src/plugins/asp/aspect/asp_inifin.h
+++ b/src/plugins/asp/aspect/asp_inifin.h
@@ -25,6 +25,8 @@
 #define __PLUGINS_ASP_ASPECT_ASP_INIFIN_H_
 
 #include <aspect/inifins/inifin.h>
+#include <core/utils/lockptr.h>
+
 #include "asp.h"
 
 namespace fawkes {
@@ -32,20 +34,24 @@ namespace fawkes {
 }
 #endif
 
+class ClingoControlManager;
 class Logger;
 
 class ASPAspectIniFin : public AspectIniFin
 {
 	private:
 	Logger *Log;
+	LockPtr<ClingoControlManager> CtrlMgr;
 
 	public:
 	ASPAspectIniFin(void);
+	~ASPAspectIniFin(void);
 
 	void init(Thread *thread) override;
 	void finalize(Thread *thread) override;
 
 	void setLogger(Logger *logger);
+	void setControlManager(const LockPtr<ClingoControlManager>& ctrlMgr);
 };
 
 } // end namespace fawkes

- *commit* 04a5ca3f12b5d110402b6cbd331a47b3b7b29069 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Sun Oct 30 20:52:38 2016 +0100
Subject: ASPAspect: Use the clingo control manager for the aspects.

 src/plugins/asp/asp_thread.cpp                    |   21 +++++++++++-
 src/plugins/asp/asp_thread.h                      |    8 ++++-
 src/plugins/asp/aspect/asp.cpp                    |    7 ++++-
 src/plugins/asp/aspect/asp.h                      |    3 +-
 src/plugins/asp/aspect/asp_inifin.cpp             |   34 +-------------------
 src/plugins/asp/aspect/asp_inifin.h               |    2 -
 src/plugins/asp/aspect/clingo_control_manager.cpp |   13 +++++++-
 src/plugins/asp/aspect/clingo_control_manager.h   |    4 ++-
 src/plugins/asp/aspect/clingo_manager_inifin.cpp  |    2 +-
 src/plugins/asp/aspect/clingo_manager_inifin.h    |    2 +-
 10 files changed, 51 insertions(+), 45 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/asp_thread.cpp b/src/plugins/asp/asp_thread.cpp
index 99b5805..19da8c3 100644
--- a/src/plugins/asp/asp_thread.cpp
+++ b/src/plugins/asp/asp_thread.cpp
@@ -29,12 +29,27 @@ using namespace fawkes;
  * ASP environment thread.
  *
  * @author Björn Schäpers
+ *
+ * @property ASPThread::ASPIniFin
+ * @brief The initi-/finalizer for the ASPAspect.
+ *
+ * @property ASPThread::ClingoIniFin
+ * @brief The initi-/finalizer for the ClingoManagerAspect.
+ *
+ * @property ASPThread::CtrlMgr
+ * @brief The clingo control manager.
  */
 
 /** Constructor. */
 ASPThread::ASPThread(void)
   : Thread("ASPThread", Thread::OPMODE_WAITFORWAKEUP),
-	AspectProviderAspect(std::list<fawkes::AspectIniFin*>(1, &ASPIniFin))
+	AspectProviderAspect([this](void) {
+		std::list<fawkes::AspectIniFin*> ret;
+		ret.emplace_back(&ASPIniFin);
+		ret.emplace_back(&ClingoIniFin);
+		return ret;
+	}()),
+	CtrlMgr(new ClingoControlManager)
 {
 	return;
 }
@@ -42,7 +57,9 @@ ASPThread::ASPThread(void)
 void
 ASPThread::init(void)
 {
-	ASPIniFin.setLogger(logger);
+	CtrlMgr->setLogger(logger);
+	ASPIniFin.setControlManager(CtrlMgr);
+	ClingoIniFin.setControlManager(CtrlMgr);
 	return;
 }
 
diff --git a/src/plugins/asp/asp_thread.h b/src/plugins/asp/asp_thread.h
index 92ac825..68bee30 100644
--- a/src/plugins/asp/asp_thread.h
+++ b/src/plugins/asp/asp_thread.h
@@ -24,10 +24,13 @@
 #define __PLUGINS_ASP_ASP_THREAD_H_
 
 #include <aspect/aspect_provider.h>
-#include "aspect/asp_inifin.h"
 #include <aspect/logging.h>
 #include <core/threading/thread.h>
 
+#include "aspect/asp_inifin.h"
+#include "aspect/clingo_control_manager.h"
+#include "aspect/clingo_manager_inifin.h"
+
 namespace fawkes {
 	class AspectIniFin;
 }
@@ -39,6 +42,8 @@ class ASPThread
 {
 	private:
 	fawkes::ASPAspectIniFin ASPIniFin;
+	fawkes::ClingoManagerAspectIniFin ClingoIniFin;
+	fawkes::LockPtr<fawkes::ClingoControlManager> CtrlMgr;
 
 	protected:
 	/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
@@ -50,7 +55,6 @@ class ASPThread
 	void init(void) override;
 	void loop(void) override;
 	void finalize(void) override;
-
 };
 
 #endif
diff --git a/src/plugins/asp/aspect/asp.cpp b/src/plugins/asp/aspect/asp.cpp
index 7650e4a..fcd57c8 100644
--- a/src/plugins/asp/aspect/asp.cpp
+++ b/src/plugins/asp/aspect/asp.cpp
@@ -39,6 +39,9 @@ namespace fawkes {
  * @property ASPAspect::ControlName
  * @brief The name for the control in the manager.
  *
+ * @property ASPAspect::LogComponent
+ * @brief The component for the logger.
+ *
  * @property ASPAspect::ClingoControl
  * @brief Clingo Control for exclusive usage.
  */
@@ -47,8 +50,10 @@ namespace fawkes {
 /**
  * Constructor.
  * @param[in] controlName The desired control name.
+ * @param[in] logComponent The component for the logger.
  */
-ASPAspect::ASPAspect(const std::string&& controlName) : ControlName(std::move(controlName))
+ASPAspect::ASPAspect(const std::string&& controlName, const std::string&& logComponent) :
+	ControlName(std::move(controlName)), LogComponent(std::move(logComponent))
 {
 	add_aspect("ASPAspect");
 	return;
diff --git a/src/plugins/asp/aspect/asp.h b/src/plugins/asp/aspect/asp.h
index 72782e0..b86b869 100644
--- a/src/plugins/asp/aspect/asp.h
+++ b/src/plugins/asp/aspect/asp.h
@@ -42,6 +42,7 @@ class ASPAspect : public virtual Aspect
 {
 	private:
 	const std::string ControlName;
+	const std::string LogComponent;
 
 	void init_ASPAspect(LockPtr<Clingo::Control> clingoControl);
 	void finalize_ASPAspect();
@@ -50,7 +51,7 @@ class ASPAspect : public virtual Aspect
 	LockPtr<Clingo::Control> ClingoControl;
 
 	public:
-	ASPAspect(const std::string&& controlName);
+	ASPAspect(const std::string&& controlName, const std::string&& logComponent = std::string());
 	virtual ~ASPAspect(void);
 
 	friend class ASPAspectIniFin;
diff --git a/src/plugins/asp/aspect/asp_inifin.cpp b/src/plugins/asp/aspect/asp_inifin.cpp
index c6f1887..ecd27eb 100644
--- a/src/plugins/asp/aspect/asp_inifin.cpp
+++ b/src/plugins/asp/aspect/asp_inifin.cpp
@@ -40,9 +40,6 @@ namespace fawkes {
  * This initializer/finalizer will provide the ASP node handle to threads with the ASPAspect.
  * @author Björn Schäpers
  *
- * @property ASPAspectIniFin::Log
- * @brief The logger used for Clingo Output.
- *
  * @property ASPAspectIniFin::CtrlMgr
  * @brief The control manager.
  */
@@ -50,7 +47,7 @@ namespace fawkes {
 /**
  * Constructor.
  */
-ASPAspectIniFin::ASPAspectIniFin(void) : AspectIniFin("ASPAspect"), Log(nullptr)
+ASPAspectIniFin::ASPAspectIniFin(void) : AspectIniFin("ASPAspect")
 {
 	return;
 }
@@ -73,23 +70,7 @@ ASPAspectIniFin::init(Thread *thread)
 		thread->name());
 	} //if ( asp_thread == nullptr )
 
-	auto clingoLogger = [this](const Clingo::WarningCode code, char const *msg)
-		{
-			fawkes::Logger::LogLevel level = fawkes::Logger::LL_NONE;
-			switch ( code )
-			{
-				case Clingo::WarningCode::AtomUndefined      :
-				case Clingo::WarningCode::OperationUndefined :
-				case Clingo::WarningCode::RuntimeError       : level = fawkes::Logger::LL_ERROR; break;
-				case Clingo::WarningCode::Other              :
-				case Clingo::WarningCode::VariableUnbounded  : level = fawkes::Logger::LL_WARN;
-				case Clingo::WarningCode::FileIncluded       :
-				case Clingo::WarningCode::GlobalVariable     : level = fawkes::Logger::LL_INFO; break;
-			} //switch ( code )
-			Log->log(level, "Clingo", msg);
-			return;
-		};
-	asp_thread->init_ASPAspect(LockPtr<Clingo::Control>(new Clingo::Control({}, clingoLogger, 100)));
+	asp_thread->init_ASPAspect(CtrlMgr->create_control(asp_thread->ControlName, asp_thread->LogComponent));
 	return;
 }
 
@@ -108,17 +89,6 @@ ASPAspectIniFin::finalize(Thread *thread)
 }
 
 /**
- * @brief Sets the logger to use for Clingo messages.
- * @param[in] logger The new logger.
- */
-void
-ASPAspectIniFin::setLogger(Logger *logger)
-{
-	Log = logger;
-	return;
-}
-
-/**
  * @brief Sets the control manager.
  * @param[in] ctrlMgr The new control manager.
  */
diff --git a/src/plugins/asp/aspect/asp_inifin.h b/src/plugins/asp/aspect/asp_inifin.h
index 1563622..141ffb9 100644
--- a/src/plugins/asp/aspect/asp_inifin.h
+++ b/src/plugins/asp/aspect/asp_inifin.h
@@ -40,7 +40,6 @@ class Logger;
 class ASPAspectIniFin : public AspectIniFin
 {
 	private:
-	Logger *Log;
 	LockPtr<ClingoControlManager> CtrlMgr;
 
 	public:
@@ -50,7 +49,6 @@ class ASPAspectIniFin : public AspectIniFin
 	void init(Thread *thread) override;
 	void finalize(Thread *thread) override;
 
-	void setLogger(Logger *logger);
 	void setControlManager(const LockPtr<ClingoControlManager>& ctrlMgr);
 };
 
diff --git a/src/plugins/asp/aspect/clingo_control_manager.cpp b/src/plugins/asp/aspect/clingo_control_manager.cpp
index b508ef7..6019d76 100644
--- a/src/plugins/asp/aspect/clingo_control_manager.cpp
+++ b/src/plugins/asp/aspect/clingo_control_manager.cpp
@@ -39,9 +39,8 @@ namespace fawkes {
 
 /**
  * Constructor.
- * @param[in] logger The logger for the controls.
  */
-ClingoControlManager::ClingoControlManager(Logger *logger) : Log(logger)
+ClingoControlManager::ClingoControlManager(void) : Log(nullptr)
 {
 	return;
 }
@@ -53,6 +52,16 @@ ClingoControlManager::~ClingoControlManager(void)
 }
 
 /**
+ * @brief Sets the logger for all Clingo Controls.
+ * @param[in] logger The logger.
+ */
+void ClingoControlManager::setLogger(Logger *logger)
+{
+	Log = logger;
+	return;
+}
+
+/**
  * Create a new control. The control is registered internally under the specified name.
  * It must be destroyed when done with it. Only a single control can be created for a particular control name.
  * @param[in] ctrl_name The Name by which to register the control.
diff --git a/src/plugins/asp/aspect/clingo_control_manager.h b/src/plugins/asp/aspect/clingo_control_manager.h
index 41a5406..be16d12 100644
--- a/src/plugins/asp/aspect/clingo_control_manager.h
+++ b/src/plugins/asp/aspect/clingo_control_manager.h
@@ -44,9 +44,11 @@ class ClingoControlManager
 	std::unordered_map<std::string, LockPtr<Clingo::Control>> Controls;
 
 	public:
-	ClingoControlManager(Logger *logger);
+	ClingoControlManager(void);
 	virtual ~ClingoControlManager(void);
 
+	void setLogger(Logger *logger);
+
 	LockPtr<Clingo::Control> create_control(const std::string& ctrl_name, const std::string& log_component_name);
 	void destroy_control(const std::string& ctrl_name);
 
diff --git a/src/plugins/asp/aspect/clingo_manager_inifin.cpp b/src/plugins/asp/aspect/clingo_manager_inifin.cpp
index 6478dd7..391167c 100644
--- a/src/plugins/asp/aspect/clingo_manager_inifin.cpp
+++ b/src/plugins/asp/aspect/clingo_manager_inifin.cpp
@@ -82,7 +82,7 @@ ClingoManagerAspectIniFin::finalize(Thread *thread)
  * @param[in] clingoCtrlMgr Clingo control manager
  */
 void
-ClingoManagerAspectIniFin::set_manager(LockPtr<ClingoControlManager>& clingoCtrlMgr)
+ClingoManagerAspectIniFin::setControlManager(LockPtr<ClingoControlManager>& clingoCtrlMgr)
 {
 	ClingoCtrlMgr = clingoCtrlMgr;
 	return;
diff --git a/src/plugins/asp/aspect/clingo_manager_inifin.h b/src/plugins/asp/aspect/clingo_manager_inifin.h
index a33cc52..a142d88 100644
--- a/src/plugins/asp/aspect/clingo_manager_inifin.h
+++ b/src/plugins/asp/aspect/clingo_manager_inifin.h
@@ -45,7 +45,7 @@ class ClingoManagerAspectIniFin : public AspectIniFin
 	void init(Thread *thread) override;
 	void finalize(Thread *thread) override;
 
-	void set_manager(LockPtr<ClingoControlManager>& clingoCtrlMgr);
+	void setControlManager(LockPtr<ClingoControlManager>& clingoCtrlMgr);
 };
 
 } // end namespace fawkes

- *commit* 56eb16f2a00b20fc1ebfa9dfdf6cad041422b741 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Mon Oct 31 16:26:27 2016 +0100
Subject: ASP-Aspect: Added access wrapper class.

 src/plugins/asp/Makefile                          |   12 +-
 src/plugins/asp/asp.files                         |    2 +
 src/plugins/asp/aspect/Makefile                   |   10 +-
 src/plugins/asp/aspect/asp.cpp                    |   12 +-
 src/plugins/asp/aspect/asp.h                      |   12 +-
 src/plugins/asp/aspect/asp_inifin.cpp             |    2 +-
 src/plugins/asp/aspect/clingo_access.cpp          |  356 +++++++++++++++++++++
 src/plugins/asp/aspect/clingo_access.h            |   82 +++++
 src/plugins/asp/aspect/clingo_control_manager.cpp |   29 +--
 src/plugins/asp/aspect/clingo_control_manager.h   |   11 +-
 10 files changed, 473 insertions(+), 55 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/Makefile b/src/plugins/asp/Makefile
index d1b8a48..9df80ff 100644
--- a/src/plugins/asp/Makefile
+++ b/src/plugins/asp/Makefile
@@ -41,14 +41,14 @@ ifeq ($(HAVE_CPP11),1)
   ifeq ($(HAVE_CLINGO),1)
     PRESUBDIRS += aspect
 
-	CFLAGS  += $(CFLAGS_CLINGO) $(CFLAGS_CPP11)
-	LDFLAGS += $(LDFLAGS_CLINGO) $(LDFLAGS_CPP11)
+    CFLAGS  += $(CFLAGS_CLINGO) $(CFLAGS_CPP11)
+    LDFLAGS += $(LDFLAGS_CLINGO) $(LDFLAGS_CPP11)
 
-	PLUGINS_all = $(PLUGINDIR)/asp.so
+    PLUGINS_all = $(PLUGINDIR)/asp.so
 
-	INSTALL_extra = asp_files
-else
-	WARN_TARGETS += warning_clingo
+    INSTALL_extra = asp_files
+  else
+    WARN_TARGETS += warning_clingo
   endif
 else
   WARN_TARGETS += warning_cpp11
diff --git a/src/plugins/asp/asp.files b/src/plugins/asp/asp.files
index 3c8dad7..3ed9f3c 100644
--- a/src/plugins/asp/asp.files
+++ b/src/plugins/asp/asp.files
@@ -9,6 +9,8 @@ aspect/asp.h
 aspect/asp.cpp
 aspect/asp_inifin.h
 aspect/asp_inifin.cpp
+aspect/clingo_access.h
+aspect/clingo_access.cpp
 aspect/clingo_control_manager.h
 aspect/clingo_control_manager.cpp
 aspect/clingo_manager.h
diff --git a/src/plugins/asp/aspect/Makefile b/src/plugins/asp/aspect/Makefile
index 5c66c4e..9a43079 100644
--- a/src/plugins/asp/aspect/Makefile
+++ b/src/plugins/asp/aspect/Makefile
@@ -36,12 +36,12 @@ LDFLAGS_CLINGO = -L$(HOME)/clingo/build/debug/ -Wl,-rpath=$(HOME)/clingo/build/d
 
 ifeq ($(HAVE_CPP11),1)
   ifeq ($(HAVE_CLINGO),1)
-	CFLAGS  += $(CFLAGS_CLINGO) $(CFLAGS_CPP11)
-	LDFLAGS += $(LDFLAGS_CLINGO) $(LDFLAGS_CPP11)
+    CFLAGS  += $(CFLAGS_CLINGO) $(CFLAGS_CPP11)
+    LDFLAGS += $(LDFLAGS_CLINGO) $(LDFLAGS_CPP11)
 
-	LIBS_all = $(LIBDIR)/libfawkesaspaspect.so
-else
-	WARN_TARGETS += warning_clingo
+    LIBS_all = $(LIBDIR)/libfawkesaspaspect.so
+  else
+    WARN_TARGETS += warning_clingo
   endif
 else
   WARN_TARGETS += warning_cpp11
diff --git a/src/plugins/asp/aspect/asp.cpp b/src/plugins/asp/aspect/asp.cpp
index fcd57c8..5aee875 100644
--- a/src/plugins/asp/aspect/asp.cpp
+++ b/src/plugins/asp/aspect/asp.cpp
@@ -22,7 +22,7 @@
  */
 
 #include "asp.h"
-#include <clingo.hh>
+#include "clingo_access.h"
 
 namespace fawkes {
 #if 0 /* just to make Emacs auto-indent happy */
@@ -69,12 +69,12 @@ ASPAspect::~ASPAspect(void)
 /** Init ASP aspect.
  * This sets the Clingo Control.
  * It is guaranteed that this is called for an ASP Thread before start is called (when running regularly inside Fawkes).
- * @param control The Clingo Control
+ * @param[in] clingo The Clingo Control.
  */
 void
-ASPAspect::init_ASPAspect(LockPtr<Clingo::Control> control)
+ASPAspect::init_ASPAspect(const LockPtr<ClingoAccess>& clingo)
 {
-	ClingoControl = control;
+	Clingo = clingo;
 	return;
 }
 
@@ -82,9 +82,9 @@ ASPAspect::init_ASPAspect(LockPtr<Clingo::Control> control)
  * This clears the Clingo Control.
  */
 void
-ASPAspect::finalize_ASPAspect()
+ASPAspect::finalize_ASPAspect(void)
 {
-	ClingoControl.clear();
+	Clingo.clear();
 	return;
 }
 
diff --git a/src/plugins/asp/aspect/asp.h b/src/plugins/asp/aspect/asp.h
index b86b869..e749f8a 100644
--- a/src/plugins/asp/aspect/asp.h
+++ b/src/plugins/asp/aspect/asp.h
@@ -29,26 +29,24 @@
 
 #include <string>
 
-namespace Clingo {
-  class Control;
-}
-
 namespace fawkes {
 #if 0 /* just to make Emacs auto-indent happy */
 }
 #endif
 
+class ClingoAccess;
+
 class ASPAspect : public virtual Aspect
 {
 	private:
 	const std::string ControlName;
 	const std::string LogComponent;
 
-	void init_ASPAspect(LockPtr<Clingo::Control> clingoControl);
-	void finalize_ASPAspect();
+	void init_ASPAspect(const LockPtr<ClingoAccess>& clingo);
+	void finalize_ASPAspect(void);
 
 	protected:
-	LockPtr<Clingo::Control> ClingoControl;
+	LockPtr<ClingoAccess> Clingo;
 
 	public:
 	ASPAspect(const std::string&& controlName, const std::string&& logComponent = std::string());
diff --git a/src/plugins/asp/aspect/asp_inifin.cpp b/src/plugins/asp/aspect/asp_inifin.cpp
index ecd27eb..a4f48d7 100644
--- a/src/plugins/asp/aspect/asp_inifin.cpp
+++ b/src/plugins/asp/aspect/asp_inifin.cpp
@@ -21,12 +21,12 @@
  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
  */
 
-#include <clingo.hh>
 #include <core/threading/thread_finalizer.h>
 #include <logging/logger.h>
 
 #include "asp.h"
 #include "asp_inifin.h"
+#include "clingo_access.h"
 #include "clingo_control_manager.h"
 
 namespace fawkes {
diff --git a/src/plugins/asp/aspect/clingo_control_manager.cpp b/src/plugins/asp/aspect/clingo_control_manager.cpp
index 6019d76..865c872 100644
--- a/src/plugins/asp/aspect/clingo_control_manager.cpp
+++ b/src/plugins/asp/aspect/clingo_control_manager.cpp
@@ -19,13 +19,12 @@
  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
  */
 
+#include "clingo_access.h"
 #include "clingo_control_manager.h"
 
 #include <core/exception.h>
 #include <logging/logger.h>
 
-#include <clingo.hh>
-
 namespace fawkes {
 #if 0 /* just to make Emacs auto-indent happy */
 }
@@ -68,31 +67,16 @@ void ClingoControlManager::setLogger(Logger *logger)
  * @param[in] log_component_name The Prefix for log entries. If empty it will be set to "Clingo".
  * @return A new plain Clingo Control.
  */
-LockPtr<Clingo::Control>
-ClingoControlManager::create_control(const std::string& ctrl_name, const std::string& log_component_name)
+LockPtr<ClingoAccess> ClingoControlManager::create_control(const std::string& ctrl_name,
+		const std::string& log_component_name)
 {
 	if ( Controls.count(ctrl_name) != 0 )
 	{
 		throw Exception("Clingo Control '%s' already exists!", ctrl_name.c_str());
 	} //if ( Controls.count(ctrl_name) != 0 )
 
-	auto clingoLogger = [this,log_component_name](const Clingo::WarningCode code, char const *msg)
-		{
-			fawkes::Logger::LogLevel level = fawkes::Logger::LL_NONE;
-			switch ( code )
-			{
-				case Clingo::WarningCode::AtomUndefined      :
-				case Clingo::WarningCode::OperationUndefined :
-				case Clingo::WarningCode::RuntimeError       : level = fawkes::Logger::LL_ERROR; break;
-				case Clingo::WarningCode::Other              :
-				case Clingo::WarningCode::VariableUnbounded  : level = fawkes::Logger::LL_WARN;
-				case Clingo::WarningCode::FileIncluded       :
-				case Clingo::WarningCode::GlobalVariable     : level = fawkes::Logger::LL_INFO; break;
-			} //switch ( code )
-			Log->log(level, log_component_name.empty() ? "Clingo" : log_component_name.c_str(), msg);
-			return;
-		};
-	LockPtr<Clingo::Control> ctrl(new Clingo::Control({}, clingoLogger, 100));
+	Clingo::SymbolSpan s;
+	LockPtr<ClingoAccess> ctrl(new ClingoAccess(Log, log_component_name));
 
 	Controls.emplace(ctrl_name, ctrl);
 
@@ -111,12 +95,11 @@ ClingoControlManager::destroy_control(const std::string& ctrl_name)
 	return;
 }
 
-
 /**
  * Get map of controls.
  * @return The map from control name to control lock ptr.
  */
-const std::unordered_map<std::string, LockPtr<Clingo::Control>>&
+const std::unordered_map<std::string, LockPtr<ClingoAccess>>&
 ClingoControlManager::controls(void) const
 {
 	return Controls;
diff --git a/src/plugins/asp/aspect/clingo_control_manager.h b/src/plugins/asp/aspect/clingo_control_manager.h
index be16d12..fdc7cf4 100644
--- a/src/plugins/asp/aspect/clingo_control_manager.h
+++ b/src/plugins/asp/aspect/clingo_control_manager.h
@@ -26,22 +26,19 @@
 
 #include <unordered_map>
 
-namespace Clingo {
-	class Control;
-}
-
 namespace fawkes {
 #if 0 /* just to make Emacs auto-indent happy */
 }
 #endif
 
+class ClingoAccess;
 class Logger;
 
 class ClingoControlManager
 {
 	private:
 	Logger *Log;
-	std::unordered_map<std::string, LockPtr<Clingo::Control>> Controls;
+	std::unordered_map<std::string, LockPtr<ClingoAccess>> Controls;
 
 	public:
 	ClingoControlManager(void);
@@ -49,10 +46,10 @@ class ClingoControlManager
 
 	void setLogger(Logger *logger);
 
-	LockPtr<Clingo::Control> create_control(const std::string& ctrl_name, const std::string& log_component_name);
+	LockPtr<ClingoAccess> create_control(const std::string& ctrl_name, const std::string& log_component_name);
 	void destroy_control(const std::string& ctrl_name);
 
-	const std::unordered_map<std::string, LockPtr<Clingo::Control>>& controls(void) const;
+	const std::unordered_map<std::string, LockPtr<ClingoAccess>>& controls(void) const;
 };
 
 } // end namespace fawkes




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list