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 
33 namespace fawkes {
34 
35 class GossipGroup;
36 class ServicePublisher;
37 class GossipAspectIniFin;
38 
39 class GossipGroupConfiguration
40 {
41 public:
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 
66 public:
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 
75 private:
76  void create_group(GossipGroupConfiguration &gc);
77 
78 private:
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
fawkes::GossipGroupConfiguration::crypto_key
std::string crypto_key
encryption key
Definition: gossip_group_manager.h:62
fawkes::GossipGroupConfiguration::recv_port
unsigned short recv_port
UDP port to list on for messages.
Definition: gossip_group_manager.h:61
fawkes::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:55
fawkes::GossipGroupManager
Definition: gossip_group_manager.h:66
fawkes::GossipGroupManager::join_group
virtual RefPtr< GossipGroup > join_group(const std::string &name)
Join a group.
Definition: gossip_group_manager.cpp:139
fawkes::GossipGroupConfiguration::name
std::string name
name of the group
Definition: gossip_group_manager.h:58
fawkes::GossipGroupManager::leave_group
virtual void leave_group(RefPtr< GossipGroup > &group)
Leave a gossip group.
Definition: gossip_group_manager.cpp:157
fawkes::GossipGroupConfiguration::GossipGroupConfiguration
GossipGroupConfiguration()
Constructor.
Definition: gossip_group_manager.cpp:37
fawkes::GossipGroupConfiguration::operator=
GossipGroupConfiguration & operator=(const GossipGroupConfiguration &c)
Assignment operator.
Definition: gossip_group_manager.cpp:88
fawkes::GossipGroupConfiguration::send_port
unsigned short send_port
UDP port to send messages to.
Definition: gossip_group_manager.h:60
fawkes::GossipGroupConfiguration
Definition: gossip_group_manager.h:43
fawkes
fawkes::ServicePublisher
Definition: service_publisher.h:35
fawkes::GossipGroupConfiguration::crypto_cipher
std::string crypto_cipher
encryption cipher
Definition: gossip_group_manager.h:63
fawkes::GossipGroupConfiguration::broadcast_addr
std::string broadcast_addr
Broadcast IP Addr.
Definition: gossip_group_manager.h:59
fawkes::GossipAspectIniFin
Definition: gossip_inifin.h:38
fawkes::GossipGroupManager::~GossipGroupManager
virtual ~GossipGroupManager()
Destructor.
Definition: gossip_group_manager.cpp:130
fawkes::GossipGroupManager::GossipGroupManager
GossipGroupManager(std::string &service_name, ServicePublisher *service_publisher, std::map< std::string, GossipGroupConfiguration > &initial_groups)
Constructor.
Definition: gossip_group_manager.cpp:111