Example #1
0
id_t Voting::duplicated(const Vote &vote)
const
{
	const auto pit(chanidx.equal_range(vote.get_chan_name()));
	for(auto it(pit.first); it != pit.second; ++it)
	{
		const auto id(it->second);
		const auto vit(votes.find(id));
		if(vit == votes.end())
			continue;

		const auto &existing(*vit->second);
		if(vote.get_id() == existing.get_id())
			continue;

		if(vote.get_type() != existing.get_type())
			continue;

		if(!boost::iequals(vote.get_issue(),existing.get_issue()))
			continue;

		return existing.get_id();
	};

	return 0;
}
Example #2
0
void Voting::call_finish(Vote &vote)
noexcept try
{
	vote.finish();
}
catch(const std::exception &e)
{
	std::stringstream err;
	err << "An internal error occurred in Vote::finish(): " << e.what() << ".";

	std::cerr << "[Voting]: \033[1;31m" << err.str() << "\033[0m" << std::endl;

	const auto &chans(get_chans());
	if(chans.has(vote.get_chan_name()))
	{
		Chan &chan(vote.get_chan());
		chan << err.str() << chan.flush;
	}
}