00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ID_SET_H
00013 #define ID_SET_H
00014
00015 #include <string.h>
00016
00017 #include <sys/time.h>
00018
00019 #if defined(Linux)
00020 # include <sys/types.h>
00021 # include <unistd.h>
00022 #endif
00023
00024 #if defined(WIN32)
00025 # include <winsock2.h>
00026 #endif
00027
00028 namespace ASSA {
00029
00038 class IdSet
00039 {
00040 public:
00042 IdSet ();
00043
00047 int newid ();
00048
00052 int recycle (int id_);
00053
00057 int currid () const;
00058
00059 private:
00062 int m_next_available_id;
00063
00066 fd_set m_id_set_map;
00067 };
00068
00069 inline
00070 IdSet::
00071 IdSet()
00072 : m_next_available_id (0)
00073 {
00074 ::memset (&m_id_set_map, 0, sizeof (m_id_set_map));
00075 }
00076
00077 inline int
00078 IdSet::
00079 currid() const
00080 {
00081 return m_next_available_id;
00082 }
00083
00084 }
00085
00086 #endif