Base class for an election.
More...
#include <ElectionBase.h>
|
void | reset_votes_pointer (void) |
| calls a reset on the votes_ location in the knowledge base using election_prefix_ + "." + round_. More...
|
|
Base class for an election.
Definition at line 82 of file ElectionBase.h.
gams::elections::ElectionBase::ElectionBase |
( |
const std::string & |
election_prefix = "" , |
|
|
const std::string & |
agent_prefix = "" , |
|
|
madara::knowledge::KnowledgeBase * |
knowledge = 0 |
|
) |
| |
Constructor.
- Parameters
-
election_prefix | the name of the election (e.g. election.leader) |
agent_prefix | the name of this bidder (e.g. agent.0) |
knowledge | the knowledge base to use for syncing |
virtual gams::elections::ElectionBase::~ElectionBase |
( |
| ) |
|
|
virtual |
virtual void gams::elections::ElectionBase::advance_round |
( |
void |
| ) |
|
|
virtual |
Proceeds to the next election round in a multi-round election.
const std::string& gams::elections::ElectionBase::get_agent_prefix |
( |
void |
| ) |
const |
Gets the prefix for the current agent.
- Returns
- the name of this bidding agent (e.g. agent.0)
const std::string& gams::elections::ElectionBase::get_election_prefix |
( |
void |
| ) |
const |
Gets the prefix for the election in the knowledge base.
- Returns
- the name of the election (e.g. election.protectors)
virtual CandidateList gams::elections::ElectionBase::get_leaders |
( |
int |
num_leaders = 1 | ) |
|
|
pure virtual |
int gams::elections::ElectionBase::get_round |
( |
void |
| ) |
const |
Retrieves the round number, usually in a multi-round election.
- Returns
- the agent prefix of the leader of the election
virtual void gams::elections::ElectionBase::get_votes |
( |
CandidateVotes & |
results | ) |
|
|
virtual |
Gets the votes cast in the election.
- Parameters
-
results | the results of the vote |
Gets the votes cast in the election by a specific group of agents.
- Parameters
-
group | the group that is of interest |
results | the results of the vote |
virtual bool gams::elections::ElectionBase::has_voted |
( |
const std::string & |
agent_prefix | ) |
|
|
virtual |
Checks if the agent has voted in this round.
- Parameters
-
agent_prefix | the participating agent's prefix (e.g. agent.0) |
- Returns
- true if the agent is a member of the election
virtual void gams::elections::ElectionBase::reset_round |
( |
void |
| ) |
|
|
virtual |
Resets the round.
- Returns
- the agent prefix of the leader of the election
void gams::elections::ElectionBase::reset_votes_pointer |
( |
void |
| ) |
|
|
protected |
calls a reset on the votes_ location in the knowledge base using election_prefix_ + "." + round_.
virtual void gams::elections::ElectionBase::set_agent_prefix |
( |
const std::string & |
prefix | ) |
|
|
virtual |
Sets the prefix for the current bidding agent.
- Parameters
-
prefix | the name of the agent (e.g. agent.0) |
virtual void gams::elections::ElectionBase::set_election_prefix |
( |
const std::string & |
prefix | ) |
|
|
virtual |
Sets the prefix for the election in the knowledge base.
- Parameters
-
prefix | the name of the election (e.g. election.protectors) |
virtual void gams::elections::ElectionBase::set_knowledge_base |
( |
madara::knowledge::KnowledgeBase * |
knowledge | ) |
|
|
virtual |
Sets the knowledge base.
- Parameters
-
knowledge | the knowledge base to use for syncing |
virtual void gams::elections::ElectionBase::sync |
( |
void |
| ) |
|
|
virtual |
Syncs the election information from the knowledge base.
void gams::elections::ElectionBase::vote |
( |
const std::string & |
candidate, |
|
|
int |
votes = 1 |
|
) |
| |
Votes in the election.
Uses the agent prefix that has been set in this Election as the voter id.
- Parameters
-
candidate | the candidate receiving votes |
votes | the number of votes cast |
virtual void gams::elections::ElectionBase::vote |
( |
const std::string & |
agent, |
|
|
const std::string & |
candidate, |
|
|
int |
votes = 1 |
|
) |
| |
|
virtual |
Bids in the election.
- Parameters
-
agent | the agent prefix who is bidding |
candidate | the candidate receiving votes |
votes | the number of votes cast |
std::string gams::elections::ElectionBase::agent_prefix_ |
|
protected |
std::string gams::elections::ElectionBase::election_prefix_ |
|
protected |
madara::knowledge::KnowledgeBase* gams::elections::ElectionBase::knowledge_ |
|
mutableprotected |
The knowledge base to use as a data plane.
Definition at line 211 of file ElectionBase.h.
int gams::elections::ElectionBase::round_ |
|
protected |
the election round in a multi-round election
Definition at line 226 of file ElectionBase.h.
madara::knowledge::containers::Map gams::elections::ElectionBase::votes_ |
|
protected |
The documentation for this class was generated from the following file: