libassa  3.5.1
IdSet.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // IdSet.h
4 //------------------------------------------------------------------------------
5 // Copyright (c) 1997 by Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 #ifndef ID_SET_H
13 #define ID_SET_H
14 
15 #include <string.h>
16 
17 #include <sys/time.h> /* select(3) */
18 
19 #if defined(Linux) /* select(3) */
20 # include <sys/types.h>
21 # include <unistd.h>
22 #endif
23 
24 #if defined(WIN32)
25 # include <winsock2.h>
26 #endif
27 
28 namespace ASSA {
29 
38 class IdSet
39 {
40 public:
42  IdSet ();
43 
47  int newid ();
48 
52  int recycle (int id_);
53 
57  int currid () const;
58 
59 private:
63 
66  fd_set m_id_set_map;
67 };
68 
69 inline
71 IdSet()
72  : m_next_available_id (0)
73 {
74  ::memset (&m_id_set_map, 0, sizeof (m_id_set_map));
75 }
76 
77 inline int
79 currid() const
80 {
81  return m_next_available_id;
82 }
83 
84 } // end namespace ASSA
85 
86 #endif /* ID_SET_H */
int m_next_available_id
Current id.
Definition: IdSet.h:62
int newid()
Return current id.
Definition: IdSet.cpp:20
IdSet()
Default constructor creates IdSet object with ID equals to 0.
Definition: IdSet.h:71
int recycle(int id_)
Recycle id_.
Definition: IdSet.cpp:54
int currid() const
Get current id.
Definition: IdSet.h:79
fd_set m_id_set_map
Map of all ids.
Definition: IdSet.h:66
Definition: Acceptor.h:40