NuriaProject Framework  0.1
The NuriaProject Framework
Public Member Functions | Friends | List of all members
Nuria::Session Class Reference

A data storage managed by an AbstractSessionManager. More...

#include <session.hpp>

Public Member Functions

 Session ()
 
 Session (const Session &other)
 
 ~Session ()
 
bool contains (const QString &key) const
 
QByteArray id () const
 
bool isDirty () const
 
bool isValid () const
 
AbstractSessionManagermanager () const
 
void markClean ()
 
void markDirty ()
 
Sessionoperator= (const Session &other)
 
QVariant & operator[] (const QString &key)
 
QVariant operator[] (const QString &key) const
 
int refCount () const
 
void remove ()
 
QVariant value (const QString &key) const
 

Friends

class AbstractSessionManager
 
bool operator!= (const Session &a, const Session &b)
 
bool operator== (const Session &a, const Session &b)
 

Detailed Description

A data storage managed by an AbstractSessionManager.

A Session is a key-value-store for persistent storage of session data. Sessions are managed by an AbstractSessionManager and are object to its storage policy.

Note
This structure is explicitly-shared.
Sessions can be compared for (in)equality.

Constructor & Destructor Documentation

Nuria::Session::Session ( )

Creates an invalid session.

Nuria::Session::Session ( const Session other)

Copy constructor.

Nuria::Session::~Session ( )

Destructor.

Member Function Documentation

bool Nuria::Session::contains ( const QString &  key) const

Returns true if there's a value for key.

QByteArray Nuria::Session::id ( ) const

Returns the id used to identify the session in the manager.

bool Nuria::Session::isDirty ( ) const

Returns true if the stored data has changed.

bool Nuria::Session::isValid ( ) const

Returns true if a session is valid.

AbstractSessionManager* Nuria::Session::manager ( ) const

Returns the manager which handles this session.

Warning
If the instance is invalid, nullptr may be returned.
void Nuria::Session::markClean ( )

Marks the session as clean, used to indicate that changed data has been saved.

Warning
This should only be used by a session manager.
void Nuria::Session::markDirty ( )

Marks the session as dirty, which indicates to the associated session manager that this instance should be written back to the manager implementation specific back-end, such as a database.

Session& Nuria::Session::operator= ( const Session other)

Assignment operator.

QVariant& Nuria::Session::operator[] ( const QString &  key)

Returns the value known as key. If there's no value for key yet, a invalid QVariant will be inserted and the reference to it returned.

The session will be marked dirty.

See also
markDirty value
QVariant Nuria::Session::operator[] ( const QString &  key) const

Same as value().

int Nuria::Session::refCount ( ) const

Returns the reference count of this session instance. The reference count indicates how many other session instances are in the application pointing to the same data, including this instance itself. If this method returns 1, then this is the only instance left.

See also
AbstractSessionManager
void Nuria::Session::remove ( )

Removes the session from the manager.

QVariant Nuria::Session::value ( const QString &  key) const

Returns the value known as key. If there's no value for key, then a invalid QVariant is returned which is not inserted into the internal storage. The dirty flag is not changed by this method.


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