Loading...
Searching...
No Matches
IdSet.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// IdSet.h
//------------------------------------------------------------------------------
// Copyright (c) 1997 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef ID_SET_H
#define ID_SET_H
#include <string.h>
#include <sys/time.h> /* select(3) */
#if defined(Linux) /* select(3) */
# include <sys/types.h>
# include <unistd.h>
#endif
#if defined(WIN32)
# include <winsock2.h>
#endif
namespace ASSA {
class IdSet
{
public:
IdSet ();
int newid ();
int recycle (int id_);
int currid () const;
private:
int m_next_available_id;
fd_set m_id_set_map;
};
inline
IdSet::
IdSet()
: m_next_available_id (0)
{
::memset (&m_id_set_map, 0, sizeof (m_id_set_map));
}
inline int
IdSet::
currid() const
{
return m_next_available_id;
}
} // end namespace ASSA
#endif /* ID_SET_H */
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::IdSet
Definition IdSet.h:39
ASSA::IdSet::m_next_available_id
int m_next_available_id
Current id.
Definition IdSet.h:62
ASSA::IdSet::newid
int newid()
Return current id.
Definition IdSet.cpp:20
ASSA::IdSet::IdSet
IdSet()
Default constructor creates IdSet object with ID equals to 0.
Definition IdSet.h:71
ASSA::IdSet::recycle
int recycle(int id_)
Recycle id_.
Definition IdSet.cpp:54
ASSA::IdSet::currid
int currid() const
Get current id.
Definition IdSet.h:79
ASSA::IdSet::m_id_set_map
fd_set m_id_set_map
Map of all ids.
Definition IdSet.h:66
ASSA
Definition Acceptor.h:40