#ifndef __SubscriptionManager_h__
#define __SubscriptionManager_h__

#include "Command.h"
#include "Subscription.h"
#include "SubscriptionHandler.h"
#include "TCPSession.h"
#include "ZString.h"
#include <string>
#include <vector>

namespace core
{

  class SubscriptionManager : public Command
  {

  public:
    SubscriptionManager();

    int add(Subscription &subscription);
    int add(Subscription &subscription, std::string handler);
    int addHandler(std::string name, SubscriptionHandler *handler);

    int removeSessionSubscriptions(TCPSession &session);

    int processCommand(coreutils::ZString &request, TCPSession &session) override;

  private:
    Subscription *subscription;
    std::map<std::string, Subscription *> subscriptions;
    std::map<std::string, SubscriptionHandler *> handlers;
    Subscription *newSubscription;
    std::mutex lock;
  };
}

#endif
