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
|
|
|
#ifndef ENDPOINT_H
|
|
|
|
#define ENDPOINT_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
class EndpointManager;
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
|
|
|
* An endpoint that can be used to send and receive messages.
|
2012-05-18 22:21:28 +02:00
|
|
|
*
|
|
|
|
* @ingroup icinga
|
2012-05-15 16:24:04 +02:00
|
|
|
*/
|
2012-04-06 08:56:52 +02:00
|
|
|
class I2_ICINGA_API Endpoint : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef shared_ptr<Endpoint> Ptr;
|
|
|
|
typedef weak_ptr<Endpoint> WeakPtr;
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
typedef set<string>::const_iterator ConstTopicIterator;
|
|
|
|
|
2012-05-07 14:52:49 +02:00
|
|
|
Endpoint(void);
|
|
|
|
|
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);
|
|
|
|
|
2012-05-08 10:13:15 +02:00
|
|
|
void SetReceivedWelcome(bool value);
|
2012-05-25 11:10:11 +02:00
|
|
|
bool HasReceivedWelcome(void) const;
|
2012-05-08 10:13:15 +02:00
|
|
|
|
|
|
|
void SetSentWelcome(bool value);
|
2012-05-25 11:10:11 +02:00
|
|
|
bool HasSentWelcome(void) const;
|
2012-05-07 14:52:49 +02:00
|
|
|
|
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-05-15 16:24:04 +02:00
|
|
|
void RegisterSubscription(string topic);
|
|
|
|
void UnregisterSubscription(string topic);
|
|
|
|
bool HasSubscription(string topic) const;
|
2012-04-06 08:56:52 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
void RegisterPublication(string topic);
|
|
|
|
void UnregisterPublication(string topic);
|
|
|
|
bool HasPublication(string topic) const;
|
2012-04-18 15:22:25 +02:00
|
|
|
|
|
|
|
virtual bool IsLocal(void) const = 0;
|
2012-04-27 13:44:53 +02:00
|
|
|
virtual bool IsConnected(void) const = 0;
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-05-21 12:53:38 +02:00
|
|
|
virtual void ProcessRequest(Endpoint::Ptr sender, const RequestMessage& message) = 0;
|
|
|
|
virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message) = 0;
|
2012-04-18 15:22:25 +02:00
|
|
|
|
2012-04-27 11:44:34 +02:00
|
|
|
virtual void Stop(void) = 0;
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
void ClearSubscriptions(void);
|
|
|
|
void ClearPublications(void);
|
2012-04-23 16:49:02 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
ConstTopicIterator BeginSubscriptions(void) const;
|
|
|
|
ConstTopicIterator EndSubscriptions(void) const;
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
ConstTopicIterator BeginPublications(void) const;
|
|
|
|
ConstTopicIterator EndPublications(void) const;
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-06-14 15:16:41 +02:00
|
|
|
boost::signal<void (const EventArgs&)> OnIdentityChanged;
|
|
|
|
boost::signal<void (const EventArgs&)> OnSessionEstablished;
|
2012-05-21 23:42:54 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
string m_Identity; /**< The identity of this endpoint. */
|
|
|
|
set<string> m_Subscriptions; /**< The topics this endpoint is
|
|
|
|
subscribed to. */
|
|
|
|
set<string> m_Publications; /**< The topics this endpoint is
|
|
|
|
publishing. */
|
|
|
|
bool m_ReceivedWelcome; /**< Have we received a welcome message
|
|
|
|
from this endpoint? */
|
|
|
|
bool m_SentWelcome; /**< Have we sent a welcome message to this
|
|
|
|
endpoint? */
|
|
|
|
|
|
|
|
weak_ptr<EndpointManager> m_EndpointManager; /**< The endpoint manager
|
|
|
|
this endpoint is
|
|
|
|
registered with. */
|
2012-04-06 08:56:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ENDPOINT_H */
|