NuriaProject Framework  0.1
The NuriaProject Framework
Public Slots | Public Member Functions | Protected Member Functions | List of all members
Nuria::AbstractSessionManager Class Referenceabstract

Interface for a session manager. More...

#include <abstractsessionmanager.hpp>

Inheritance diagram for Nuria::AbstractSessionManager:
Nuria::SessionManager

Public Slots

virtual void removeSession (const QByteArray &id)=0
 

Public Member Functions

 AbstractSessionManager (QObject *parent=nullptr)
 
virtual Session create ()
 
virtual bool exists (const QByteArray &id) const =0
 
virtual Session get (const QByteArray &id)=0
 

Protected Member Functions

Session createSession (const QByteArray &id)
 
virtual QByteArray generateNewId ()
 

Detailed Description

Interface for a session manager.

The abstract session manager provides a common interface for session managment. Sessions are uniquely named by their id, which is assigned by a session manager. The id itself should only contain printable ASCII symbols like characters or digits. Please note that session manager implementation may choose to obey or not obey this rule.

See SessionManager for a general purpose in-memory session manager.

See also
Session
SessionManager
Management of sessions
It's important to know that sessions are not stored into the session managers back-end (Which is defined by implementing AbstractSessionManager) immediately. Instead, sessions use a dirty flag. Implementations should keep a list of all currently used sessions and iterate over it at some point, checking the dirty flags of all sessions and eventually writing changed ones into some kind of storage engine.

As this list itself holds a reference to the session, it'd be never cleard from memory. To counter this, you can use Session::refCount() to see if the session held inside the manager itself is the last reference that's left, enabling the manager to clear sessions which are no longer needed.

Member Function Documentation

virtual Session Nuria::AbstractSessionManager::create ( )
virtual

Creates a new session with an unique id.

The default implementation does so by calling get() using a new id from generateNewId().

Session Nuria::AbstractSessionManager::createSession ( const QByteArray &  id)
protected

Creates the actual session object with a given id.

virtual bool Nuria::AbstractSessionManager::exists ( const QByteArray &  id) const
pure virtual

Returns true if the session id is known by the manager.

Implemented in Nuria::SessionManager.

virtual QByteArray Nuria::AbstractSessionManager::generateNewId ( )
protectedvirtual

Generate a new unique session id.

The default implementation uses UUIDs and thus should be globally unique.

Note
This is only guaranteed to be unique to the specific manager.
virtual Session Nuria::AbstractSessionManager::get ( const QByteArray &  id)
pure virtual

Fetches the session id. If no session id is known, a new one with that id will be created instead.

Warning
It is possible that an invalid session will be generated, e.g. when the SessionManager is for some reason unable to fetch or create a real session. In this case the session will not be saved or fetched later on, but will still function for data storage.

Implemented in Nuria::SessionManager.

virtual void Nuria::AbstractSessionManager::removeSession ( const QByteArray &  id)
pure virtualslot

Removes the session id from the manager.


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