Fawkes API Fawkes Development Version
gossip_group_manager.h
1
2/***************************************************************************
3 * gossip_group_manager.h - Fawkes Gossip group manager
4 *
5 * Created: Fri Feb 28 16:54:34 2014
6 * Copyright 2006-2014 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _PLUGINS_GOSSIP_GOSSIP_GOSSIP_GROUP_MANAGER_H_
25#define _PLUGINS_GOSSIP_GOSSIP_GOSSIP_GROUP_MANAGER_H_
26
27#include <core/utils/refptr.h>
28
29#include <list>
30#include <map>
31#include <string>
32
33namespace fawkes {
34
35class GossipGroup;
36class ServicePublisher;
37class GossipAspectIniFin;
38
40{
41public:
44 GossipGroupConfiguration(std::string & name,
45 std::string & broadcast_address,
46 unsigned short broadcast_port);
47 GossipGroupConfiguration(std::string & name,
48 std::string & broadcast_address,
49 unsigned short send_port,
50 unsigned short recv_port);
51
53
54 std::string name; ///< name of the group
55 std::string broadcast_addr; ///< Broadcast IP Addr
56 unsigned short send_port; ///< UDP port to send messages to
57 unsigned short recv_port; ///< UDP port to list on for messages
58 std::string crypto_key; ///< encryption key
59 std::string crypto_cipher; ///< encryption cipher
60};
61
63{
64 friend GossipAspectIniFin;
65
66public:
67 GossipGroupManager(std::string & service_name,
68 ServicePublisher * service_publisher,
69 std::map<std::string, GossipGroupConfiguration> &initial_groups);
70 virtual ~GossipGroupManager();
71
72 virtual RefPtr<GossipGroup> join_group(const std::string &name);
73 virtual void leave_group(RefPtr<GossipGroup> &group);
74
75private:
76 void create_group(GossipGroupConfiguration &gc);
77
78private:
79 std::string service_name_;
80 ServicePublisher * service_publisher_;
81 std::map<std::string, RefPtr<GossipGroup>> groups_;
82};
83
84} // end namespace fawkes
85
86#endif
GossipAspect initializer/finalizer.
Definition: gossip_inifin.h:35
Group configuration for initial groups.
unsigned short send_port
UDP port to send messages to.
unsigned short recv_port
UDP port to list on for messages.
std::string name
name of the group
std::string crypto_cipher
encryption cipher
GossipGroupConfiguration & operator=(const GossipGroupConfiguration &c)
Assignment operator.
std::string crypto_key
encryption key
std::string broadcast_addr
Broadcast IP Addr.
Abstract class for a Gossip group manager.
GossipGroupManager(std::string &service_name, ServicePublisher *service_publisher, std::map< std::string, GossipGroupConfiguration > &initial_groups)
Constructor.
virtual void leave_group(RefPtr< GossipGroup > &group)
Leave a gossip group.
virtual RefPtr< GossipGroup > join_group(const std::string &name)
Join a group.
virtual ~GossipGroupManager()
Destructor.
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:50
Service publisher interface.
Fawkes library namespace.