~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/srv/csm/shl/SessionSet.hpp

  • Committer: Package Import Robot
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2015-07-11 02:00:35 UTC
  • mfrom: (10.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150711020035-2nhpztq7s15qyc0v
Tags: 2.5.1-1
* New upstream release. (Closes: #789968)
* Update debian/control.
  - Update Standards-Version to 3.9.6.
* Add support mips64(el) and ppc64el. (Closes: #741508, #748146)
* Add patches/support-gcc-5.x.patch. (Closes: #777767)
  - Fix build with gcc-5.x.
* Add patches/Disable-NET0001.als.patch.
  - Disable test of NET0001.als.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ---------------------------------------------------------------------------
 
2
// - SessionSet.hpp                                                          -
 
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.                  -
 
7
// -                                                                         -
 
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
// ---------------------------------------------------------------------------
 
16
 
 
17
#ifndef  AFNIX_SESSIONSET_HPP
 
18
#define  AFNIX_SESSIONSET_HPP
 
19
 
 
20
#ifndef  AFNIX_SESSION_HPP
 
21
#include "Session.hpp"
 
22
#endif
 
23
 
 
24
#ifndef  AFNIX_HASHTABLE_HPP
 
25
#include "HashTable.hpp"
 
26
#endif
 
27
 
 
28
namespace afnix {
 
29
 
 
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
 
38
 
 
39
  class SessionSet : public Object {
 
40
  private:
 
41
    /// the hash table
 
42
    HashTable d_hash;
 
43
 
 
44
  public:
 
45
    /// create an empty set
 
46
    SessionSet (void);
 
47
 
 
48
    /// @return the class name
 
49
    String repr (void) const;
 
50
 
 
51
    /// reset this session set
 
52
    virtual void reset (void);
 
53
 
 
54
    /// @return the number of session
 
55
    virtual long length (void) const;
 
56
 
 
57
    /// @return true if the session set is empty
 
58
    virtual bool empty (void) const;
 
59
 
 
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;
 
63
 
 
64
    /// add a session object
 
65
    /// @param sobj the session object
 
66
    virtual void add (Session* sobj);
 
67
 
 
68
    /// get a session by index
 
69
    /// @param idx the session index
 
70
    virtual Session* get (const long idx) const;
 
71
 
 
72
    /// locate a session by hid
 
73
    /// @param hid the session hash id to find
 
74
    virtual Session* lookup (const String& hid) const;
 
75
 
 
76
    /// remove a session by hid
 
77
    /// @param hid the session hash id to remove
 
78
    virtual void remove (const String& hid);
 
79
 
 
80
  private:
 
81
    // make the copy constructor private
 
82
    SessionSet (const SessionSet&);
 
83
    // make the assignment operator private
 
84
    SessionSet& operator = (const SessionSet&);
 
85
 
 
86
  public:
 
87
    /// create a new object in a generic way
 
88
    /// @param argv the argument vector
 
89
    static Object* mknew (Vector* argv);
 
90
 
 
91
    /// @return true if the given quark is defined
 
92
    bool isquark (const long quark, const bool hflg) const;
 
93
 
 
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,
 
100
                   Vector* argv);
 
101
  };
 
102
}
 
103
 
 
104
#endif