GAMS  1.4.0
ElectionFactoryRepository.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_ELECTIONS_ELECTION_FACTORY_REPOSITORY_H_
55 #define _GAMS_ELECTIONS_ELECTION_FACTORY_REPOSITORY_H_
56 
57 #include <vector>
58 #include <string>
59 #include <map>
60 
61 #include "madara/knowledge/KnowledgeBase.h"
62 #include "ElectionFactory.h"
63 
64 namespace gams
65 {
66  namespace elections
67  {
71  typedef std::map <ElectionType, ElectionFactory *> ElectionFactoryMap;
72 
77  {
78  public:
85  const std::string & agent_prefix,
86  madara::knowledge::KnowledgeBase * knowledge = 0);
87 
92 
99  void add (ElectionType type,
100  ElectionFactory * factory);
101 
107  ElectionBase * create (const std::string & election_prefix);
108 
115 
120  void set_knowledge (madara::knowledge::KnowledgeBase * knowledge);
121 
126  void set_agent_prefix (const std::string & prefix);
127 
128  protected:
129 
133  void init (void);
134 
136  madara::knowledge::KnowledgeBase * knowledge_;
137 
141  std::string agent_prefix_;
142 
145 
146  };
147  }
148 }
149 
150 #include "ElectionFactoryRepository.inl"
151 
152 #endif // _GAMS_ELECTIONS_ELECTION_FACTORY_REPOSITORY_H_
Copyright(c) 2016 Carnegie Mellon University.
#define GAMS_EXPORT
Definition: GamsExport.h:20
Base class for an election.
Definition: ElectionBase.h:83
A repository for election factories.
ElectionFactoryRepository(const std::string &agent_prefix, madara::knowledge::KnowledgeBase *knowledge=0)
Constructor.
madara::knowledge::KnowledgeBase * knowledge_
knowledge base containing variables
void init(void)
Initializes factories for all supported GAMS elections.
virtual ~ElectionFactoryRepository()
Destructor.
ElectionBase * create(ElectionType type)
Creates an election based on type.
void set_knowledge(madara::knowledge::KnowledgeBase *knowledge)
Sets the knowledge base.
std::string agent_prefix_
self prefix of the agent
void add(ElectionType type, ElectionFactory *factory)
Adds an algorithm factory.
ElectionFactoryMap factory_map_
a mapping of types to election factories
ElectionBase * create(const std::string &election_prefix)
Creates an election based on type.
void set_agent_prefix(const std::string &prefix)
Sets the prefix for the current voting agent.
Base class for an auction factory.
std::map< ElectionType, ElectionFactory * > ElectionFactoryMap
Convenience typedef for a map of types to factories.
madara::knowledge::KnowledgeRecord::Integer ElectionType
convenience typedef for ElectionType
Contains all GAMS-related tools, classes and code.