Prioritizer¶
This page describes the class Prioritizer
The class Prioritizer
is used to manage an SPopulation’s actions based on their priority level.
In QHG an action with lower priority level is executed before an action with a higher priority level (cf. Actions and Priorities).
- Code:
Type Definitions¶
typedef std::map<uint, std::vector< Action<A>* > > actlist;
typedef std::map<std::string, Action<A>* > namelist;
actlist
is a map associating a vector of actions o a priority level.namelist
is a map associating an action to a name.Public Methods¶
constructor
¶
Prioritizer();
The constructor does nothing.
destructor
¶
virtual ~Prioritizer() {};
The destructor does nothing.
setPrio
¶
virtual int setPrio(uint iPrio, std::string name);
iPrio
Priority level.
name
Name of the action tpo be associated with the priotiy level.
Aassociates a names with a prority level. An action with this name must have prevrioously been registered with a call to
addAction()
.
addAction
¶
virtual int addAction(Action<A> *act);
act
Pointer to action to be registered.
removeAction
¶
virtual int removeAction(std::string name);
name
Name of action to be removed.
hasAction`¶
virtual bool hasAction(std::string name);
name
Name of action to check.
Returns true if an action with this name exists.
hasParam
¶
virtual bool hasParam(std::string name);
name
Name of attribute to check.
Returns true if one or more actions have an attribute with the specified name.
getMaxPrio
¶
virtual uint getMaxPrio();
Returns the highest priority level.
getPrios
¶
virtual uint getPrios( std::set<uint> &vPrios);
vPrios
A vector to hold the priority levels of the registered actions.
Fills the provided vector with the priority levels of the registered actions.
Returns the number of elements in the vector.
getNumActionsForPrio
¶
uint getNumActionsForPrio(uint iPrio);
iPrio
Priority level for which to count the actions.
Returns the number of actions registered for this priority level.
getAction
¶
Action<A> *getAction(int iPrio, int iWhich);
iPrio
Priority level of interest.
iWhich
Index of the wanted action in the list of registered actions
Returns the action at position iWhich
in the vector associated with the priority level.
extractActionParamsQDF
¶
int extractActionParamsQDF(hid_t hSpeciesGroup);
hSpeciesGroup
HDF5 handle for a species group.
Calls the extractAttributesQDF()
method for all registered agents.
writeActionParamsQDF
¶
int writeActionParamsQDF(hid_t hSpeciesGroup);
hSpeciesGroup
HDF5 handle for a species group.
Calls the writeAttributesQDF()
method for all registered agents.
getActionAttributes
¶
int getActionAttributes(const modulemap &mModules);
mModules
A modulemap holding actions and their attributes.
Sets the attribute values for all actions found in mModules
.
dumpActionStatesQDF
¶
int dumpActionStatesQDF(hid_t hSpeciesGroup);
hSpeciesGroup
HDF5 handle for a species group.
Dumps the states of all registered actions to the specified species group.
restoreActionStatesQDF
¶
int restoreActionStatesQDF(hid_t hSpeciesGroup); // for qdf
Restores the states of all registered actions fromthe specified species grouo.
modifyAttribute
¶
int modifyAttribute(const std::string sAttrName, double dValue);
sAttrName
Name of attribute to change.
dValue
New value for attribute.
Loops through registered actions until one has an attribute with the specified name. The attribute wiil be set to the new value.
isEqual
¶
bool isEqual(Prioritizer<A> *pP, bool bStrict);
pP
Prooritizer to compare this with.
bStrict
Strict comparison if true.
Returns true if pP
is equal to this. Two Prioritizer
objects are equal, if they have the same actions with the same values.
showAttributes
¶
void showAttributes();
Displays the attributes of all registerd actions.