1

I am trying to create a simple manager that will map error codes to functions. But since a map copies the values and a signal is noncopyable that is not a solution. I cannot use a map of shared_ptr pointers since the * operator is blocked in boost::function.

Which collection should I use to store this?

typedef boost::function<bool (shared_ptr<EngineEvent> event,long timeSinceEvent)> EngineErrorHandler;
typedef boost::signal<bool (  EngineErrorHandler )> ErrorSignal;
typedef std::map<EventErrorType,ErrorSignal> ErrorHandlers;

class ServiceErrorManager {

    public:
        static ServiceErrorManager* getInstance();

        void registerErrorHandler(EngineErrorHandler& handler,EventErrorType subScribeTo);
        void signalEngineEventfail(shared_ptr<EngineEvent> event);

    private:
        static ServiceErrorManager* m_pInstance;

       ErrorHandlers errorTypeToSignal;

        ServiceErrorManager();
        ~ServiceErrorManager();
    };
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Middy
  • 91
  • 1
  • 9

1 Answers1

1

You could always store everything into a struct and store shared_ptr or unique_ptr objects inside a map or set using a custom predicate. This seems like it would make your code a bit more self-explanatory as well.

adzm
  • 4,148
  • 1
  • 27
  • 21