Refactor to remove dependency of DrivenEngine on World
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
class LpxClient : public DrivenEngine {
|
||||
public:
|
||||
EngineWrapper *wrapper_;
|
||||
std::unique_ptr<World> world_;
|
||||
InvocationQueue unack_;
|
||||
SharedChannel channel_;
|
||||
PrintChanneler print_channeler_;
|
||||
@@ -18,19 +20,22 @@ public:
|
||||
lua_State *lua_syntax_checker_;
|
||||
|
||||
public:
|
||||
LpxClient() {
|
||||
LpxClient(EngineWrapper *w) : wrapper_(w) {
|
||||
lua_syntax_checker_ = LuaCoreStack::newstate(eng::l_alloc);
|
||||
|
||||
set_initial_state_standalone();
|
||||
}
|
||||
|
||||
~LpxClient() {
|
||||
unexpose_world_to_driver(wrapper_);
|
||||
lua_close(lua_syntax_checker_);
|
||||
}
|
||||
|
||||
void set_initial_state_connect(const eng::string &hostspec) {
|
||||
// Create the world model.
|
||||
unexpose_world_to_driver(wrapper_);
|
||||
world_.reset(new World(WORLD_TYPE_PREDICTIVE));
|
||||
world_->expose_world_to_driver(wrapper_);
|
||||
|
||||
// Create the communication channel.
|
||||
channel_ = new_outgoing_channel(hostspec);
|
||||
@@ -57,7 +62,9 @@ public:
|
||||
|
||||
void set_initial_state_standalone() {
|
||||
// Create the world model.
|
||||
unexpose_world_to_driver(wrapper_);
|
||||
world_.reset(new World(WORLD_TYPE_MASTER));
|
||||
world_->expose_world_to_driver(wrapper_);
|
||||
|
||||
// Make sure the channel is empty.
|
||||
channel_.reset();
|
||||
|
||||
Reference in New Issue
Block a user