1
// ---------------------------------------------------------------------------
3
// - afnix:csm service - session set class definition -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2015 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_SESSIONSET_HPP
18
#define AFNIX_SESSIONSET_HPP
20
#ifndef AFNIX_SESSION_HPP
21
#include "Session.hpp"
24
#ifndef AFNIX_HASHTABLE_HPP
25
#include "HashTable.hpp"
30
/// The SessionSet class is a collection of session object organized
31
/// with a hash table, those key is the session hash id. Normally, the
32
/// session object is used to track the user activity. In particular,
33
/// the session time must be carefully monitored in order to close a
34
/// session which has timed-out. Futhermore, for security purpose, the
35
/// session hash id must be carefully generated from the session itself
36
/// but in a way which cannot be guessed from the client side.
37
/// @author amaury darsch
39
class SessionSet : public Object {
45
/// create an empty set
48
/// @return the class name
49
String repr (void) const;
51
/// reset this session set
52
virtual void reset (void);
54
/// @return the number of session
55
virtual long length (void) const;
57
/// @return true if the session set is empty
58
virtual bool empty (void) const;
60
/// check if a session exists by hid
61
/// @param hid the session hash id to validate
62
virtual bool exists (const String& hid) const;
64
/// add a session object
65
/// @param sobj the session object
66
virtual void add (Session* sobj);
68
/// get a session by index
69
/// @param idx the session index
70
virtual Session* get (const long idx) const;
72
/// locate a session by hid
73
/// @param hid the session hash id to find
74
virtual Session* lookup (const String& hid) const;
76
/// remove a session by hid
77
/// @param hid the session hash id to remove
78
virtual void remove (const String& hid);
81
// make the copy constructor private
82
SessionSet (const SessionSet&);
83
// make the assignment operator private
84
SessionSet& operator = (const SessionSet&);
87
/// create a new object in a generic way
88
/// @param argv the argument vector
89
static Object* mknew (Vector* argv);
91
/// @return true if the given quark is defined
92
bool isquark (const long quark, const bool hflg) const;
94
/// apply this object with a set of arguments and a quark
95
/// @param robj the current runnable
96
/// @param nset the current nameset
97
/// @param quark the quark to apply these arguments
98
/// @param argv the arguments to apply
99
Object* apply (Runnable* robj, Nameset* nset, const long quark,