/* 
 * 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_HOST_II__
#define __PVM_HOST_II__

#include <pvm++/host.hh>
#include <pvm++/task.hh>
#include <pvm++/hostset.hh>
#include <iostream>

namespace Pvm
{

  inline 
  Host::Host () : Where (Get (0))
  {
  }
  
  inline 
  Host::Host (const Host &What) : Where (What.Where)
  {
  }
  
  inline 
  Host::Host (unsigned int What) : Where (Get (What))
  {
  }
  
  inline 
  std::ostream & 
  operator << (std::ostream &Stream, Host What)
  {
    std::ios::fmtflags oldflags = Stream.setf (std::ios::hex, 
					       std::ios::basefield);
    Stream << 'h' << (unsigned int) What;
    Stream.flags (oldflags);
    return (Stream);
  }
  
  inline 
  void
  Host::Spawn (const std::string &Task, int Num, TaskSet &Result) const
  {
    HostSet ThisHost;
    ThisHost.insert (*this);
    ThisHost.Spawn (Task, Num, Result);
  }
  
  inline 
  Task 
  Host::Spawn (const std::string &Task) const
  {
    HostSet ThisHost;
    ThisHost.insert (*this);
    return (ThisHost.Spawn (Task));
  }
  
} // namespace Pvm

#endif /* __PVM_HOST_II__ */
