jay/module/module.h

42 lines
1.0 KiB
C++

// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <string>
#include <memory>
#include <vector>
#include "component/core.h"
#include "component/actor.h"
#include "connection/connection.h"
namespace Module {
class Module {
public:
typedef std::vector<std::string> Tokens;
typedef std::vector<std::string> List;
typedef std::map<std::string, List> Permissions;
protected:
Module(const std::shared_ptr<Core>& core, const std::shared_ptr<Connection>& connection, const Permissions& permissions);
bool hasPermission(const std::string& permission, const std::shared_ptr<::Actor>& actor) const;
public:
virtual ~Module() noexcept;
static Tokens split(const std::string& string, const std::string& delimiter = " ");
virtual void message(const std::shared_ptr<::Actor>& actor, const Tokens& args) = 0;
protected:
std::shared_ptr<Core> core;
std::shared_ptr<Connection> connection;
Permissions permissions;
};
}