InspectorBaseAgent.h [plain text]
#ifndef InspectorBaseAgent_h
#define InspectorBaseAgent_h
#include "InspectorBackendDispatcher.h"
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class InspectorFrontend;
class InspectorCompositeState;
class InspectorState;
class InstrumentingAgents;
class InspectorBaseAgentInterface {
public:
InspectorBaseAgentInterface(const String&, InstrumentingAgents*, InspectorCompositeState*);
virtual ~InspectorBaseAgentInterface();
virtual void setFrontend(InspectorFrontend*) { }
virtual void clearFrontend() { }
virtual void restore() { }
virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0;
virtual void discardAgent() { }
String name() { return m_name; }
protected:
InstrumentingAgents* m_instrumentingAgents;
InspectorState* m_state;
private:
String m_name;
};
class InspectorAgentRegistry {
public:
void append(PassOwnPtr<InspectorBaseAgentInterface>);
void setFrontend(InspectorFrontend*);
void clearFrontend();
void restore();
void registerInDispatcher(InspectorBackendDispatcher*);
void discardAgents();
private:
Vector<OwnPtr<InspectorBaseAgentInterface> > m_agents;
};
template<typename T>
class InspectorBaseAgent : public InspectorBaseAgentInterface {
public:
virtual ~InspectorBaseAgent() { }
virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher)
{
dispatcher->registerAgent(static_cast<T*>(this));
}
protected:
InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState)
: InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState)
{
}
};
}
#endif // !defined(InspectorBaseAgent_h)