The SqliteLogger is a logger that will store the tree and all the status transitions in a SQLite database (single file). More...
#include <bt_sqlite_logger.h>

Classes | |
| struct | Transition |
Public Types | |
| using | ExtraCallback = std::function< std::string(Duration, const TreeNode &, NodeStatus, NodeStatus)> |
Public Member Functions | |
| virtual void | callback (Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override |
| void | execSqlStatement (std::string statement) |
| virtual void | flush () override |
| void | setAdditionalCallback (ExtraCallback func) |
| SqliteLogger (const Tree &tree, std::filesystem::path const &file, bool append=false) | |
| To correctly read this log with Groot2, you must use the suffix ".db3". Constructor will throw otherwise. More... | |
| virtual | ~SqliteLogger () override |
Public Member Functions inherited from BT::StatusChangeLogger | |
| bool | enabled () const |
| void | enableTransitionToIdle (bool enable) |
| StatusChangeLogger & | operator= (const StatusChangeLogger &other)=delete |
| StatusChangeLogger & | operator= (StatusChangeLogger &&other)=default |
| void | setEnabled (bool enabled) |
| void | setTimestampType (TimestampType type) |
| bool | showsTransitionToIdle () const |
| StatusChangeLogger (const StatusChangeLogger &other)=delete | |
| StatusChangeLogger (StatusChangeLogger &&other)=default | |
| StatusChangeLogger (TreeNode *root_node) | |
| virtual | ~StatusChangeLogger ()=default |
Private Member Functions | |
| void | writerLoop () |
Private Attributes | |
| std::unique_ptr< sqlite::Connection > | db_ |
| ExtraCallback | extra_func_ |
| std::atomic_bool | loop_ = true |
| int64_t | monotonic_timestamp_ = 0 |
| std::condition_variable | queue_cv_ |
| std::mutex | queue_mutex_ |
| int | session_id_ = -1 |
| std::unordered_map< const BT::TreeNode *, int64_t > | starting_time_ |
| std::deque< Transition > | transitions_queue_ |
| std::thread | writer_thread_ |
The SqliteLogger is a logger that will store the tree and all the status transitions in a SQLite database (single file).
SQL schema
CREATE TABLE IF NOT EXISTS Definitions ( session_id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, xml_tree TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS Nodes (" session_id INTEGER NOT NULL, fullpath VARCHAR, " node_uid INTEGER NOT NULL );
CREATE TABLE IF NOT EXISTS Transitions ( timestamp INTEGER PRIMARY KEY NOT NULL, session_id INTEGER NOT NULL, node_uid INTEGER NOT NULL, duration INTEGER, state INTEGER NOT NULL, extra_data VARCHAR ); You can append data to the same file; this allows you to store multiple experiments into the database. Yn that case, each recording has a unique session_id.
This is primarily meant to be used with Groot2, but the content of the tables is sufficiently self-explaining, and you can create your own tools to extract the information.
Definition at line 47 of file bt_sqlite_logger.h.
| using BT::SqliteLogger::ExtraCallback = std::function<std::string(Duration, const TreeNode&, NodeStatus, NodeStatus)> |
Definition at line 66 of file bt_sqlite_logger.h.
| BT::SqliteLogger::SqliteLogger | ( | const Tree & | tree, |
| std::filesystem::path const & | file, | ||
| bool | append = false |
||
| ) |
To correctly read this log with Groot2, you must use the suffix ".db3". Constructor will throw otherwise.
| tree | the tree to log |
| filepath | path of the file where info will be stored |
| append | if true, add this recording to the database |
Definition at line 8 of file bt_sqlite_logger.cpp.
|
overridevirtual |
Definition at line 73 of file bt_sqlite_logger.cpp.
|
overridevirtual |
Implements BT::StatusChangeLogger.
Definition at line 87 of file bt_sqlite_logger.cpp.
| void BT::SqliteLogger::execSqlStatement | ( | std::string | statement | ) |
Definition at line 134 of file bt_sqlite_logger.cpp.
|
overridevirtual |
Implements BT::StatusChangeLogger.
Definition at line 164 of file bt_sqlite_logger.cpp.
| void BT::SqliteLogger::setAdditionalCallback | ( | ExtraCallback | func | ) |
Definition at line 82 of file bt_sqlite_logger.cpp.
|
private |
Definition at line 139 of file bt_sqlite_logger.cpp.
|
private |
Definition at line 77 of file bt_sqlite_logger.h.
|
private |
Definition at line 100 of file bt_sqlite_logger.h.
|
private |
Definition at line 98 of file bt_sqlite_logger.h.
|
private |
Definition at line 79 of file bt_sqlite_logger.h.
|
private |
Definition at line 94 of file bt_sqlite_logger.h.
|
private |
Definition at line 95 of file bt_sqlite_logger.h.
|
private |
Definition at line 82 of file bt_sqlite_logger.h.
|
private |
Definition at line 80 of file bt_sqlite_logger.h.
|
private |
Definition at line 93 of file bt_sqlite_logger.h.
|
private |
Definition at line 97 of file bt_sqlite_logger.h.