GAMS  1.2.2
GroupBase.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_GROUPS_GROUP_BASE_H_
55 #define _GAMS_GROUPS_GROUP_BASE_H_
56 
57 #include <vector>
58 #include <string>
59 #include <map>
60 
61 #include "madara/knowledge/KnowledgeBase.h"
62 
63 #include "gams/GamsExport.h"
64 #include "GroupTypesEnum.h"
65 
66 namespace gams
67 {
68  namespace groups
69  {
71  typedef std::vector <std::string> AgentVector;
72 
74  typedef std::map <std::string,
75  madara::knowledge::KnowledgeRecord::Integer> AgentMap;
76 
84  int find_member_index (const std::string & prefix,
85  const AgentVector & members);
86 
91  {
92  public:
98  GroupBase (const std::string & prefix = "",
99  madara::knowledge::KnowledgeBase * knowledge = 0);
100 
104  virtual ~GroupBase ();
105 
110  virtual void add_members (const AgentVector & members) = 0;
111 
115  virtual void clear_members (void) = 0;
116 
121  virtual void get_members (AgentVector & members) const = 0;
122 
129  virtual bool is_member (const std::string & id) const = 0;
130 
139  virtual void write (const std::string & prefix = "",
140  madara::knowledge::KnowledgeBase * knowledge = 0) const = 0;
141 
147  virtual void set_prefix (const std::string & prefix,
148  madara::knowledge::KnowledgeBase * knowledge = 0);
149 
154  virtual size_t size (void) = 0;
155 
159  virtual void sync (void) = 0;
160 
165  const std::string & get_prefix (void) const;
166 
167  protected:
168 
172  mutable madara::knowledge::KnowledgeBase * knowledge_;
173 
177  std::string prefix_;
178  };
179  }
180 }
181 
182 #include "GroupBase.inl"
183 
184 #endif // _GAMS_GROUPS_GROUP_BASE_H_
std::vector< std::string > AgentVector
A vector of agent names.
Definition: GroupBase.h:71
std::map< std::string, madara::knowledge::KnowledgeRecord::Integer > AgentMap
A map of agent names.
Definition: GroupBase.h:75
madara::knowledge::KnowledgeBase * knowledge_
The knowledge base to use as a data plane.
Definition: GroupBase.h:172
std::string prefix_
the prefix for the group
Definition: GroupBase.h:177
Contains all GAMS-related tools, classes and code.
Base class for a group of agents.
Definition: GroupBase.h:90
#define GAMS_EXPORT
Definition: GamsExport.h:20
Copyright (c) 2016 Carnegie Mellon University.
int find_member_index(const std::string &prefix, const AgentVector &members)
Finds the index of the member prefix in a member listing.