GAMS  1.4.0
GroupTransient.h
Go to the documentation of this file.
1 
56 #ifndef _GAMS_GROUPS_GROUP_TRANSIENT_H_
57 #define _GAMS_GROUPS_GROUP_TRANSIENT_H_
58 
59 #include <vector>
60 #include <string>
61 #include <map>
62 
63 #include "madara/knowledge/containers/Map.h"
64 
65 #include "GroupBase.h"
66 #include "GroupFactory.h"
67 
68 namespace gams
69 {
70  namespace groups
71  {
76  {
77  public:
85  GroupTransient(const std::string & prefix = "",
86  madara::knowledge::KnowledgeBase * knowledge = 0);
87 
91  virtual ~GroupTransient();
92 
97  virtual void add_members(const AgentVector & members);
98 
102  virtual void clear_members(void);
103 
108  virtual void get_members(AgentVector & members) const;
109 
116  virtual bool is_member(const std::string & id) const;
117 
122  virtual void remove_members(const AgentVector & members);
123 
132  virtual void write(const std::string & prefix = "",
133  madara::knowledge::KnowledgeBase * knowledge = 0) const;
134 
140  virtual void set_prefix(const std::string & prefix,
141  madara::knowledge::KnowledgeBase * knowledge = 0);
142 
147  virtual size_t size(void);
148 
152  virtual void sync(void);
153 
154  protected:
155 
159  madara::knowledge::containers::Map members_;
160 
165  };
166 
171  {
172  public:
173 
178 
183 
190  virtual GroupBase * create(
191  const std::string & prefix,
192  madara::knowledge::KnowledgeBase * knowledge);
193  };
194  }
195 }
196 
197 #endif // _GAMS_GROUPS_GROUP_TRANSIENT_H_
#define GAMS_EXPORT
Definition: GamsExport.h:20
Copyright(c) 2016 Carnegie Mellon University.
Copyright(c) 2016 Carnegie Mellon University.
Base class for a group of agents.
Definition: GroupBase.h:91
Base class for a group factory.
Definition: GroupFactory.h:72
Factory for creating GroupTransient groups.
virtual GroupBase * create(const std::string &prefix, madara::knowledge::KnowledgeBase *knowledge)
Creates a group.
virtual ~GroupTransientFactory()
Destructor.
A fixed list of agent members.
madara::knowledge::containers::Map members_
The source member list in the knowledge base.
virtual void write(const std::string &prefix="", madara::knowledge::KnowledgeBase *knowledge=0) const
Writes the group information to a specified prefix in a knowledge base.
virtual ~GroupTransient()
Constructor.
virtual size_t size(void)
Returns the number of members in the group.
virtual void sync(void)
Syncs the list to the knowledge base.
virtual void add_members(const AgentVector &members)
Adds the members to the group.
AgentMap fast_members_
member list for fast access
virtual void remove_members(const AgentVector &members)
Removes members from the group.
GroupTransient(const std::string &prefix="", madara::knowledge::KnowledgeBase *knowledge=0)
Constructor.
virtual void set_prefix(const std::string &prefix, madara::knowledge::KnowledgeBase *knowledge=0)
Sets the prefix for the group in the knowledge base.
virtual void get_members(AgentVector &members) const
Retrieves the members from the group.
virtual bool is_member(const std::string &id) const
Checks if the agent is a member of the formation.
virtual void clear_members(void)
Clears the member list.
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
Contains all GAMS-related tools, classes and code.