Fawkes API
Fawkes Development Version
|
#include <>>
Public Types | |
typedef fawkes::LockMap< std::string, fawkes::Interface * > | InterfaceMap |
Map of varname to interface instance. More... | |
typedef fawkes::LockMap< std::string, std::list< fawkes::Interface * > > | InterfaceListMap |
Map of varname to list of interfaces. More... | |
Public Member Functions | |
LuaInterfaceImporter (LuaContext *context_, BlackBoard *blackboard, Configuration *config, Logger *logger) | |
Constructor. More... | |
~LuaInterfaceImporter () | |
Destructor. More... | |
void | open_reading_interfaces (std::string &prefix) |
Open interfaces for reading. More... | |
void | open_writing_interfaces (std::string &prefix) |
Open interfaces for writing. More... | |
void | add_interface (std::string varname, Interface *interface) |
Add a single interface to be pushed to the context. More... | |
void | close_reading_interfaces () |
Close interfaces for reading. More... | |
void | close_writing_interfaces () |
Close interfaces for writing. More... | |
LuaInterfaceImporter::InterfaceMap & | writing_interfaces () |
Get interface map of writing interfaces. More... | |
LuaInterfaceImporter::InterfaceMap & | reading_interfaces () |
Get interface map of reading interfaces. More... | |
void | push_interfaces () |
Push interfaces to Lua environment. More... | |
void | read_to_buffer () |
Read from all reading interfaces into a buffer. More... | |
void | read_from_buffer () |
Update interfaces from internal buffers. More... | |
void | read () |
Read from all reading interfaces. More... | |
void | write () |
Write all writing interfaces. More... | |
void | lua_restarted (LuaContext *context) |
![]() | |
virtual | ~LuaContextWatcher () |
Virtual empty destructor. More... | |
Lua interface importer. The Lua interface importer reads a list from the configuration for a given prefix and exports them to the Lua environment. The configuration entries have the form "/this/is/the/prefix/variablename" -> Interface UID. The interfaces are exported as a table assigned to the global variable named "interfaces". This table has four entries, reading and writing to tables with variablename to interface mappings and reading_by_uid and writing_by_uid with mappings from the interface UID to the interface.
Definition at line 47 of file interface_importer.h.
typedef fawkes::LockMap<std::string, std::list<fawkes::Interface *> > fawkes::LuaInterfaceImporter::InterfaceListMap |
Map of varname to list of interfaces.
Definition at line 70 of file interface_importer.h.
typedef fawkes::LockMap<std::string, fawkes::Interface *> fawkes::LuaInterfaceImporter::InterfaceMap |
Map of varname to interface instance.
Definition at line 68 of file interface_importer.h.
fawkes::LuaInterfaceImporter::LuaInterfaceImporter | ( | LuaContext * | context, |
BlackBoard * | blackboard, | ||
Configuration * | config, | ||
Logger * | logger | ||
) |
Constructor.
context | Lua context |
blackboard | BlackBoard |
config | configuration |
logger | Logger |
Definition at line 58 of file interface_importer.cpp.
fawkes::LuaInterfaceImporter::~LuaInterfaceImporter | ( | ) |
Destructor.
Definition at line 74 of file interface_importer.cpp.
void fawkes::LuaInterfaceImporter::add_interface | ( | std::string | varname, |
Interface * | interface | ||
) |
Add a single interface to be pushed to the context.
The given interface is pushed with the given variable name to the context, on explicit push_interfaces() and on the next LuaContext restart. However, the interface is not owned by the importer and thus neither is the interface read during read() nor is it written during write(). It is also not automatically closed in the destructor.
varname | the variable name of the interface |
interface | the interface to push |
Definition at line 206 of file interface_importer.cpp.
Referenced by LuaAgentPeriodicExecutionThread::init(), and LuaAgentContinuousExecutionThread::init().
void fawkes::LuaInterfaceImporter::close_reading_interfaces | ( | ) |
Close interfaces for reading.
Definition at line 245 of file interface_importer.cpp.
References fawkes::BlackBoard::unregister_observer().
void fawkes::LuaInterfaceImporter::close_writing_interfaces | ( | ) |
Close interfaces for writing.
Definition at line 269 of file interface_importer.cpp.
|
virtual |
Lua restart event. This is called when the LuaContext has been restarted, for example when file watching is enabled and a file changed. It is executed after all packages have been loaded and variables have been set, but before the start script is run. The implementation may throw an exception if anything prevents it from using the new context properly.
context | This is a temporary LuaContext that is valid as long as the method is executed. It is a wrapper context around the new Lua state, just before the start script is run and it the calling context is switched to the new state (if no error occurs). |
Implements fawkes::LuaContextWatcher.
Definition at line 435 of file interface_importer.cpp.
void fawkes::LuaInterfaceImporter::open_reading_interfaces | ( | std::string & | prefix | ) |
Open interfaces for reading.
prefix | configuration prefix for the interface list |
Definition at line 182 of file interface_importer.cpp.
Referenced by LuaAgentPeriodicExecutionThread::init(), and LuaAgentContinuousExecutionThread::init().
void fawkes::LuaInterfaceImporter::open_writing_interfaces | ( | std::string & | prefix | ) |
Open interfaces for writing.
prefix | configuration prefix for the interface list |
Definition at line 191 of file interface_importer.cpp.
References fawkes::Interface::is_writer().
Referenced by LuaAgentPeriodicExecutionThread::init(), and LuaAgentContinuousExecutionThread::init().
void fawkes::LuaInterfaceImporter::push_interfaces | ( | ) |
Push interfaces to Lua environment.
The interfaces are pushed to the interfaces table described in the class documentation. Note that you need to do this only once. The table is automatically re-pushed on a Lua restart event.
Definition at line 428 of file interface_importer.cpp.
Referenced by LuaAgentPeriodicExecutionThread::init(), and LuaAgentContinuousExecutionThread::init().
void fawkes::LuaInterfaceImporter::read | ( | ) |
Read from all reading interfaces.
Definition at line 297 of file interface_importer.cpp.
Referenced by LuaAgentPeriodicExecutionThread::loop().
void fawkes::LuaInterfaceImporter::read_from_buffer | ( | ) |
Update interfaces from internal buffers.
Exception | thrown if read_to_buffer() was not called before. |
Definition at line 326 of file interface_importer.cpp.
Referenced by LuaAgentContinuousExecutionThread::read_interfaces().
void fawkes::LuaInterfaceImporter::read_to_buffer | ( | ) |
Read from all reading interfaces into a buffer.
Definition at line 307 of file interface_importer.cpp.
Referenced by LuaAgentContinuousExecutionThread::init(), and LuaAgentContinuousExecutionThread::loop().
LuaInterfaceImporter::InterfaceMap & fawkes::LuaInterfaceImporter::reading_interfaces | ( | ) |
Get interface map of reading interfaces.
Definition at line 281 of file interface_importer.cpp.
void fawkes::LuaInterfaceImporter::write | ( | ) |
Write all writing interfaces.
Definition at line 340 of file interface_importer.cpp.
Referenced by LuaAgentPeriodicExecutionThread::loop(), and LuaAgentContinuousExecutionThread::write_interfaces().
LuaInterfaceImporter::InterfaceMap & fawkes::LuaInterfaceImporter::writing_interfaces | ( | ) |
Get interface map of writing interfaces.
Definition at line 290 of file interface_importer.cpp.