diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 8b08f3be..fc81a5ce 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -2,10 +2,10 @@ name: CMake
on:
workflow_dispatch:
- #push:
- # branches: [ "master" ]
- #pull_request:
- # branches: [ "master" ]
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
@@ -26,6 +26,9 @@ jobs:
- name: install-deps
run: sudo apt install libboost-all-dev wget
+
+ - name: update submodules
+ run: git submodule update --force --init --checkout
- name: install eclipse-clp
run: |
@@ -43,8 +46,8 @@ jobs:
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_READYLOG_SEMANTICS=TRUE \
- -DBUILD_PARSER=FALSE \
- -DBUILD_TESTING=FALSE \
+ -DBUILD_PARSER=TRUE \
+ -DBUILD_TESTING=TRUE \
- name: Build
# Build your program with the given configuration
@@ -54,5 +57,6 @@ jobs:
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
- run: ctest -C ${{env.BUILD_TYPE}}
+ run: ctest -C ${{env.BUILD_TYPE}} -VV
+ timeout-minutes: 10
diff --git a/.gitmodules b/.gitmodules
index 2ba5fa68..0236b55a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
[submodule "external/taptenc"]
path = external/taptenc
- url = git@github.com:TarikViehmann/taptenc.git
-[submodule "src/semantics/readylog/interpreter"]
- path = src/semantics/readylog/interpreter
+ url = https://github.com/TarikViehmann/taptenc.git
+[submodule "src/semantics/readylog/readylog_ecl"]
+ path = src/semantics/readylog/readylog_ecl
url = https://github.com/MASKOR/readylog.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80148c08..da57e0f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,8 +15,8 @@
# along with golog++. If not, see .
###########################################################################
-project(golog++)
cmake_minimum_required(VERSION 3.0)
+project(golog++)
include(CMakeDependentOption)
include(GNUInstallDirs)
@@ -72,7 +72,8 @@ set(SEMANTICS_INSTALL_DIR ${CMAKE_INSTALL_DATAROOTDIR}/golog++/semantics)
set(GOLOGPP_VERSION 0.1.0)
-
+file(GLOB_RECURSE GOLOGPP_HEADERS "src/*.h")
+add_custom_target(headers SOURCES ${GOLOGPP_HEADERS})
######################################################################################
# The golog++ language metamodel: libgolog++.so
@@ -100,8 +101,8 @@ set(INTERFACE_SRC
src/model/mapping.cpp
src/model/language.cpp
src/model/types.cpp
- src/model/compound_expression.cpp
- src/model/list_expression.cpp
+ src/model/compound.cpp
+ src/model/list.cpp
src/model/semantics.cpp
src/model/logger.cpp
src/model/name.cpp
@@ -115,6 +116,7 @@ set(INTERFACE_SRC
src/execution/plan.cpp
src/execution/platform_backend.cpp
src/execution/transformation.cpp
+ src/execution/event.cpp
src/model/platform/component.cpp
src/model/platform/constraint.cpp
@@ -155,8 +157,8 @@ install(FILES
src/model/string.h
src/model/mapping.h
src/model/types.h
- src/model/compound_expression.h
- src/model/list_expression.h
+ src/model/compound.h
+ src/model/list.h
src/model/logger.h
src/model/name.h
@@ -173,6 +175,7 @@ install(FILES
src/execution/plan.h
src/execution/platform_backend.h
src/execution/transformation.h
+ src/execution/event.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/golog++/execution
)
@@ -225,10 +228,10 @@ if (${BUILD_PARSER})
src/parser/symbolic_expression.cpp
src/parser/string_expression.cpp
src/parser/domain.cpp
- src/parser/compound_expression.cpp
+ src/parser/compound.cpp
src/parser/mixed_member_access.cpp
src/parser/mapping.cpp
- src/parser/list_expression.cpp
+ src/parser/list.cpp
src/parser/value.cpp
src/parser/platform/clock_formula.cpp
@@ -262,10 +265,10 @@ if (${BUILD_PARSER})
src/parser/expressions.h
src/parser/symbolic_expression.h
src/parser/domain.h
- src/parser/compound_expression.h
+ src/parser/compound.h
src/parser/mixed_member_access.h
src/parser/mapping.h
- src/parser/list_expression.h
+ src/parser/list.h
src/parser/value.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/golog++/parser
)
@@ -313,10 +316,9 @@ if (${BUILD_READYLOG_SEMANTICS})
src/semantics/readylog/history.cpp
src/semantics/readylog/reference.cpp
src/semantics/readylog/effect_axiom.cpp
- src/semantics/readylog/compound_expression.cpp
- src/semantics/readylog/list_expression.cpp
+ src/semantics/readylog/compound.cpp
+ src/semantics/readylog/list.cpp
src/semantics/readylog/transition.cpp
- src/semantics/readylog/activity.cpp
src/semantics/readylog/plan.cpp
)
@@ -348,24 +350,31 @@ if (${BUILD_READYLOG_SEMANTICS})
src/semantics/readylog/reference.h
src/semantics/readylog/string.h
src/semantics/readylog/history.h
- src/semantics/readylog/compound_expression.h
- src/semantics/readylog/list_expression.h
+ src/semantics/readylog/compound.h
+ src/semantics/readylog/list.h
src/semantics/readylog/transition.h
- src/semantics/readylog/activity.h
src/semantics/readylog/plan.h
src/semantics/readylog/wrap_eclipseclass.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/golog++/semantics/readylog
)
+ file(
+ COPY src/semantics/readylog/boilerplate.pl
+ DESTINATION "${CMAKE_BINARY_DIR}/semantics/readylog"
+ )
install(FILES
src/semantics/readylog/boilerplate.pl
DESTINATION ${SEMANTICS_INSTALL_DIR}/readylog
)
if (INSTALL_READYLOG_INTERPRETER)
+ file(
+ COPY src/semantics/readylog/readylog_ecl
+ DESTINATION "${CMAKE_BINARY_DIR}/semantics/readylog"
+ )
install(
- DIRECTORY src/semantics/readylog/interpreter
+ DIRECTORY src/semantics/readylog/readylog_ecl
DESTINATION ${SEMANTICS_INSTALL_DIR}/readylog
)
endif()
@@ -383,6 +392,89 @@ if (${BUILD_READYLOG_SEMANTICS})
endif()
+
+######################################################################################
+# The golog++ native semantics: libnativegolog++.so
+######################################################################################
+
+option(BUILD_NATIVE_SEMANTICS "Build the native golog++ semantics" OFF)
+if (${BUILD_NATIVE_SEMANTICS})
+ set(NATIVE_SRC
+ src/semantics/native/action.cpp
+ src/semantics/native/variable.cpp
+ src/semantics/native/value.cpp
+ src/semantics/native/domain.cpp
+ src/semantics/native/arithmetic.cpp
+ src/semantics/native/execution.cpp
+ src/semantics/native/fluent.cpp
+ src/semantics/native/formula.cpp
+ src/semantics/native/procedural.cpp
+ src/semantics/native/scope.cpp
+ src/semantics/native/semantics.cpp
+ src/semantics/native/utilities.cpp
+ src/semantics/native/string.cpp
+ src/semantics/native/history.cpp
+ src/semantics/native/reference.cpp
+ src/semantics/native/effect_axiom.cpp
+ src/semantics/native/compound.cpp
+ src/semantics/native/list.cpp
+ src/semantics/native/transition.cpp
+ )
+
+ link_directories(${ECLIPSE_LIBRARY_DIRS})
+ add_library(nativegolog++ SHARED ${NATIVE_SRC})
+ target_compile_definitions(nativegolog++ PUBLIC
+ -DECLIPSE_DIR=\"${ECLIPSE_DIR}\"
+ -DUSES_NO_ENGINE_HANDLE
+ -DSEMANTICS_INSTALL_DIR=\"${CMAKE_INSTALL_PREFIX}/${SEMANTICS_INSTALL_DIR}\"
+ )
+ target_include_directories(nativegolog++ PUBLIC ${ECLIPSE_INCLUDE_DIRS})
+ target_link_libraries(nativegolog++ golog++ ${ECLIPSE_LIBRARIES} stdc++fs)
+ set_property(TARGET nativegolog++ PROPERTY CXX_STANDARD 14)
+ set_property(TARGET nativegolog++ PROPERTY SOVERSION ${GOLOGPP_VERSION})
+ install(TARGETS nativegolog++ DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(FILES
+ src/semantics/native/semantics.h
+ src/semantics/native/formula.h
+ src/semantics/native/effect_axiom.h
+ src/semantics/native/variable.h
+ src/semantics/native/value.h
+ src/semantics/native/domain.h
+ src/semantics/native/arithmetic.h
+ src/semantics/native/procedural.h
+ src/semantics/native/scope.h
+ src/semantics/native/fluent.h
+ src/semantics/native/action.h
+ src/semantics/native/execution.h
+ src/semantics/native/utilities.h
+ src/semantics/native/reference.h
+ src/semantics/native/string.h
+ src/semantics/native/history.h
+ src/semantics/native/compound.h
+ src/semantics/native/list.h
+ src/semantics/native/transition.h
+
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/golog++/semantics/native
+ )
+
+ get_target_property(NATIVEGPP_CXXFLAGS_L nativegolog++ INTERFACE_COMPILE_OPTIONS)
+ set(NATIVEGPP_CXXFLAGS "-I${ECLIPSE_INCLUDE_DIRS}")
+ if (${NATIVEGPP_CXXFLAGS_L})
+ foreach(i IN LISTS ${NATIVEGPP_CXXFLAGS_L})
+ set(NATIVEGPP_CXXFLAGS "${NATIVEGPP_CXXFLAGS} ${i}")
+ endforeach()
+ endif()
+ set(NATIVEGPP_LDFLAGS "${ECLIPSE_LDFLAGS}")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nativegolog++.pc.in ${CMAKE_CURRENT_BINARY_DIR}/nativegolog++.pc @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nativegolog++.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+endif()
+
+
+
+######################################################################################
+# The taptenc semantics for platform modeling
+######################################################################################
+
if (BUILD_TAPTENC_SEMANTICS)
set(TAPTENC_SRC
external/taptenc/src/constraints/constraints.cpp
@@ -461,6 +553,7 @@ set(GPP_TESTS
if (BUILD_PARSER AND BUILD_READYLOG_SEMANTICS)
include(CTest)
+ enable_testing()
add_executable(gologpp-test src/tests/gologpp-test.cpp)
if (USE_LIBASAN)
@@ -469,6 +562,7 @@ if (BUILD_PARSER AND BUILD_READYLOG_SEMANTICS)
set(TEST_LIBS ${TEST_LIBS} boost_filesystem boost_program_options parsegolog++ readylog++)
target_link_libraries(gologpp-test ${TEST_LIBS})
+ set_target_properties(gologpp-test PROPERTIES BUILD_RPATH ${ECLIPSE_LIBRARY_DIRS})
if (BUILD_TAPTENC_SEMANTICS)
target_link_libraries(gologpp-test taptenc-golog++)
@@ -487,3 +581,18 @@ if (BUILD_PARSER AND BUILD_READYLOG_SEMANTICS)
endif()
+
+if (${BUILD_NATIVE_SEMANTICS})
+ set(NATIVE_TEST_SRC
+ src/tools/nativegpp-test.cpp)
+ add_executable(nativegpp-test ${NATIVE_TEST_SRC})
+ target_link_libraries(nativegpp-test nativegolog++ parsegolog++)
+ set_property(TARGET nativegpp-test PROPERTY CXX_STANDARD 14)
+
+ if (USE_LIBASAN)
+ target_link_libraries(nativegpp-test asan)
+ endif()
+
+ install(TARGETS nativegpp-test RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
+
diff --git a/src/execution/activity.cpp b/src/execution/activity.cpp
index cc0a3c72..8883bb73 100644
--- a/src/execution/activity.cpp
+++ b/src/execution/activity.cpp
@@ -25,14 +25,15 @@ namespace gologpp {
-Activity::Activity(const shared_ptr &action, vector> &&args, AExecutionController &ctx, State state)
-: ReferenceBase(action, std::move(args))
+Activity::Activity(const shared_ptr &action, vector> &&args, AExecutionController &ctx, State state)
+: action_ref_(action, std::move(args))
, state_(state)
, exec_context_(ctx)
{}
+
Activity::Activity(const Transition &trans, AExecutionController &ctx)
-: ReferenceBase(trans.target(), copy(trans.args()))
+: action_ref_(trans.action(), copy(trans.ref().args()))
, state_(State::IDLE)
, exec_context_(ctx)
{
@@ -40,18 +41,6 @@ Activity::Activity(const Transition &trans, AExecutionController &ctx)
throw Bug("Activity must be constructed from a START Transition");
}
-const Action &Activity::operator *() const
-{ return *this->target(); }
-
-Action &Activity::operator *()
-{ return *this->target(); }
-
-const Action *Activity::operator ->() const
-{ return this->target().get(); }
-
-Action *Activity::operator ->()
-{ return this->target().get(); }
-
void Activity::set_state(Activity::State state)
{ state_ = state; }
@@ -81,36 +70,50 @@ void Activity::update(Transition::Hook hook)
{
PlatformBackend::Lock backend_lock = exec_context_.backend().lock();
set_state(target_state(hook));
- exec_context_.exog_queue_push(shared_from_this());
+ exec_context_.exog_queue_push(
+ shared_ptr(new Transition(action(), args(), hook))
+ );
+ update_condition_.notify_all();
}
+void Activity::wait_for_update()
+{
+ std::unique_lock update_lock { update_mutex_ };
+ State prev_state = state();
+ update_condition_.wait(update_lock, [&] {
+ return state() != prev_state;
+ });
+}
Value Activity::mapped_arg_value(const string &name) const
{
return
dynamic_cast &>(
- target()->mapping().mapped_expr(name).general_semantics()
- ).evaluate({ &this->binding() }, exec_context_.history());
+ action()->mapping().mapped_expr(name).general_semantics()
+ ).evaluate({ &this->ref().binding() }, exec_context_.history());
}
-
const std::string &Activity::mapped_name() const
-{ return target()->mapping().backend_name(); }
+{ return action()->mapping().backend_name(); }
-string Activity::to_string(const string &pfx) const
-{ return pfx + "state(" + ReferenceBase::to_string("") + ") = " + gologpp::to_string(state()); }
+shared_ptr Activity::action() const
+{ return ref().target(); }
-void Activity::attach_semantics(SemanticsFactory &implementor)
+vector> Activity::args() const
{
- if (!semantics_) {
- binding().attach_semantics(implementor);
- semantics_ = implementor.make_semantics(*this);
- for (auto &c : args())
- c->attach_semantics(implementor);
- }
+ vector> rv;
+ for (const Value *arg : ref().args())
+ rv.emplace_back(new Value(*arg));
+ return rv;
}
+const Reference &Activity::ref() const
+{ return action_ref_; }
+
+Reference &Activity::ref()
+{ return action_ref_; }
+
string to_string(Activity::State s)
{
diff --git a/src/execution/activity.h b/src/execution/activity.h
index 4849e43e..edf52c71 100644
--- a/src/execution/activity.h
+++ b/src/execution/activity.h
@@ -23,46 +23,44 @@
#include
#include "transition.h"
-#include
-
+#include
namespace gologpp {
-class Activity
-: public ReferenceBase
-, public Reference
-, public Instruction
-, public LanguageElement
-, public std::enable_shared_from_this {
+class Activity {
public:
enum State { IDLE, RUNNING, FINAL, CANCELLED, FAILED };
- Activity(const shared_ptr &action, vector> &&args, AExecutionController &, State state = IDLE);
+ Activity(
+ const shared_ptr &action,
+ vector> &&args,
+ AExecutionController &, State state = IDLE
+ );
+
Activity(const Transition &, AExecutionController &);
- virtual const Action &operator * () const override;
- virtual Action &operator * () override;
- virtual const Action *operator -> () const override;
- virtual Action *operator -> () override;
+ void update(Transition::Hook hook);
+ void wait_for_update();
State state() const;
void set_state(State s);
-
- void update(Transition::Hook hook);
-
const std::string &mapped_name() const;
Value mapped_arg_value(const string &name) const;
-
- virtual string to_string(const string &pfx) const override;
-
- virtual void attach_semantics(SemanticsFactory &) override;
+ shared_ptr action() const;
+ vector> args() const;
+ const Grounding &ref() const;
+ Grounding &ref();
static State target_state(Transition::Hook);
private:
+ Grounding action_ref_;
+
State state_;
AExecutionController &exec_context_;
+ std::condition_variable update_condition_;
+ std::mutex update_mutex_;
};
diff --git a/src/execution/controller.cpp b/src/execution/controller.cpp
index 337e6a84..4a50afe9 100644
--- a/src/execution/controller.cpp
+++ b/src/execution/controller.cpp
@@ -27,7 +27,6 @@
#include
#include
-#include "plan.h"
#include "controller.h"
#include "history.h"
#include "platform_backend.h"
@@ -88,16 +87,17 @@ AExecutionController::AExecutionController(unique_ptr &&platfor
}
-shared_ptr> AExecutionController::exog_queue_pop()
+shared_ptr AExecutionController::exog_queue_pop()
{
std::lock_guard locked{ exog_mutex_ };
- shared_ptr> rv = std::move(exog_queue_.front());
+ shared_ptr rv = std::move(exog_queue_.front());
exog_queue_.pop_front();
+ rv->attach_semantics(semantics_factory());
return rv;
}
-shared_ptr> AExecutionController::exog_queue_poll(optional timeout)
+shared_ptr AExecutionController::exog_queue_poll(optional timeout)
{
exog_queue_block(timeout);
return exog_queue_pop();
@@ -137,7 +137,7 @@ void AExecutionController::terminate()
}
-void AExecutionController::exog_queue_push(shared_ptr> exog)
+void AExecutionController::exog_queue_push(shared_ptr exog)
{
std::lock_guard { exog_mutex_ };
exog_queue_.push_back(std::move(exog));
@@ -147,7 +147,7 @@ void AExecutionController::exog_queue_push(shared_ptr>
}
}
-void AExecutionController::exog_queue_push_front(shared_ptr > exog)
+void AExecutionController::exog_queue_push_front(shared_ptr exog)
{
std::lock_guard { exog_mutex_ };
exog_queue_.push_front(std::move(exog));
@@ -160,14 +160,13 @@ void AExecutionController::exog_queue_push_front(shared_ptr> {
- step_time_action_->make_ref(
- { new Value(
- get_type(),
- Clock::now().time_since_epoch().count())
- }
- )
- } );
+ exog_queue_push_front(shared_ptr { new ExogEvent {
+ step_time_action_,
+ { unique_ptr( new Value (
+ get_type(),
+ Clock::now().time_since_epoch().count()
+ ) ) }
+ } } );
std::lock_guard l2 { wait_mutex_ };
}
@@ -191,24 +190,23 @@ History &AExecutionController::history()
void AExecutionController::drain_exog_queue()
{
while (!exog_empty()) {
- shared_ptr> exog = exog_queue_pop();
+ shared_ptr exog = exog_queue_pop();
if (!std::dynamic_pointer_cast>(exog)) {
// Nothing to do here for SwitchStateAction:
// its effects have already been applied to the component model
- if (!(*exog)->silent()) {
- log(LogLevel::INF) << ">>> Exogenous event: " << exog << flush;
+ if (!exog->ref()->silent()) {
+ log(LogLevel::INF) << ">>> Exogenous event: " << exog->ref() << flush;
silent_ = false;
}
- exog->attach_semantics(semantics_factory());
shared_ptr activity = std::dynamic_pointer_cast(exog);
- if (activity && activity->target()->senses())
+ if (activity && activity->action()->senses())
history().general_semantics().append_sensing_result(
activity,
- activity->target()->senses()->lhs(),
- activity->target()->senses()->rhs().general_semantics().evaluate(
- { &activity->binding() },
+ activity->action()->senses()->lhs(),
+ activity->action()->senses()->rhs().general_semantics().evaluate(
+ { &activity->ref().binding() },
history()
)
);
@@ -254,136 +252,5 @@ shared_ptr AExecutionController::switch_state_actio
{ return switch_state_action_; }
-/////////////////////////////////////////////////////////////////////////////////////////////////
-/***********************************************************************************************/
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-ExecutionController::ExecutionController(
- unique_ptr &&exec_backend,
- unique_ptr &&plan_transformation
-)
-: AExecutionController(std::move(exec_backend))
-, plan_transformation_(std::move(plan_transformation))
-{
- if (!plan_transformation_)
- plan_transformation_.reset(semantics_factory().platform_semantics_factory().make_transformation());
-}
-
-ExecutionController::~ExecutionController()
-{}
-
-
-void ExecutionController::run(const Instruction &program)
-{
- try {
- history().attach_semantics(semantics_factory());
- global_scope().implement_globals(semantics_factory(), *this);
-
- plan_transformation_->init(*this);
-
- while (!program.general_semantics().final({}, history())) {
- set_silent(true);
-
- unique_ptr plan {
- program.general_semantics().trans({}, history())
- };
-
- if (plan) {
- plan = plan_transformation_->transform(std::move(*plan));
-
- log(LogLevel::INF) << "<<< Transformed schedule: " << *plan << flush;
-
- while (!plan->elements().empty()) {
- set_silent(true);
-
- if (terminated)
- throw Terminate();
-
- if (!exog_empty()) {
- drain_exog_queue();
- if (backend().any_component_state_changed_exog())
- plan = plan_transformation_->transform(std::move(*plan));
- }
-
- unique_ptr empty_plan;
-
- if (plan->elements().front().earliest_timepoint() > context_time()) {
- backend().schedule_timer_event(
- plan->elements().front().earliest_timepoint()
- );
- }
- else {
- // Plan elements are expected to not return plans again (nullptr or empty Plan).
- empty_plan = plan->elements().front().instruction()
- .general_semantics().trans({}, history())
- ;
- }
-
- Clock::time_point timeout = plan->next_timeout();
-
- if (empty_plan) {
- // Empty plan: successfully executed
- if (!empty_plan->elements().empty())
- throw Bug(
- "Plan instruction returned a plan: "
- + plan->elements().front().instruction().str()
- );
- plan->elements().erase(plan->elements().begin());
- }
- else {
- // Current Plan element not executable
- try {
- drain_exog_queue_blocking(timeout);
- } catch (ExogTimeout &)
- {
- exog_timer_wakeup();
- log(LogLevel::ERR) << "=== Next-action timeout " << timeout << " exceeded" << flush;
-
- auto sw_state = dynamic_cast *>(
- &plan->elements().front().instruction()
- );
- if (sw_state) {
- global_scope().lookup_global(
- static_cast(dynamic_cast(
- sw_state->arg_for_param(sw_state->target()->param_component())
- ))
- )->backend().handle_missed_transition();
- }
-
- drain_exog_queue();
- }
-
- if (context_time() > plan->elements().front().latest_timepoint()
- || backend().any_component_state_changed_exog()
- ) {
- // First plan element's time window has passed: replan!
- log(LogLevel::INF) << "=== Re-transforming..." << flush;
- plan->make_start_slack(Clock::seconds(16384));
- plan = plan_transformation_->transform(std::move(*plan));
- log(LogLevel::INF) << "=== New schedule " << *plan << flush;
- }
- }
-
- if (history().general_semantics().should_progress()) {
- log(LogLevel::DBG) << "=== Progressing history." << flush;
- history().general_semantics().progress();
- }
- }
- }
- else {
- drain_exog_queue_blocking(nullopt);
- }
-
- if (terminated)
- throw Terminate();
-
- }
- } catch (Terminate &) {
- log(LogLevel::DBG) << ">>> Terminated." << flush;
- }
-}
-
-
-
}
diff --git a/src/execution/controller.h b/src/execution/controller.h
index 9b04a873..05414f48 100644
--- a/src/execution/controller.h
+++ b/src/execution/controller.h
@@ -23,7 +23,6 @@
#include "platform_backend.h"
#include "history.h"
-#include "transformation.h"
#include
#include
@@ -48,7 +47,7 @@ class ExogTimeout {
class AExecutionController {
public:
- typedef std::deque>> ExogQueue;
+ typedef std::deque> ExogQueue;
AExecutionController(unique_ptr &&platform_backend);
virtual ~AExecutionController() = default;
@@ -67,18 +66,18 @@ class AExecutionController {
virtual void run(const Instruction &program) = 0;
/// \return Head popped from the exog_queue or nullptr if it is empty.
- shared_ptr> exog_queue_pop();
+ shared_ptr exog_queue_pop();
/// Block until the exog_queue is non-empty.
/// \return Head popped from the exog_queue.
- shared_ptr> exog_queue_poll(optional timeout);
+ shared_ptr exog_queue_poll(optional timeout);
/// Block until the exog_queue is non-empty.
void exog_queue_block(optional timeout);
bool exog_empty();
- void exog_queue_push(shared_ptr> exog);
- void exog_queue_push_front(shared_ptr> exog);
+ void exog_queue_push(shared_ptr exog);
+ void exog_queue_push_front(shared_ptr exog);
/// Update context_time and unblock exog_queue.
void exog_timer_wakeup();
@@ -122,24 +121,6 @@ class AExecutionController {
-class ExecutionController : public AExecutionController {
-public:
- ExecutionController(
- unique_ptr &&exec_backend,
- unique_ptr &&plan_transformation
- );
-
- virtual ~ExecutionController() override;
-
- virtual void run(const Instruction &program) override;
-
-private:
- unique_ptr plan_transformation_;
-};
-
-
-
-
} // namespace gologpp
#endif
diff --git a/src/execution/dummy_backend.cpp b/src/execution/dummy_backend.cpp
index 9ca827c1..daa728e6 100644
--- a/src/execution/dummy_backend.cpp
+++ b/src/execution/dummy_backend.cpp
@@ -72,13 +72,11 @@ std::function DummyBackend::rnd_exog_generator()
break;
shared_ptr exog = exogs_[static_cast(rnd_exog_index_(prng_))];
- vector> args;
+ vector> args;
for (shared_ptr p : exog->params())
args.push_back(rnd_value(p->type()));
- shared_ptr> event(new Reference(exog, std::move(args)));
- event->attach_semantics(exec_context()->semantics_factory());
-
+ shared_ptr event(new ExogEvent(exog, std::move(args)));
exec_context()->exog_queue_push(event);
}
log(LogLevel::INF) << "exog generator TERMINATED" << flush;
@@ -124,7 +122,7 @@ void DummyBackend::preempt_activity(shared_ptr a)
{
std::lock_guard locked(thread_mtx_);
if (activity_threads_.find(a) == activity_threads_.end())
- throw EngineError("No such activity: " + a->str());
+ throw EngineError("No such activity: " + a->ref().str());
activity_threads_[a]->cancel();
}
diff --git a/src/execution/event.cpp b/src/execution/event.cpp
new file mode 100644
index 00000000..fd329a09
--- /dev/null
+++ b/src/execution/event.cpp
@@ -0,0 +1,83 @@
+/*************************************************************************
+ * This file is part of golog++.
+ *
+ * golog++ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * golog++ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with golog++. If not, see .
+**************************************************************************/
+
+
+#include "event.h"
+#include
+#include
+#include
+#include
+
+namespace gologpp {
+
+
+string AbstractEvent::to_string(const string &pfx) const
+{ return ref().to_string(pfx); }
+
+template
+Event::Event(shared_ptr action, vector> &&args)
+: ground_action_(action, std::move(args))
+{}
+
+template
+Event::Event(shared_ptr action, std::initializer_list> &&args)
+: ground_action_(action, std::vector> { std::move(args) })
+{}
+
+template
+Event::Event(shared_ptr action, std::initializer_list &&args)
+: ground_action_(action, std::vector> { args.begin(), args.end() })
+{}
+
+template
+Event::Event(Event &&other)
+: ground_action_(std::move(other.ground_action_))
+{}
+
+template
+Event::Event(const Event &other)
+: ground_action_(other.ground_action_)
+{}
+
+template
+shared_ptr Event::action() const
+{ return ground_action_.target(); }
+
+template
+const vector &Event::args()
+{ return ground_action_.args(); }
+
+template
+const Reference &Event::ref() const
+{ return ground_action_; }
+
+template
+Reference &Event::ref()
+{ return ground_action_; }
+
+
+template
+class Event;
+
+template
+class Event;
+
+template
+class Event;
+
+
+} // gologpp
diff --git a/src/execution/event.h b/src/execution/event.h
new file mode 100644
index 00000000..6f1c5c66
--- /dev/null
+++ b/src/execution/event.h
@@ -0,0 +1,67 @@
+/*************************************************************************
+ * This file is part of golog++.
+ *
+ * golog++ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * golog++ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with golog++. If not, see .
+**************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+#include