GAMS  1.4.0
gams::groups::GroupBase Class Referenceabstract

Base class for a group of agents. More...

#include <GroupBase.h>

Inheritance diagram for gams::groups::GroupBase:
gams::groups::GroupFixedList gams::groups::GroupTransient

Public Member Functions

 GroupBase (const std::string &prefix="", madara::knowledge::KnowledgeBase *knowledge=0)
 Constructor. More...
 
virtual ~GroupBase ()
 Constructor. More...
 
virtual void add_members (const AgentVector &members)=0
 Adds the members to the group. More...
 
virtual void clear_members (void)=0
 Clears the member list. More...
 
virtual void get_members (AgentVector &members) const =0
 Retrieves the members from the group. More...
 
const std::string & get_prefix (void) const
 Gets the prefix for the group in the knowledge base. More...
 
virtual bool is_member (const std::string &id) const =0
 Checks if the agent is a member of the formation. More...
 
virtual void remove_members (const AgentVector &members)=0
 Removes members from the group. More...
 
virtual void set_prefix (const std::string &prefix, madara::knowledge::KnowledgeBase *knowledge=0)
 Sets the prefix for the group in the knowledge base. More...
 
virtual size_t size (void)=0
 Returns the number of members in the group. More...
 
virtual void sync (void)=0
 Syncs the list to the knowledge base. More...
 
virtual void write (const std::string &prefix="", madara::knowledge::KnowledgeBase *knowledge=0) const =0
 Writes the group information to a specified prefix in a knowledge base. More...
 

Protected Attributes

madara::knowledge::KnowledgeBase * knowledge_
 The knowledge base to use as a data plane. More...
 
std::string prefix_
 the prefix for the group More...
 

Detailed Description

Base class for a group of agents.

Definition at line 90 of file GroupBase.h.

Constructor & Destructor Documentation

◆ GroupBase()

gams::groups::GroupBase::GroupBase ( const std::string &  prefix = "",
madara::knowledge::KnowledgeBase *  knowledge = 0 
)

Constructor.

Parameters
prefixthe name of the group(e.g. group.protectors)
knowledgethe knowledge base to use for syncing

◆ ~GroupBase()

virtual gams::groups::GroupBase::~GroupBase ( )
virtual

Constructor.

Member Function Documentation

◆ add_members()

virtual void gams::groups::GroupBase::add_members ( const AgentVector members)
pure virtual

Adds the members to the group.

Parameters
memberslist of members to add

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ clear_members()

virtual void gams::groups::GroupBase::clear_members ( void  )
pure virtual

Clears the member list.

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ get_members()

virtual void gams::groups::GroupBase::get_members ( AgentVector members) const
pure virtual

Retrieves the members from the group.

Parameters
membersa list of the members currently in the group

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ get_prefix()

const std::string& gams::groups::GroupBase::get_prefix ( void  ) const

Gets the prefix for the group in the knowledge base.

Returns
the name of the group(e.g. group.protectors)

◆ is_member()

virtual bool gams::groups::GroupBase::is_member ( const std::string &  id) const
pure virtual

Checks if the agent is a member of the formation.

Parameters
idthe agent id(e.g. agent.0 or agent.leader). If null, uses the current agent's id
Returns
true if the agent is a member of the group

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ remove_members()

virtual void gams::groups::GroupBase::remove_members ( const AgentVector members)
pure virtual

Removes members from the group.

Parameters
memberslist of members to remove if they exist

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ set_prefix()

virtual void gams::groups::GroupBase::set_prefix ( const std::string &  prefix,
madara::knowledge::KnowledgeBase *  knowledge = 0 
)
virtual

Sets the prefix for the group in the knowledge base.

Parameters
prefixthe name of the group(e.g. group.protectors)
knowledgethe knowledge base to use for syncing

Reimplemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ size()

virtual size_t gams::groups::GroupBase::size ( void  )
pure virtual

Returns the number of members in the group.

Returns
the number of members

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ sync()

virtual void gams::groups::GroupBase::sync ( void  )
pure virtual

Syncs the list to the knowledge base.

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

◆ write()

virtual void gams::groups::GroupBase::write ( const std::string &  prefix = "",
madara::knowledge::KnowledgeBase *  knowledge = 0 
) const
pure virtual

Writes the group information to a specified prefix in a knowledge base.

If no knowledge base is specified, then saves in the original knowledge base. If no prefix is specified, then saves in the original prefix location

Parameters
prefixthe name of the group(e.g. group.protectors)
knowledgethe knowledge base to save into

Implemented in gams::groups::GroupTransient, and gams::groups::GroupFixedList.

Member Data Documentation

◆ knowledge_

madara::knowledge::KnowledgeBase* gams::groups::GroupBase::knowledge_
mutableprotected

The knowledge base to use as a data plane.

Definition at line 178 of file GroupBase.h.

◆ prefix_

std::string gams::groups::GroupBase::prefix_
protected

the prefix for the group

Definition at line 183 of file GroupBase.h.


The documentation for this class was generated from the following file: