2012-04-06 08:56:52 +02:00
|
|
|
#include "i2-icinga.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2012-05-07 14:52:49 +02:00
|
|
|
Endpoint::Endpoint(void)
|
|
|
|
{
|
2012-05-08 10:13:15 +02:00
|
|
|
m_ReceivedWelcome = false;
|
|
|
|
m_SentWelcome = false;
|
2012-05-07 14:52:49 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 10:38:11 +02:00
|
|
|
string Endpoint::GetIdentity(void) const
|
|
|
|
{
|
|
|
|
return m_Identity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Endpoint::SetIdentity(string identity)
|
|
|
|
{
|
|
|
|
m_Identity = identity;
|
2012-04-23 16:49:02 +02:00
|
|
|
|
|
|
|
EventArgs ea;
|
|
|
|
ea.Source = shared_from_this();
|
|
|
|
OnIdentityChanged(ea);
|
2012-04-20 10:38:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Endpoint::HasIdentity(void) const
|
|
|
|
{
|
|
|
|
return !m_Identity.empty();
|
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
EndpointManager::Ptr Endpoint::GetEndpointManager(void) const
|
|
|
|
{
|
2012-04-19 12:16:52 +02:00
|
|
|
return m_EndpointManager.lock();
|
2012-04-18 15:22:25 +02:00
|
|
|
}
|
|
|
|
|
2012-04-19 12:16:52 +02:00
|
|
|
void Endpoint::SetEndpointManager(EndpointManager::WeakPtr manager)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
|
|
|
m_EndpointManager = manager;
|
|
|
|
}
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void Endpoint::RegisterMethodSink(string method)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
2012-04-16 16:27:41 +02:00
|
|
|
m_MethodSinks.insert(method);
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void Endpoint::UnregisterMethodSink(string method)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
2012-04-16 16:27:41 +02:00
|
|
|
m_MethodSinks.erase(method);
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
bool Endpoint::IsMethodSink(string method) const
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
2012-04-16 16:27:41 +02:00
|
|
|
return (m_MethodSinks.find(method) != m_MethodSinks.end());
|
|
|
|
}
|
|
|
|
|
2012-05-08 09:20:42 +02:00
|
|
|
void Endpoint::ForEachMethodSink(function<int (const NewMethodEventArgs&)> callback)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
|
|
|
for (set<string>::iterator i = m_MethodSinks.begin(); i != m_MethodSinks.end(); i++) {
|
|
|
|
NewMethodEventArgs nmea;
|
|
|
|
nmea.Source = shared_from_this();
|
|
|
|
nmea.Method = *i;
|
|
|
|
callback(nmea);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void Endpoint::RegisterMethodSource(string method)
|
|
|
|
{
|
|
|
|
m_MethodSources.insert(method);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Endpoint::UnregisterMethodSource(string method)
|
|
|
|
{
|
|
|
|
m_MethodSources.erase(method);
|
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
bool Endpoint::IsMethodSource(string method) const
|
2012-04-16 16:27:41 +02:00
|
|
|
{
|
2012-04-30 15:30:45 +02:00
|
|
|
return (m_MethodSources.find(method) != m_MethodSources.end());
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-05-08 09:20:42 +02:00
|
|
|
void Endpoint::ForEachMethodSource(function<int (const NewMethodEventArgs&)> callback)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
|
|
|
for (set<string>::iterator i = m_MethodSources.begin(); i != m_MethodSources.end(); i++) {
|
|
|
|
NewMethodEventArgs nmea;
|
|
|
|
nmea.Source = shared_from_this();
|
|
|
|
nmea.Method = *i;
|
|
|
|
callback(nmea);
|
|
|
|
}
|
|
|
|
}
|
2012-04-19 12:16:52 +02:00
|
|
|
|
|
|
|
void Endpoint::ClearMethodSinks(void)
|
|
|
|
{
|
|
|
|
m_MethodSinks.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Endpoint::ClearMethodSources(void)
|
|
|
|
{
|
|
|
|
m_MethodSources.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Endpoint::CountMethodSinks(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSinks.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Endpoint::CountMethodSources(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSources.size();
|
|
|
|
}
|
2012-04-30 15:30:45 +02:00
|
|
|
|
|
|
|
set<string>::const_iterator Endpoint::BeginSinks(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSinks.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
set<string>::const_iterator Endpoint::EndSinks(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSinks.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
set<string>::const_iterator Endpoint::BeginSources(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSources.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
set<string>::const_iterator Endpoint::EndSources(void) const
|
|
|
|
{
|
|
|
|
return m_MethodSources.end();
|
|
|
|
}
|
2012-05-07 14:52:49 +02:00
|
|
|
|
2012-05-08 10:13:15 +02:00
|
|
|
void Endpoint::SetReceivedWelcome(bool value)
|
2012-05-07 14:52:49 +02:00
|
|
|
{
|
2012-05-08 10:13:15 +02:00
|
|
|
m_ReceivedWelcome = value;
|
2012-05-07 14:52:49 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 10:13:15 +02:00
|
|
|
bool Endpoint::GetReceivedWelcome(void) const
|
2012-05-07 14:52:49 +02:00
|
|
|
{
|
2012-05-08 10:13:15 +02:00
|
|
|
return m_ReceivedWelcome;
|
2012-05-07 14:52:49 +02:00
|
|
|
}
|
2012-05-08 10:13:15 +02:00
|
|
|
|
|
|
|
void Endpoint::SetSentWelcome(bool value)
|
|
|
|
{
|
|
|
|
m_SentWelcome = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Endpoint::GetSentWelcome(void) const
|
|
|
|
{
|
|
|
|
return m_SentWelcome;
|
|
|
|
}
|