A bit better module config
This commit is contained in:
parent
647b8f3072
commit
98bfab4ba5
13 changed files with 67 additions and 45 deletions
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "actor.h"
|
||||
|
||||
Module::Actor::Actor(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions):
|
||||
Module(core, permissions, "Actor")
|
||||
Module::Actor::Actor(const std::shared_ptr<Core>& core, const Config::Module& conf):
|
||||
Module(core, conf, "Actor")
|
||||
{}
|
||||
|
||||
Module::Actor::~Actor() noexcept {}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Module {
|
|||
|
||||
class Actor : public Module {
|
||||
public:
|
||||
Actor(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions);
|
||||
Actor(const std::shared_ptr<Core>& core, const Config::Module& conf);
|
||||
~Actor() noexcept;
|
||||
|
||||
virtual Shared::Result message(const std::shared_ptr<::Actor>& actor, const Shared::Strings& args) override;
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
#include "gloox/message.h"
|
||||
|
||||
Module::Module::Module(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions, const std::string& name):
|
||||
Shared::Loggable(core->logger, {"Module", name}),
|
||||
Module::Module::Module(const std::shared_ptr<Core>& core, const Config::Module& conf, const std::string& name):
|
||||
Shared::Loggable(core->logger, {"Module", name, conf.alias}),
|
||||
name(name),
|
||||
alias(conf.alias),
|
||||
core(core),
|
||||
permissions(permissions)
|
||||
permissions(conf.permissions)
|
||||
{}
|
||||
|
||||
bool Module::Module::hasPermission(const std::string& permission, const std::shared_ptr<::Actor>& actor) const {
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
#include "shared/loggable.h"
|
||||
#include "component/core.h"
|
||||
#include "component/actor.h"
|
||||
#include "component/config.h"
|
||||
|
||||
namespace Module {
|
||||
|
||||
class Module : protected Shared::Loggable {
|
||||
protected:
|
||||
Module(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions, const std::string& name);
|
||||
Module(const std::shared_ptr<Core>& core, const Config::Module& conf, const std::string& name);
|
||||
|
||||
bool hasPermission(const std::string& permission, const std::shared_ptr<::Actor>& actor) const;
|
||||
|
||||
|
@ -30,6 +31,10 @@ public:
|
|||
|
||||
virtual Shared::Result message(const std::shared_ptr<::Actor>& actor, const Shared::Strings& args) = 0;
|
||||
|
||||
public:
|
||||
const std::string name;
|
||||
const std::string alias;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Core> core;
|
||||
Shared::Permissions permissions;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <exception>
|
||||
|
||||
Module::Publish::Publish(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions):
|
||||
Module(core, permissions, "Actor")
|
||||
Module::Publish::Publish(const std::shared_ptr<Core>& core, const Config::Module& conf):
|
||||
Module(core, conf, "Publish")
|
||||
{}
|
||||
|
||||
Module::Publish::~Publish() noexcept {}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Module {
|
|||
|
||||
class Publish : public Module {
|
||||
public:
|
||||
Publish(const std::shared_ptr<Core>& core, const Shared::Permissions& permissions);
|
||||
Publish(const std::shared_ptr<Core>& core, const Config::Module& conf);
|
||||
~Publish() noexcept;
|
||||
|
||||
virtual Shared::Result message(const std::shared_ptr<::Actor>& actor, const Shared::Strings& args) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue