1 /******************************************************************************
3 * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
26 class EndpointManager;
29 * An endpoint that can be used to send and receive messages.
33 class I2_ICINGA_API Endpoint : public Object
36 typedef shared_ptr<Endpoint> Ptr;
37 typedef weak_ptr<Endpoint> WeakPtr;
39 typedef set<string>::const_iterator ConstTopicIterator;
43 virtual string GetAddress(void) const = 0;
45 string GetIdentity(void) const;
46 void SetIdentity(string identity);
48 void SetReceivedWelcome(bool value);
49 bool HasReceivedWelcome(void) const;
51 void SetSentWelcome(bool value);
52 bool HasSentWelcome(void) const;
54 shared_ptr<EndpointManager> GetEndpointManager(void) const;
55 void SetEndpointManager(weak_ptr<EndpointManager> manager);
57 void RegisterSubscription(string topic);
58 void UnregisterSubscription(string topic);
59 bool HasSubscription(string topic) const;
61 void RegisterPublication(string topic);
62 void UnregisterPublication(string topic);
63 bool HasPublication(string topic) const;
65 virtual bool IsLocal(void) const = 0;
66 virtual bool IsConnected(void) const = 0;
68 virtual void ProcessRequest(Endpoint::Ptr sender, const RequestMessage& message) = 0;
69 virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message) = 0;
71 virtual void Stop(void) = 0;
73 void ClearSubscriptions(void);
74 void ClearPublications(void);
76 ConstTopicIterator BeginSubscriptions(void) const;
77 ConstTopicIterator EndSubscriptions(void) const;
79 ConstTopicIterator BeginPublications(void) const;
80 ConstTopicIterator EndPublications(void) const;
82 boost::signal<void (const EventArgs&)> OnIdentityChanged;
83 boost::signal<void (const EventArgs&)> OnSessionEstablished;
86 string m_Identity; /**< The identity of this endpoint. */
87 set<string> m_Subscriptions; /**< The topics this endpoint is
89 set<string> m_Publications; /**< The topics this endpoint is
91 bool m_ReceivedWelcome; /**< Have we received a welcome message
92 from this endpoint? */
93 bool m_SentWelcome; /**< Have we sent a welcome message to this
96 weak_ptr<EndpointManager> m_EndpointManager; /**< The endpoint manager
103 #endif /* ENDPOINT_H */