Classes | Public Member Functions

HttpSession Class Reference

This class stores data for a single HTTP session. More...

#include <httpsession.h>

List of all members.

Classes

struct  HttpSessionData

Public Member Functions

 HttpSession (bool canStore=false)
 Constructor.
 HttpSession (const HttpSession &other)
 Copy constructor.
HttpSessionoperator= (const HttpSession &other)
 Copy operator.
virtual ~HttpSession ()
 Destructor.
QByteArray getId () const
 Get the unique ID of this session.
bool isNull () const
 Null sessions cannot store data.
void set (const QByteArray &key, const QVariant &value)
 Set a value.
void remove (const QByteArray &key)
 Remove a value.
QVariant get (const QByteArray &key) const
 Get a value.
bool contains (const QByteArray &key) const
 Check if a key exists.
QMap< QByteArray, QVariant > getAll () const
 Get a copy of all data stored in this session.
qint64 getLastAccess () const
 Get the timestamp of last access.
void setLastAccess ()
 Set the timestamp of last access, to renew the timeout period.

Detailed Description

This class stores data for a single HTTP session.

A session can store any number of key/value pairs. This class uses implicit sharing for read and write access. This class is thread safe.

See also:
HttpSessionStore should be used to create and get instances of this class.

Definition at line 21 of file httpsession.h.


Constructor & Destructor Documentation

HttpSession::HttpSession ( bool  canStore = false  ) 

Constructor.

Parameters:
canStore The session can store data, if this parameter is true. Otherwise all calls to set() and remove() do not have any effect.

Definition at line 11 of file httpsession.cpp.

HttpSession::HttpSession ( const HttpSession other  ) 

Copy constructor.

Creates another HttpSession object that shares the data of the other object.

Definition at line 26 of file httpsession.cpp.

HttpSession::~HttpSession (  )  [virtual]

Destructor.

Detaches from the shared data.

Definition at line 65 of file httpsession.cpp.


Member Function Documentation

bool HttpSession::contains ( const QByteArray &  key  )  const

Check if a key exists.

This method is thread safe.

Definition at line 121 of file httpsession.cpp.

QVariant HttpSession::get ( const QByteArray &  key  )  const

Get a value.

This method is thread safe.

Definition at line 111 of file httpsession.cpp.

QMap< QByteArray, QVariant > HttpSession::getAll (  )  const

Get a copy of all data stored in this session.

Changes to the session do not affect the copy and vice versa. This method is thread safe.

Definition at line 131 of file httpsession.cpp.

QByteArray HttpSession::getId (  )  const

Get the unique ID of this session.

This method is thread safe.

Definition at line 82 of file httpsession.cpp.

qint64 HttpSession::getLastAccess (  )  const

Get the timestamp of last access.

That is the time when the last HttpSessionStore::getSession() has been called. This method is thread safe.

Definition at line 141 of file httpsession.cpp.

bool HttpSession::isNull (  )  const

Null sessions cannot store data.

All calls to set() and remove() do not have any effect.This method is thread safe.

Definition at line 91 of file httpsession.cpp.

HttpSession & HttpSession::operator= ( const HttpSession other  ) 

Copy operator.

Detaches from the current shared data and attaches to the data of the other object.

Definition at line 38 of file httpsession.cpp.

void HttpSession::remove ( const QByteArray &  key  ) 

Remove a value.

This method is thread safe.

Definition at line 103 of file httpsession.cpp.

void HttpSession::set ( const QByteArray &  key,
const QVariant &  value 
)

Set a value.

This method is thread safe.

Definition at line 95 of file httpsession.cpp.

void HttpSession::setLastAccess (  ) 

Set the timestamp of last access, to renew the timeout period.

Called by HttpSessionStore::getSession(). This method is thread safe.

Definition at line 152 of file httpsession.cpp.


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