/* 
 * PVM++ - A C++ library for easy use of PVM
 * Copyright (C) 1997-2001 Sebastian Wilhelmi; University of Karlsruhe
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __PVM_STRUCTSET_II__
#define __PVM_STRUCTSET_II__

#include <pvm++/structset.hh>
#include <pvm++/struct.hh>

namespace Pvm
{

  inline 
  StructSet::StructSet ()
    : UseSelect (false), UseSelectUnknown (false), IntFDsReady (false)
  {
  }
  
  inline 
  int
  StructSet::count (const Struct &What) const
  {
    return Map.count (What.GetStructId ()) > 0 &&
      (*Map.find (What.GetStructId ())).second == &What;
  }
  
  inline 
  int
  StructSet::count (StructId What) const
  {
    return Map.count (What);
  }
  
  inline 
  void
  StructSet::erase (const Struct &What)
  {
    if (count (What))
      {
	Map.erase (What.GetStructId ());
      }
  }
  
  inline 
  void
  StructSet::erase (StructId What)
  {
    Map.erase (What);
  }
  
  inline 
  void
  StructSet::insert (Struct &What)
  {
    Map.insert (MapType::value_type (What.GetStructId (), &What));
  }
  
  inline 
  const StructSet::FDSet & 
  StructSet::ReadFDs () const
  {
    return IntReadFDs;
  }
  
  inline 
  StructSet::FDSet & 
  StructSet::ReadFDs ()
  {
    UseSelectUnknown = true;
    return IntReadFDs;
  }
  
  inline
  const StructSet::FDSet & 
  StructSet::WriteFDs () const
  {
    return IntWriteFDs;
  }
  
  inline 
  StructSet::FDSet & 
  StructSet::WriteFDs ()
  {
    UseSelectUnknown = true;
    return IntWriteFDs;
  }
  
  inline 
  const StructSet::FDSet & 
  StructSet::ExceptFDs () const
  {
    return IntExceptFDs;
  }
  
  inline 
  StructSet::FDSet & 
  StructSet::ExceptFDs ()
  {
    UseSelectUnknown = true;
    return IntExceptFDs;
  }
  
  inline 
  const StructSet::FDSet & 
  StructSet::ReadyReadFDs () const
  {
    return IntReadyReadFDs;
  }
  
  inline
  const StructSet::FDSet & 
  StructSet::ReadyWriteFDs () const
  {
    return IntReadyWriteFDs;
  }
  
  inline 
  const StructSet::FDSet & 
  StructSet::ReadyExceptFDs () const
  {
    return IntReadyExceptFDs;
  }
  
  inline 
  bool 
  StructSet::FDsReady () const
  {
    return IntFDsReady;
  }

} // namespace Pvm

#endif /* __PVM_STRUCTSET_II__ */
