// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.

#ifndef tools_wroot_mpi_basket_add
#define tools_wroot_mpi_basket_add

#include "mpi_send_basket"
#include "branch"

namespace tools {
namespace wroot {

class mpi_basket_add : public virtual branch::iadd_basket {
  typedef branch::iadd_basket parent;
public:
  virtual bool add_basket(basket* a_basket) {
    bool status = mpi_send_basket(m_mpi,m_dest,m_tag,m_id,m_icol,*a_basket);
    delete a_basket;
    return status;
  }
public:
  mpi_basket_add(impi& a_mpi,int a_dest,int a_tag,uint32 a_id,uint32 a_icol)
  :m_mpi(a_mpi),m_dest(a_dest),m_tag(a_tag),m_id(a_id),m_icol(a_icol)
  {}
protected:
  mpi_basket_add(const mpi_basket_add& a_from):parent()
  ,m_mpi(a_from.m_mpi),m_dest(a_from.m_dest),m_tag(a_from.m_tag)
  ,m_id(a_from.m_id),m_icol(a_from.m_icol)
  {}
  mpi_basket_add& operator=(const mpi_basket_add& a_from){
    m_dest = a_from.m_dest;
    m_tag = a_from.m_tag;
    m_id = a_from.m_id;
    m_icol = a_from.m_icol;
    return *this;
  }
protected:
  impi& m_mpi;
  int m_dest;
  int m_tag;
  uint32 m_id;
  uint32 m_icol;
};

}}

#endif
