2012-04-06 08:56:52 +02:00
|
|
|
#ifndef ENDPOINT_H
|
|
|
|
#define ENDPOINT_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
class EndpointManager;
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
struct I2_ICINGA_API NewMethodEventArgs : public EventArgs
|
|
|
|
{
|
|
|
|
string Method;
|
|
|
|
};
|
|
|
|
|
2012-04-06 08:56:52 +02:00
|
|
|
class I2_ICINGA_API Endpoint : public Object
|
|
|
|
{
|
|
|
|
private:
|
2012-04-20 10:38:11 +02:00
|
|
|
string m_Identity;
|
2012-04-16 16:27:41 +02:00
|
|
|
set<string> m_MethodSinks;
|
|
|
|
set<string> m_MethodSources;
|
2012-04-06 08:56:52 +02:00
|
|
|
|
2012-04-19 12:16:52 +02:00
|
|
|
weak_ptr<EndpointManager> m_EndpointManager;
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-04-06 08:56:52 +02:00
|
|
|
public:
|
|
|
|
typedef shared_ptr<Endpoint> Ptr;
|
|
|
|
typedef weak_ptr<Endpoint> WeakPtr;
|
|
|
|
|
2012-04-23 13:45:41 +02:00
|
|
|
virtual string GetAddress(void) const = 0;
|
|
|
|
|
2012-04-20 10:38:11 +02:00
|
|
|
string GetIdentity(void) const;
|
|
|
|
void SetIdentity(string identity);
|
|
|
|
bool HasIdentity(void) const;
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
shared_ptr<EndpointManager> GetEndpointManager(void) const;
|
2012-04-19 12:16:52 +02:00
|
|
|
void SetEndpointManager(weak_ptr<EndpointManager> manager);
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void RegisterMethodSink(string method);
|
|
|
|
void UnregisterMethodSink(string method);
|
2012-04-18 15:22:25 +02:00
|
|
|
bool IsMethodSink(string method) const;
|
2012-04-06 08:56:52 +02:00
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void RegisterMethodSource(string method);
|
|
|
|
void UnregisterMethodSource(string method);
|
2012-04-18 15:22:25 +02:00
|
|
|
bool IsMethodSource(string method) const;
|
2012-04-23 13:45:41 +02:00
|
|
|
|
|
|
|
virtual void AddAllowedMethodSinkPrefix(string method) = 0;
|
|
|
|
virtual void RemoveAllowedMethodSinkPrefix(string method) = 0;
|
|
|
|
virtual bool IsAllowedMethodSink(string method) const = 0;
|
|
|
|
virtual void AddAllowedMethodSourcePrefix(string method) = 0;
|
|
|
|
virtual void RemoveAllowedMethodSourcePrefix(string method) = 0;
|
|
|
|
virtual bool IsAllowedMethodSource(string method) const = 0;
|
2012-04-18 15:22:25 +02:00
|
|
|
|
|
|
|
virtual bool IsLocal(void) const = 0;
|
|
|
|
|
|
|
|
virtual void ProcessRequest(Endpoint::Ptr sender, const JsonRpcRequest& message) = 0;
|
|
|
|
virtual void ProcessResponse(Endpoint::Ptr sender, const JsonRpcResponse& message) = 0;
|
|
|
|
|
2012-04-27 11:44:34 +02:00
|
|
|
virtual void Stop(void) = 0;
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
Event<NewMethodEventArgs> OnNewMethodSink;
|
|
|
|
Event<NewMethodEventArgs> OnNewMethodSource;
|
2012-04-06 08:56:52 +02:00
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
void ForeachMethodSink(function<int (const NewMethodEventArgs&)> callback);
|
|
|
|
void ForeachMethodSource(function<int (const NewMethodEventArgs&)> callback);
|
2012-04-19 12:16:52 +02:00
|
|
|
|
|
|
|
void ClearMethodSinks(void);
|
|
|
|
void ClearMethodSources(void);
|
|
|
|
|
|
|
|
int CountMethodSinks(void) const;
|
|
|
|
int CountMethodSources(void) const;
|
2012-04-23 16:49:02 +02:00
|
|
|
|
|
|
|
Event<EventArgs> OnIdentityChanged;
|
2012-04-06 08:56:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ENDPOINT_H */
|