diff options
Diffstat (limited to 'src/include/broker.h')
-rw-r--r-- | src/include/broker.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/include/broker.h b/src/include/broker.h index 57c79dc..a6428e1 100644 --- a/src/include/broker.h +++ b/src/include/broker.h @@ -14,6 +14,7 @@ #include "session.h" #include <map> +#include <memory> #include <string> namespace Binc { @@ -23,7 +24,7 @@ namespace Binc { class BrokerFactory { private: - std::map<Session::State, Broker *> brokers; + std::map<Session::State, Broker> brokers; BrokerFactory(); @@ -31,40 +32,39 @@ namespace Binc { public: Broker *getBroker(Session::State state); - void assign(const std::string &fname, Operator *o); + void assign(const std::string &fname, std::shared_ptr<Operator> o); void addCapability(const std::string &c); Operator *getOperator(Session::State state, const std::string &name) const; - inline const std::string &getLastError() const; - inline void setLastError(const std::string &error) const; + const std::string &getLastError() const + { + return lastError; + } - static BrokerFactory &getInstance(); - ~BrokerFactory(); - }; + void setLastError(std::string error) const + { + lastError = std::move(error); + } - const std::string &BrokerFactory::getLastError() const - { - return lastError; - } + static BrokerFactory &getInstance(); - void BrokerFactory::setLastError(const std::string &error) const - { - lastError = error; - } + BrokerFactory(const BrokerFactory &) = delete; + BrokerFactory(const BrokerFactory &&) = delete; + }; class Broker { private: - std::map<std::string, Operator *> operators; - std::map<std::string, bool> deletables; + std::map<std::string, std::shared_ptr<Operator>> operators; public: Parser &parser; Operator *get(const std::string &name) const; - void assign(const std::string &fname, Operator *o, bool deletable = false); + void assign(const std::string &fname, std::shared_ptr<Operator> o); Parser::ParseResult parseStub(Request &cmd); Broker(Parser &p) : parser(p){}; + Broker(const Broker &) = delete; Broker(Broker &&) = default; }; |