<commit_before>#ifndef RAINBACK_RAINBACK_HEADER
#define RAINBACK_RAINBACK_HEADER

#include <vector>
#include <memory>

#include <lua-cxx/DirectoryModuleLoader.hpp>
#include <lua-cxx/LuaValue.hpp>

#include <QWidget>
#include <QElapsedTimer>
#include <QTimer>

namespace rainback {

class Rainback : public QObject
{
    Q_OBJECT
    QWidget* _widget;

    Lua& _lua;

    QElapsedTimer elapsed;
    QTimer timer;

    DirectoryModuleLoader fritomodLoader;
    DirectoryModuleLoader wowLoader;
    DirectoryModuleLoader rainbackLoader;
    std::vector<std::shared_ptr<ModuleLoader>> loaders;

    void assertWidget();

    void openFile(QFile& file, const QIODevice::OpenMode& flags, const bool checkExists);
public:
    Rainback(Lua& lua);

    QWidget* widget()
    {
        return _widget;
    }

    void setWidget(QWidget* const widget)
    {
        _widget = widget;
    }

    Lua& lua() const
    {
        return _lua;
    }

private slots:
    void timeout();
    void close();
};

template <typename... Args>
void dispatch(Lua& lua, std::string event, Args&&... args)
{
    auto dispatcher = lua["Rainback"]["DispatchEvent"];
    if (dispatcher.isNil()) {
        return;
    }
    dispatcher(event, args...);
}

} // namespace rainback

#endif // RAINBACK_RAINBACK_HEADER


// vim: set ts=4 sw=4 :<commit_msg>Report event errors<commit_after>#ifndef RAINBACK_RAINBACK_HEADER
#define RAINBACK_RAINBACK_HEADER

#include <vector>
#include <memory>
#include <iostream>

#include <lua-cxx/DirectoryModuleLoader.hpp>
#include <lua-cxx/LuaValue.hpp>

#include <QWidget>
#include <QElapsedTimer>
#include <QTimer>

namespace rainback {

class Rainback : public QObject
{
    Q_OBJECT
    QWidget* _widget;

    Lua& _lua;

    QElapsedTimer elapsed;
    QTimer timer;

    DirectoryModuleLoader fritomodLoader;
    DirectoryModuleLoader wowLoader;
    DirectoryModuleLoader rainbackLoader;
    std::vector<std::shared_ptr<ModuleLoader>> loaders;

    void assertWidget();

    void openFile(QFile& file, const QIODevice::OpenMode& flags, const bool checkExists);
public:
    Rainback(Lua& lua);

    QWidget* widget()
    {
        return _widget;
    }

    void setWidget(QWidget* const widget)
    {
        _widget = widget;
    }

    Lua& lua() const
    {
        return _lua;
    }

private slots:
    void timeout();
    void close();
};

template <typename... Args>
void dispatch(Lua& lua, std::string event, Args&&... args)
{
    auto dispatcher = lua["Rainback"]["DispatchEvent"];
    if (dispatcher.isNil()) {
        return;
    }
    try {
        dispatcher(event, args...);
    } catch(LuaException& ex) {
        std::cerr << "Exception during event: " << event << "\n";
        std::cerr << ex.what() << std::endl;
    }
}

} // namespace rainback

#endif // RAINBACK_RAINBACK_HEADER


// vim: set ts=4 sw=4 :
{'fraction_non_alphanumeric': 0.12177903282739146, 'fraction_numerical': 0.0014119308153900459, 'mean_word_length': 3.2488755622188905, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727396', 'n_tokens_mistral': 968, 'n_tokens_neox': 935, 'n_words': 220}