hoa_global::GlobalEventGroup Class Reference

A container that manages the occurences of several related game events. More...

#include <global.h>

Collaboration diagram for hoa_global::GlobalEventGroup:

Collaboration graph
[legend]
List of all members.
 GlobalEventGroup (const GlobalEventGroup &geg)
 
Note:
Copy constructor and assignment operator kept private to prevent external code creating their own GlobalEventGroup objects

GlobalEventGroupoperator= (const GlobalEventGroup &geg)

Public Member Functions

void AddNewEvent (const std::string &event_name, int32 event_value=0)
 Adds a new event to the group.
bool DoesEventExist (const std::string &event_name)
 Queries whether or not an event of a given name exists in the group.
int32 GetEvent (const std::string &event_name)
 Retrieves the value of a specific event in the group.
std::string GetGroupName () const
 Returns a copy of the name of this group.
uint32 GetNumberEvents () const
 Returns the number of events currently stored within the group.
void SetEvent (const std::string &event_name, int32 event_value)
 Sets the value for an existing event.
 ~GlobalEventGroup ()

Private Member Functions

 GlobalEventGroup (const std::string &group_name)
 The class constructor is private because groups may only be created by the GameGlobal class.

Private Attributes

std::map< std::string, int32_events
 The map container for all the events in the group The string is the name of the event, which should be unique to the group. The integer value represents the event's status and can take on multiple meanings depending on the event's context.
std::string _group_name
 The name given to this group of events.

Friends

class GameGlobal

Detailed Description

A container that manages the occurences of several related game events.

****************************************************************************

Events in Allacrost are nothing more than a string, integer pair. The string represents the name of the event while the integer takes on various meanings about the event. One example of an event could be if the player has already seen a certain piece of dialogue, and the integer would be set to zero or non-zero to emulate a boolean value. Another example could be whether the player previous chose option A, B, C, or D when presented with a list of possible actions to take, in which the integer value would represent the option taken.

Because we want to continually look-up whether or not an event has occured, it is not efficient to store all game events in a single container (the larger the number of events, the longer the event search time). Instead, this class collectively represents a group of related events. A typical event group could represent all of the events that occured on a particular map, for instance.

Note:
Only the GameGlobal class may construct objects of this class. There are methods in GameGlobal to create new objects of this class

Definition at line 68 of file global.h.


Constructor & Destructor Documentation

hoa_global::GlobalEventGroup::~GlobalEventGroup (  )  [inline]

Definition at line 72 of file global.h.

hoa_global::GlobalEventGroup::GlobalEventGroup ( const std::string &  group_name  )  [inline, private]

The class constructor is private because groups may only be created by the GameGlobal class.

Parameters:
group_name The name of the group to create (this can not be changed)

Definition at line 124 of file global.h.

hoa_global::GlobalEventGroup::GlobalEventGroup ( const GlobalEventGroup geg  )  [private]

Note:
Copy constructor and assignment operator kept private to prevent external code creating their own GlobalEventGroup objects


Member Function Documentation

void hoa_global::GlobalEventGroup::AddNewEvent ( const std::string &  event_name,
int32  event_value = 0 
)

Adds a new event to the group.

Parameters:
event_name The name of the event to add
event_value The value of the event to add (default value is zero)
Note:
If an event by the given name already exists, the function will abort and not add the new event

Definition at line 46 of file global.cpp.

References _events, _group_name, DoesEventExist(), and hoa_global::GLOBAL_DEBUG.

Referenced by hoa_global::GameGlobal::_LoadEvents().

Here is the call graph for this function:

bool hoa_global::GlobalEventGroup::DoesEventExist ( const std::string &  event_name  )  [inline]

Queries whether or not an event of a given name exists in the group.

Parameters:
event_name The name of the event to check for
Returns:
True if the event name was found in the group, false if it was not

Definition at line 78 of file global.h.

References _events.

Referenced by AddNewEvent().

int32 hoa_global::GlobalEventGroup::GetEvent ( const std::string &  event_name  ) 

Retrieves the value of a specific event in the group.

Parameters:
event_name The name of the event to retrieve
Returns:
The value of the event, or GLOBAL_BAD_EVENT if the event corresponding to the name wasn't found

Definition at line 58 of file global.cpp.

References _events, _group_name, hoa_global::GLOBAL_BAD_EVENT, and hoa_global::GLOBAL_DEBUG.

std::string hoa_global::GlobalEventGroup::GetGroupName (  )  const [inline]

Returns a copy of the name of this group.

Definition at line 107 of file global.h.

References _group_name.

Referenced by hoa_global::GameGlobal::_SaveEvents().

uint32 hoa_global::GlobalEventGroup::GetNumberEvents (  )  const [inline]

Returns the number of events currently stored within the group.

Definition at line 103 of file global.h.

References _events.

GlobalEventGroup& hoa_global::GlobalEventGroup::operator= ( const GlobalEventGroup geg  )  [private]

void hoa_global::GlobalEventGroup::SetEvent ( const std::string &  event_name,
int32  event_value 
)

Sets the value for an existing event.

Parameters:
event_name The name of the event whose value should be changed
event_value The value to set for the event
Note:
If the event by the given name is not found, no change will be made

Definition at line 71 of file global.cpp.

References _events, _group_name, and hoa_global::GLOBAL_DEBUG.


Friends And Related Function Documentation

friend class GameGlobal [friend]

Definition at line 69 of file global.h.


Member Data Documentation

std::map<std::string, int32> hoa_global::GlobalEventGroup::_events [private]

The map container for all the events in the group The string is the name of the event, which should be unique to the group. The integer value represents the event's status and can take on multiple meanings depending on the event's context.

Definition at line 119 of file global.h.

Referenced by hoa_global::GameGlobal::_SaveEvents(), AddNewEvent(), DoesEventExist(), GetEvent(), GetNumberEvents(), and SetEvent().

std::string hoa_global::GlobalEventGroup::_group_name [private]

The name given to this group of events.

Definition at line 112 of file global.h.

Referenced by AddNewEvent(), GetEvent(), GetGroupName(), and SetEvent().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:14:19 2007 for Hero of Allacrost by  doxygen 1.5.1