2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
2012-05-11 13:33:57 +02:00
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
2012-05-10 12:06:41 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
2012-04-06 08:56:52 +02:00
|
|
|
#include "i2-icinga.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Retrieves the endpoint manager this endpoint is registered with.
|
|
|
|
*
|
|
|
|
* @returns The EndpointManager object.
|
|
|
|
*/
|
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-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Sets the endpoint manager this endpoint is registered with.
|
|
|
|
*
|
|
|
|
* @param manager The EndpointManager object.
|
|
|
|
*/
|
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-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Registers a topic subscription for this endpoint.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
void Endpoint::RegisterSubscription(String topic)
|
2012-04-16 16:27:41 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Subscriptions.insert(topic);
|
2012-04-16 16:27:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Removes a topic subscription from this endpoint.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
void Endpoint::UnregisterSubscription(String topic)
|
2012-04-16 16:27:41 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Subscriptions.erase(topic);
|
2012-04-16 16:27:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Checks whether the endpoint has a subscription for the specified topic.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
* @returns true if the endpoint is subscribed to the topic, false otherwise.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
bool Endpoint::HasSubscription(String topic) const
|
2012-04-16 16:27:41 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return (m_Subscriptions.find(topic) != m_Subscriptions.end());
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Registers a topic publication for this endpoint.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
void Endpoint::RegisterPublication(String topic)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Publications.insert(topic);
|
2012-04-18 15:22:25 +02:00
|
|
|
}
|
2012-04-19 12:16:52 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Removes a topic publication from this endpoint.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
void Endpoint::UnregisterPublication(String topic)
|
2012-04-19 12:16:52 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Publications.erase(topic);
|
2012-04-19 12:16:52 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Checks whether the endpoint has a publication for the specified topic.
|
|
|
|
*
|
|
|
|
* @param topic The name of the topic.
|
|
|
|
* @returns true if the endpoint is publishing this topic, false otherwise.
|
|
|
|
*/
|
2012-08-02 09:38:08 +02:00
|
|
|
bool Endpoint::HasPublication(String topic) const
|
2012-04-19 12:16:52 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return (m_Publications.find(topic) != m_Publications.end());
|
2012-04-19 12:16:52 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Removes all subscriptions for the endpoint.
|
|
|
|
*/
|
|
|
|
void Endpoint::ClearSubscriptions(void)
|
2012-04-19 12:16:52 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Subscriptions.clear();
|
2012-04-19 12:16:52 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Removes all publications for the endpoint.
|
|
|
|
*/
|
|
|
|
void Endpoint::ClearPublications(void)
|
2012-04-19 12:16:52 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
m_Publications.clear();
|
2012-04-19 12:16:52 +02:00
|
|
|
}
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the beginning of the subscriptions list.
|
|
|
|
*
|
|
|
|
* @returns An iterator that points to the first subscription.
|
|
|
|
*/
|
|
|
|
Endpoint::ConstTopicIterator Endpoint::BeginSubscriptions(void) const
|
2012-04-30 15:30:45 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return m_Subscriptions.begin();
|
2012-04-30 15:30:45 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the end of the subscriptions list.
|
|
|
|
*
|
|
|
|
* @returns An iterator that points past the last subscription.
|
|
|
|
*/
|
|
|
|
Endpoint::ConstTopicIterator Endpoint::EndSubscriptions(void) const
|
2012-04-30 15:30:45 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return m_Subscriptions.end();
|
2012-04-30 15:30:45 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the beginning of the publications list.
|
|
|
|
*
|
|
|
|
* @returns An iterator that points to the first publication.
|
|
|
|
*/
|
|
|
|
Endpoint::ConstTopicIterator Endpoint::BeginPublications(void) const
|
2012-04-30 15:30:45 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return m_Publications.begin();
|
2012-04-30 15:30:45 +02:00
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the end of the publications list.
|
|
|
|
*
|
|
|
|
* @returns An iterator that points past the last publication.
|
|
|
|
*/
|
|
|
|
Endpoint::ConstTopicIterator Endpoint::EndPublications(void) const
|
2012-04-30 15:30:45 +02:00
|
|
|
{
|
2012-05-15 16:24:04 +02:00
|
|
|
return m_Publications.end();
|
2012-04-30 15:30:45 +02:00
|
|
|
}
|
2012-05-07 14:52:49 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Sets whether a welcome message has been received from this endpoint.
|
|
|
|
*
|
|
|
|
* @param value Whether we've received a welcome message.
|
|
|
|
*/
|
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-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Retrieves whether a welcome message has been received from this endpoint.
|
|
|
|
*
|
|
|
|
* @returns Whether we've received a welcome message.
|
|
|
|
*/
|
2012-05-25 11:10:11 +02:00
|
|
|
bool Endpoint::HasReceivedWelcome(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
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Sets whether a welcome message has been sent to this endpoint.
|
|
|
|
*
|
|
|
|
* @param value Whether we've sent a welcome message.
|
|
|
|
*/
|
2012-05-08 10:13:15 +02:00
|
|
|
void Endpoint::SetSentWelcome(bool value)
|
|
|
|
{
|
|
|
|
m_SentWelcome = value;
|
|
|
|
}
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* Retrieves whether a welcome message has been sent to this endpoint.
|
|
|
|
*
|
|
|
|
* @returns Whether we've sent a welcome message.
|
|
|
|
*/
|
2012-05-25 11:10:11 +02:00
|
|
|
bool Endpoint::HasSentWelcome(void) const
|
2012-05-08 10:13:15 +02:00
|
|
|
{
|
|
|
|
return m_SentWelcome;
|
2012-05-09 13:49:26 +02:00
|
|
|
}
|