54 #ifndef _GAMS_ELECTIONS_ELECTION_BASE_H_ 55 #define _GAMS_ELECTIONS_ELECTION_BASE_H_ 61 #include "madara/knowledge/KnowledgeBase.h" 62 #include "madara/knowledge/containers/Map.h" 76 typedef std::map <std::string,
92 const std::string & agent_prefix =
"",
93 madara::knowledge::KnowledgeBase * knowledge = 0);
105 virtual bool has_voted (
const std::string & agent_prefix);
111 virtual void get_votes (CandidateVotes & results);
118 virtual void get_votes (
125 virtual void set_agent_prefix (
const std::string & prefix);
131 virtual void set_election_prefix (
const std::string & prefix);
137 virtual void set_knowledge_base (
138 madara::knowledge::KnowledgeBase * knowledge);
143 virtual void sync (
void);
149 const std::string & get_agent_prefix (
void)
const;
155 const std::string & get_election_prefix (
void)
const;
163 void vote (
const std::string & candidate,
int votes = 1);
171 virtual void vote (
const std::string & agent,
172 const std::string & candidate,
int votes = 1);
180 virtual CandidateList get_leaders (
int num_leaders = 1) = 0;
186 virtual void advance_round (
void);
192 int get_round (
void)
const;
198 virtual void reset_round (
void);
206 void reset_votes_pointer (
void);
231 madara::knowledge::containers::Map
votes_;
236 #include "ElectionBase.inl" 238 #endif // _GAMS_ELECTIONS_ELECTION_BASE_H_ Copyright (c) 2016 Carnegie Mellon University.
Copyright (c) 2016 Carnegie Mellon University.
std::map< std::string, madara::knowledge::KnowledgeRecord::Integer > CandidateVotes
candidate vote tally
madara::knowledge::KnowledgeBase * knowledge_
The knowledge base to use as a data plane.
madara::knowledge::containers::Map votes_
convenience class for bids
std::string election_prefix_
the prefix for the election
Contains all GAMS-related tools, classes and code.
std::vector< std::string > CandidateList
list of candidates
Base class for a group of agents.
int round_
the election round in a multi-round election
std::string agent_prefix_
self prefix of the agent
Base class for an election.