IMapControl.h 1.14 KB
//
//  IMapControl.h
//  SteveMaggieCpp
//
//  Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//

#ifndef IMapControl_h
#define IMapControl_h

#include "IMapControlInterface.h"

class AniMapLayer;
class IMapCharacter;

class IMapControl {
    
public:
    // the order of the observers in the vector will be the order of responding of the observers to events
    virtual void install(AniMapLayer* p_AniMapLayer, IMapCharacter* p_controlledCharacter, std::vector<IMapControlInterface*> p_observers) {
        for(auto it = p_observers.begin(); it != p_observers.end(); ++it){
            (*it)->m_mapControl = this;
        }
        m_observers = p_observers;
    }
    
    virtual void uninstall(){
        for(auto it = m_observers.begin(); it != m_observers.end(); ++it){
            (*it)->m_mapControl = nullptr;
        }
        m_observers.clear();
    }
    
    virtual ~IMapControl(){};
    
    struct IMapEvent {
        std::string type;
    };
    
    virtual void mapEvent(IMapControlInterface* p_controlInterface, IMapEvent* p_mapEvent){};
    
protected:
    std::vector<IMapControlInterface*> m_observers;
};

#endif /* IMapControl_h */