Orxonox: orxonox::NotificationQueue Class Reference

# orxonox::NotificationQueue Class Reference

Displays Notifications from specific senders. Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.). More...

`#include <src/orxonox/overlays/notifications/NotificationQueue.h>`

Inheritance diagram for orxonox::NotificationQueue:

List of all members.

## Public Member Functions

int | getDisplayTime () const
| Returns the time interval the Notification is displayed.
const std::string & | getFont () const
| Returns the font used to display the Notifications.
float | getFontSize () const
| Returns the font size used to display the Notifications.
int | getMaxSize () const
| Returns the maximum number of Notifications displayed.
int | getNotificationLength () const
| Returns the maximum length in characters a Notification message is allowed to have.
const Vector2 & | getPosition () const
| Returns the position of the NotificationQueue.
int | getSize () const
| Returns the current number of Notifications displayed.
bool | getTargets (std::string *string) const
| Returns a string consisting of the concatination of the targets.
const std::set< std::string > & | getTargetsSet ()
| Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
| NotificationQueue (BaseObject *creator)
| Constructor. Creates and initializes the object.
void | scroll (const Vector2 pos)
| Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
void | setPosition (Vector2 pos)
| Sets the position of the NotificationQueue.
virtual void | tick (float dt)
| To update from time to time.
void | update (Notification *notification, const std::time_t &time)
| Adds a Notification to the queue.
void | update (void)
| Updates the queue.
virtual void | XMLPort (Element &xmlElement, XMLPort::Mode mode)
| Method for creating a NotificationQueue object through XML.
virtual | ~NotificationQueue ()
| Destructor.

## Private Member Functions

void | addNotification (Notification *notification, const std::time_t &time)
| Add a notification to the queue.
void | clear (void)
| Clear the queue.
void | initialize (void)
| Initializes the object.
void | positionChanged (void)
| Aligns all the Notifications to the position of the NotificationQueue.
bool | removeContainer (NotificationOverlayContainer *container)
| Remove a container from the queue.
void | setDefaults (void)
| Helper method to set the default values.
bool | setDisplayTime (int time)
| Sets the maximum number of seconds a Notification is displayed.
bool | setFont (const std::string &font)
| Set the font.
bool | setFontSize (float size)
| Set the font size.
bool | setMaxSize (int size)
| Sets the maximum number of displayed Notifications.
bool | setNotificationLength (int length)
| Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
bool | setTargets (const std::string &targets)
| Set the targets of this queue.

## Private Attributes

std::multiset < NotificationOverlayContainer *, NotificationOverlayContainerCompare > | containers_
| Multiset, because the ordering is based on, not necessarily unique, timestamps.
int | displayTime_
| The time a Notification is displayed.
std::string | font_
| The font.
float | fontSize_
| The font size.
int | maxSize_
| The maximal number of Notifications displayed.
int | notificationLength_
| The maximal number of characters a Notification-message is allowed to have.
std::map< Notification *, NotificationOverlayContainer * > | overlays_
| Mapping notifications to their corresponding overlay containers, for easier association and finding.
Vector2 | position_
| The position of the NotificationQueue.
int | size_
| The number of Notifications displayed.
std::set< std::string > | targets_
| The targets the Queue displays Notifications of.
float | tickTime_
| Helper variable, to not have to check for overlays that have been displayed too long, every tick.
NotificationOverlayContainer | timeLimit_
| Helper object to check against to determine whether Notifications have expired.

## Static Private Attributes

static const int | DEFAULT_DISPLAY_TIME = 30
| The default display time.
static const std::string | DEFAULT_FONT = "VeraMono"
| The default font.
static const float | DEFAULT_FONT_SIZE = 0.025f
| The default font size.
static const int | DEFAULT_LENGTH = 64
| The default maximum number of Notifications displayed.
static const Vector2 | DEFAULT_POSITION = Vector2(0.0,0.0)
| the default position.
static const int | DEFAULT_SIZE = 5
| The default maximum number of Notifications displayed.

## Detailed Description

Displays Notifications from specific senders. Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.).

Creating a NotificationQueue through XML goes as follows: <NotificationQueue name = "SuperQueue" //Name of your OverlayQueue. maxSize = "5" //The maximum size of Notifications displayed. notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 5) displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30) targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.) font = "VeraMono" //The font (Default is VeraMono) fontSize = '0.4' //The font size. (Default is 0.025) position = "0.0, .0.0" //The position of the NotificationQueue. (Default is 0.0,0.0) />

Author:
  Damian 'Mozork' Frick

## Constructor & Destructor Documentation

orxonox::NotificationQueue::NotificationQueue | ( | BaseObject * | creator | ) |

Constructor. Creates and initializes the object.

References initialize(), and RegisterObject.

orxonox::NotificationQueue::~NotificationQueue | ( |  | ) | `[virtual]`

Destructor.

References clear(), and targets_.

## Member Function Documentation

void orxonox::NotificationQueue::addNotification | ( | Notification * | notification,
|  | const std::time_t & | time |
| ) |  |  | `[private]`

Add a notification to the queue.

Adds a Notification, to the queue. It inserts it into the storage containers, creates an corresponding overlay and a container.

Parameters:

  | notification | The Notification.
  | time | The time.

References orxonox::OverlayGroup::addElement(), containers_, getFontSize(), getSize(), orxonox::NotificationOverlayContainer::name, orxonox::NotificationOverlayContainer::notification, orxonox::NotificationOverlayContainer::overlay, overlays_, orxonox::OrxonoxOverlay::scroll(), size_, orxonox::NotificationOverlayContainer::time, and orxonox::MT_Type::Vector2.

Referenced by update().

void orxonox::NotificationQueue::clear | ( | void |  | ) | `[private]`

Clear the queue.

Clears the queue by removing all containers.

References containers_, and removeContainer().

Referenced by update(), and ~NotificationQueue().

int orxonox::NotificationQueue::getDisplayTime | ( |  | ) | const`[inline]`

Returns the time interval the Notification is displayed.

Returns:
  Returns the display time.

Referenced by XMLPort().

const std::string& orxonox::NotificationQueue::getFont | ( |  | ) | const`[inline]`

Returns the font used to display the Notifications.

Returns:
  Returns the font.

Referenced by orxonox::NotificationOverlay::defineOverlay(), and XMLPort().

float orxonox::NotificationQueue::getFontSize | ( |  | ) | const`[inline]`

Returns the font size used to display the Notifications.

Returns:
  Returns the font size.

Referenced by addNotification(), orxonox::NotificationOverlay::defineOverlay(), positionChanged(), tick(), update(), and XMLPort().

int orxonox::NotificationQueue::getMaxSize | ( |  | ) | const`[inline]`

Returns the maximum number of Notifications displayed.

Returns:
  Returns maximum size.

Referenced by update(), and XMLPort().

int orxonox::NotificationQueue::getNotificationLength | ( |  | ) | const`[inline]`

Returns the maximum length in characters a Notification message is allowed to have.

Returns:
  Returns the maximum Notification length.

Referenced by orxonox::NotificationOverlay::clipMessage(), and XMLPort().

const Vector2& orxonox::NotificationQueue::getPosition | ( |  | ) | const`[inline]`

Returns the position of the NotificationQueue.

Returns:
  Returns the position.

Referenced by orxonox::NotificationOverlay::defineOverlay(), positionChanged(), and XMLPort().

int orxonox::NotificationQueue::getSize | ( | void |  | ) | const`[inline]`

Returns the current number of Notifications displayed.

Returns:
  Returns the size of the queue.

Referenced by addNotification(), and update().

bool orxonox::NotificationQueue::getTargets | ( | std::string * | string | ) | const

Returns a string consisting of the concatination of the targets.

Produces all targets concatinated as string, with kommas (',') as seperators.

Parameters:

  | string | Pointer to a string which will be used by the method to fill with the concatination of the targets.

Returns:
  Returns true if successful.

< Iterate through the set of targets.

References COUT, and targets_.

Referenced by XMLPort().

const std::set<std::string>& orxonox::NotificationQueue::getTargetsSet | ( |  | ) | `[inline]`

Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.

Returns:
  Retuns a set of string holding the different targets.

Referenced by orxonox::NotificationManager::registerQueue().

void orxonox::NotificationQueue::initialize | ( | void |  | ) | `[private]`

Initializes the object.

Initializes the object. Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager.

References orxonox::NotificationManager::getInstance(), orxonox::NotificationManager::registerQueue(), size_, and tickTime_.

Referenced by NotificationQueue().

void orxonox::NotificationQueue::positionChanged | ( | void |  | ) | `[private]`

Aligns all the Notifications to the position of the NotificationQueue.

< Set the position for each overlay.

References containers_, getFontSize(), getPosition(), and orxonox::MT_Type::Vector2.

bool orxonox::NotificationQueue::removeContainer | ( | NotificationOverlayContainer * | container | ) | `[private]`

Remove a container from the queue.

Removes a container from the queue.

Parameters:

  | container | A pointer to the container.

Returns:
  Returns true if successful.

< You cannot remove anything if the queue is empty.

References containers_, orxonox::NotificationOverlayContainer::notification, orxonox::NotificationOverlayContainer::overlay, overlays_, orxonox::OverlayGroup::removeElement(), and size_.

Referenced by clear(), tick(), and update().

void orxonox::NotificationQueue::scroll | ( | const Vector2 | pos | ) |

Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.

Parameters:

  | pos | The vector the NotificationQueue is scrolled.

< Scroll each overlay.

References overlays_.

Referenced by tick(), and update().

void orxonox::NotificationQueue::setDefaults | ( | void |  | ) | `[private]`

Helper method to set the default values.

Sets the defaults.

References orxonox::NotificationManager::ALL, DEFAULT_DISPLAY_TIME, DEFAULT_FONT, DEFAULT_FONT_SIZE, DEFAULT_LENGTH, DEFAULT_POSITION, DEFAULT_SIZE, setDisplayTime(), setFont(), setFontSize(), setMaxSize(), setNotificationLength(), setPosition(), and setTargets().

Referenced by XMLPort().

bool orxonox::NotificationQueue::setDisplayTime | ( | int | time | ) | `[private]`

Sets the maximum number of seconds a Notification is displayed.

Parameters:

  | time | The number of seconds the Notifications is displayed.

Returns:
  Returns true if successful.

References displayTime_, and update().

Referenced by setDefaults(), and XMLPort().

bool orxonox::NotificationQueue::setFont | ( | const std::string & | font | ) | `[private]`

Set the font.

Sets the font.

Parameters:

  | font | The font.

Returns:
  Returns true if successful.

< Set the font for each overlay.

References font_, and overlays_.

Referenced by setDefaults(), and XMLPort().

bool orxonox::NotificationQueue::setFontSize | ( | float | size | ) | `[private]`

Set the font size.

Sets the font size.

Parameters:

  | size | The font size.

Returns:
  Returns true if successful.

< Set the font size for each overlay.

References fontSize_, and overlays_.

Referenced by setDefaults(), and XMLPort().

bool orxonox::NotificationQueue::setMaxSize | ( | int | size | ) | `[private]`

Sets the maximum number of displayed Notifications.

Parameters:

  | size | The size to be set.

Returns:
  Returns true if successful.

References maxSize_, and update().

Referenced by setDefaults(), and XMLPort().

bool orxonox::NotificationQueue::setNotificationLength | ( | int | length | ) | `[private]`

Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.

Parameters:

  | length | The length to be set.

Returns:
  Returns true if successful.

References notificationLength_, and update().

Referenced by setDefaults(), and XMLPort().

void orxonox::NotificationQueue::setPosition | ( | Vector2 | pos | ) | `[inline]`

Sets the position of the NotificationQueue.

Parameters:

  | pos | The position.

Referenced by setDefaults(), and XMLPort().

bool orxonox::NotificationQueue::setTargets | ( | const std::string & | targets | ) | `[private]`

Set the targets of this queue.

Sets the targets of the queue. The targets are the senders whose Notifications are displayed in this queue.

Parameters:

  | targets | Accepts a string of targets, each seperated by commas (','), spaces are ignored.

Returns:
  Returns true if successful.

< Go through the string, character by character until the end is reached.

References targets_.

Referenced by setDefaults(), and XMLPort().

void orxonox::NotificationQueue::tick | ( | float | dt | ) | `[virtual]`

To update from time to time.

Updates the queue from time to time.

Parameters:

  | dt | The time interval that has passed since the last tick.

< Add the time interval that has passed to the time counter.

< If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.

< Container containig the current time.

< Iterate through all elements whose creation time is smaller than the current time minus the display time.

< Reset time counter.

Implements orxonox::Tickable.

References containers_, displayTime_, getFontSize(), removeContainer(), scroll(), tickTime_, orxonox::NotificationOverlayContainer::time, timeLimit_, and orxonox::MT_Type::Vector2.

void orxonox::NotificationQueue::update | ( | Notification * | notification,
|  | const std::time_t & | time |
| ) |  |  |

Adds a Notification to the queue.

Updates the NotificationQueue by adding an new Notification.

Parameters:

  | notification | Pointer to the Notification.
  | time | The time the Notification was sent.

References addNotification(), containers_, COUT, getFontSize(), getMaxSize(), getSize(), removeContainer(), scroll(), and orxonox::MT_Type::Vector2.

void orxonox::NotificationQueue::update | ( | void |  | ) |

Updates the queue.

Updates the NotificationQueue. Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting the in the queue.

< Get the Notifications sent in the interval form now to minus the display time.

> Add all Notifications.

References addNotification(), clear(), COUT, displayTime_, and orxonox::NotificationManager::getInstance().

Referenced by orxonox::NotificationManager::registerQueue(), setDisplayTime(), setMaxSize(), and setNotificationLength().

void orxonox::NotificationQueue::XMLPort | ( | Element & | xmlElement,
|  | XMLPort::Mode | mode |
| ) |  |  | `[virtual]`

Method for creating a NotificationQueue object through XML.

Reimplemented from orxonox::OverlayGroup.

References COUT, getDisplayTime(), getFont(), getFontSize(), getMaxSize(), getNotificationLength(), getPosition(), getTargets(), setDefaults(), setDisplayTime(), setFont(), setFontSize(), setMaxSize(), setNotificationLength(), setPosition(), setTargets(), SUPER, and XMLPortParam.

## Member Data Documentation

std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> orxonox::NotificationQueue::containers_`[private]`

Multiset, because the ordering is based on, not necessarily unique, timestamps.

Referenced by addNotification(), clear(), positionChanged(), removeContainer(), tick(), and update().

const int orxonox::NotificationQueue::DEFAULT_DISPLAY_TIME = 30`[static, private]`

The default display time.

Referenced by setDefaults().

const std::string orxonox::NotificationQueue::DEFAULT_FONT = "VeraMono"`[static, private]`

The default font.

Referenced by setDefaults().

const float orxonox::NotificationQueue::DEFAULT_FONT_SIZE = 0.025f`[static, private]`

The default font size.

Referenced by setDefaults().

const int orxonox::NotificationQueue::DEFAULT_LENGTH = 64`[static, private]`

The default maximum number of Notifications displayed.

Referenced by setDefaults().

const Vector2 orxonox::NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0)`[static, private]`

the default position.

Referenced by setDefaults().

const int orxonox::NotificationQueue::DEFAULT_SIZE = 5`[static, private]`

The default maximum number of Notifications displayed.

Referenced by setDefaults().

int orxonox::NotificationQueue::displayTime_`[private]`

The time a Notification is displayed.

Referenced by setDisplayTime(), tick(), and update().

std::string orxonox::NotificationQueue::font_`[private]`

The font.

Referenced by setFont().

float orxonox::NotificationQueue::fontSize_`[private]`

The font size.

Referenced by setFontSize().

int orxonox::NotificationQueue::maxSize_`[private]`

The maximal number of Notifications displayed.

Referenced by setMaxSize().

int orxonox::NotificationQueue::notificationLength_`[private]`

The maximal number of characters a Notification-message is allowed to have.

Referenced by setNotificationLength().

std::map<Notification*, NotificationOverlayContainer*> orxonox::NotificationQueue::overlays_`[private]`

Mapping notifications to their corresponding overlay containers, for easier association and finding.

Referenced by addNotification(), removeContainer(), scroll(), setFont(), and setFontSize().

Vector2 orxonox::NotificationQueue::position_`[private]`

The position of the NotificationQueue.

int orxonox::NotificationQueue::size_`[private]`

The number of Notifications displayed.

Referenced by addNotification(), initialize(), and removeContainer().

std::set<std::string> orxonox::NotificationQueue::targets_`[private]`

The targets the Queue displays Notifications of.

Referenced by getTargets(), setTargets(), and ~NotificationQueue().

float orxonox::NotificationQueue::tickTime_`[private]`

Helper variable, to not have to check for overlays that have been displayed too long, every tick.

Referenced by initialize(), and tick().

NotificationOverlayContainer orxonox::NotificationQueue::timeLimit_`[private]`

Helper object to check against to determine whether Notifications have expired.

Referenced by tick().

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

- src/orxonox/overlays/notifications/NotificationQueue.h
- src/orxonox/overlays/notifications/NotificationQueue.cc