SDL2lazy
Public Member Functions | Private Attributes | List of all members
SlEventHandler Class Reference

#include <SlEventHandler.h>

Public Member Functions

 SlEventHandler ()
 
 ~SlEventHandler ()
 
 SlEventHandler (const SlEventHandler &)=delete
 
SlEventHandler & operator= (const SlEventHandler &)=delete
 
void addAction (const std::string &key, const std::string &whatToDo, const std::string &spritename, int destination, std::vector< std::string > parameters)
 
void addManipulations (const std::map< std::string, SlManipulation * > &manip)
 
SlManipulation * getManipulation (const std::string &whatToDo)
 
int handleEvent (const SDL_Event &event)
 
void parseEvent (std::ifstream &input)
 
int pollEvent ()
 

Private Attributes

std::map< std::string, SlEventObject > eventActions_
 
std::map< std::string, SlManipulation * > manipulations_
 
SDL_Event event_
 

Detailed Description

Takes a SDL_Event and calls the assigned SlEventObject.

Constructor & Destructor Documentation

SlEventHandler::SlEventHandler ( )

Default constructor

SlEventHandler::~SlEventHandler ( )

Default destructor

SlEventHandler::SlEventHandler ( const SlEventHandler &  )
delete

Delete copy constructor. EventHandler is unique to SlManager and its sprites.

Member Function Documentation

void SlEventHandler::addAction ( const std::string &  key,
const std::string &  whatToDo,
const std::string &  spritename,
int  destination,
std::vector< std::string >  parameters 
)

Creates the SlEventAction based on the parsed input. Creates SlEventObject if it doesn't exist.

void SlEventHandler::addManipulations ( const std::map< std::string, SlManipulation * > &  manip)

Adds the given SlManipulations to manipulations_.

SlManipulation * SlEventHandler::getManipulation ( const std::string &  whatToDo)

Returns specified SlManipulation from manipulations_ based on whatToDo keyword.

Exceptions
std::invalid_argumentif not found.
int SlEventHandler::handleEvent ( const SDL_Event &  event)

The actual event handling, checking what SDL_Event was registered. Limited implimentation.

Return values
1if event was quit.
0otherwise.

< undefined input is ignored.

SlEventHandler& SlEventHandler::operator= ( const SlEventHandler &  )
delete

Deleted, same reason as copy constructor.

void SlEventHandler::parseEvent ( std::ifstream &  input)

Parse configuration file entry. Pattern: key what spritename sprite_destination parameters

int SlEventHandler::pollEvent ( )

Check for events.

Return values
1if event was quit.
0otherwise.

< 0 means don't quit, 1 means quit

Member Data Documentation

SDL_Event SlEventHandler::event_
private

The event used for polling.

std::map<std::string, SlEventObject> SlEventHandler::eventActions_
private

The string is the keyword for the event handling.

std::map<std::string, SlManipulation*> SlEventHandler::manipulations_
private

Contains pointers to all SlSpriteManipulations and SlRenderManipulations


The documentation for this class was generated from the following files: