Event driven engine, further work.
This commit is contained in:
@@ -64,11 +64,6 @@
|
||||
// * If 'logmode_write' or 'logmode_none' is selected, the driver must proceed
|
||||
// to drive the application. Follow the remainder of these steps.
|
||||
//
|
||||
// * Read the lua source from disk, and call 'drv_set_lua_source'.
|
||||
//
|
||||
// * Invoke the DrivenEngine's init callback by calling
|
||||
// 'drv_invoke_engine_init'.
|
||||
//
|
||||
// * Open a hardwired list of ports for listening.
|
||||
//
|
||||
// * Repeat the following steps over and over:
|
||||
@@ -104,7 +99,7 @@
|
||||
// drv_peek_outgoing, drv_sent_outgoing, and drv_recv_incoming in the
|
||||
// same manner as you would for a socket.
|
||||
//
|
||||
// - Use 'drv_invoke_engine_update' to invoke the engine's update callback.
|
||||
// - Use 'drv_invoke_event_update' to invoke the engine's update callback.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -168,16 +163,10 @@ public:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// The initialization function. You should override this in a subclass.
|
||||
// This will be called to initialize the logic engine, shortly after the lua
|
||||
// source is loaded.
|
||||
// The update callback. You may override this in a subclass.
|
||||
// This will be called whenever anything changes.
|
||||
//
|
||||
virtual void init() {}
|
||||
|
||||
// The update function. You should override this in a subclass. This will
|
||||
// be called to give the engine a chance to respond to new data.
|
||||
//
|
||||
virtual void update() {}
|
||||
virtual void event_update() {}
|
||||
|
||||
// Get the current time.
|
||||
//
|
||||
@@ -218,21 +207,10 @@ public:
|
||||
//
|
||||
Channel *get_stdio_channel();
|
||||
|
||||
// Fetches the entire contents of the lua source directory. The keys in the
|
||||
// map are filenames, and the values in the map are file contents. By
|
||||
// default, the lua source is actually read from disk just once. If you call
|
||||
// get_lua_source a second time, it will return a nullptr. The nullptr
|
||||
// indicates that the source has not been refreshed recently. If you want
|
||||
// to reread the source code, you must trigger the process by calling
|
||||
// 'refresh_lua_source'. After some delay, it will again be possible to
|
||||
// get_lua_source.
|
||||
// Fetches the lua source, and takes ownership of it. The DrivenEngine
|
||||
// no longer contains the source after calling this.
|
||||
//
|
||||
// DRIVER: the driver is responsible for storing the lua source into the
|
||||
// DrivenEngine, once, at startup, using drv_set_source. The driver will
|
||||
// periodically poll to see if the engine has called rescan_lua_source,
|
||||
// using drv_get_rescan
|
||||
//
|
||||
std::unique_ptr<util::LuaSource> get_lua_source();
|
||||
util::LuaSourcePtr get_lua_source();
|
||||
|
||||
// Rescan the lua source directory. The lua source directory is read once,
|
||||
// automatically, at engine creation time. If you want to read it again,
|
||||
@@ -272,17 +250,6 @@ public:
|
||||
//
|
||||
void drv_logmode_none();
|
||||
|
||||
// Invoke the engine's init function. The driver must call drv_set_lua_source
|
||||
// before calling this.
|
||||
//
|
||||
void drv_invoke_engine_init();
|
||||
|
||||
// Invoke the engine's update function. This typically causes the engine
|
||||
// to check the I/O buffers, and respond to I/O, if any. It also typically
|
||||
// causes the engine to check the clock, and do any scheduled calculation.
|
||||
//
|
||||
void drv_invoke_engine_update();
|
||||
|
||||
// Get a list of all non-closed existing channels. This may include new
|
||||
// channels that were created using 'new_outgoing_channel'. It may also be
|
||||
// missing channels that were deleted. It is up to the driver to update its
|
||||
@@ -341,7 +308,11 @@ public:
|
||||
// Set the lua source code. The driver is expected to read the lua source
|
||||
// code and store it (using this function) once before invoking
|
||||
//
|
||||
void drv_set_lua_source(const util::LuaSource &source);
|
||||
void drv_set_lua_source(util::LuaSourcePtr source);
|
||||
|
||||
// Invoke the update event.
|
||||
//
|
||||
void drv_invoke_event_update();
|
||||
|
||||
// Check the 'rescan_lua_source' flag. If this flag is set, it means
|
||||
// that the engine wants the driver to rescan the lua source code.
|
||||
@@ -398,8 +369,8 @@ private:
|
||||
std::map<int, Channel *> channels_;
|
||||
Channel *recent_channel_;
|
||||
std::vector<std::unique_ptr<Channel>> accepted_channels_;
|
||||
util::LuaSourcePtr lua_source_;
|
||||
bool rescan_lua_source_;
|
||||
std::unique_ptr<util::LuaSource> lua_source_;
|
||||
double clock_;
|
||||
bool stop_driver_;
|
||||
friend class Channel;
|
||||
|
||||
Reference in New Issue
Block a user