GAMS  1.4.0
GroupFixedList.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_GROUPS_GROUP_FIXED_LIST_H_
55 #define _GAMS_GROUPS_GROUP_FIXED_LIST_H_
56 
57 #include <vector>
58 #include <string>
59 #include <map>
60 
61 #include "madara/knowledge/containers/StringVector.h"
62 
63 #include "GroupBase.h"
64 #include "GroupFactory.h"
65 
66 namespace gams
67 {
68  namespace groups
69  {
74  {
75  public:
83  GroupFixedList(const std::string & prefix = "",
84  madara::knowledge::KnowledgeBase * knowledge = 0);
85 
89  virtual ~GroupFixedList();
90 
95  virtual void add_members(const AgentVector & members);
96 
100  virtual void clear_members(void);
101 
106  virtual void get_members(AgentVector & members) const;
107 
114  virtual bool is_member(const std::string & id) const;
115 
120  virtual void remove_members(const AgentVector & members);
121 
130  virtual void write(const std::string & prefix = "",
131  madara::knowledge::KnowledgeBase * knowledge = 0) const;
132 
138  virtual void set_prefix(const std::string & prefix,
139  madara::knowledge::KnowledgeBase * knowledge = 0);
140 
145  virtual size_t size(void);
146 
150  virtual void sync(void);
151 
152  protected:
153 
157  madara::knowledge::containers::StringVector members_;
158 
163  };
164 
169  {
170  public:
171 
176 
181 
188  virtual GroupBase * create(
189  const std::string & prefix,
190  madara::knowledge::KnowledgeBase * knowledge);
191  };
192  }
193 }
194 
195 #endif // _GAMS_GROUPS_GROUP_FIXED_LIST_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 GroupFixedList groups.
virtual ~GroupFixedListFactory()
Destructor.
virtual GroupBase * create(const std::string &prefix, madara::knowledge::KnowledgeBase *knowledge)
Creates a group.
A fixed list of agent members.
GroupFixedList(const std::string &prefix="", madara::knowledge::KnowledgeBase *knowledge=0)
Constructor.
AgentVector fast_members_
member list for fast access
madara::knowledge::containers::StringVector members_
The source member list in the knowledge base.
virtual void clear_members(void)
Clears the member list.
virtual bool is_member(const std::string &id) const
Checks if the agent is a member of the formation.
virtual size_t size(void)
Returns the number of members in the group.
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 void add_members(const AgentVector &members)
Adds the members to the group.
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 remove_members(const AgentVector &members)
Removes members from the group.
virtual void sync(void)
Syncs the list to the knowledge base.
virtual void get_members(AgentVector &members) const
Retrieves the members from the group.
virtual ~GroupFixedList()
Constructor.
std::vector< std::string > AgentVector
A vector of agent names.
Definition: GroupBase.h:71
Contains all GAMS-related tools, classes and code.