//------------------------------------------------------------
// $Id: mpi2communStandAlone.h,v 1.2 1999/12/07 03:49:56 yamauchi Exp $
//------------------------------------------------------------
// mpi2communication for stand alone
//	Copyright 1999 (C) YAMAUCHI Hitoshi 
// template 化した Isend と Irecv の StandAlone 版
//------------------------------------------------------------
#ifndef _mpi2communStandAlone_h
#define _mpi2communStandAlone_h
#ifndef FOR_STANDALONE
#  error "Error! : This file is for Stand Alone Mode! Check compile option."
#endif

#include <assert.h>
#include "mpi2.h"
#include "req_handle_t.h"
#include "Intensity.h"

//------------------------------------------------------------
// Isend, Irecv 
//    send, wait ともに wait しないので必ず受信をチェックする
//------------------------------------------------------------
template < class T >
reqHandle_st commMpi2_IsendObj(int destRank, T *pObj, int numOfObj)
{
    assert(destRank >= 0);
    assert(pObj != NULL);
    assert(numOfObj > 0);
    reqHandle_st req_handle;

    extern void sendIntensityStandAlone(IntensityClass *pObj, int numOfObj);

    switch(T::getTAG())
    {
    case TAG_RAY_e:
	// 1PE では他 PE への Ray の送信はない
	cout << "Error! : Never called" << endl;
	break;
    case TAG_INTENSITY_e:
	// Dirty Cast... うむ．汚い．instanceOf が欲しい．
	sendIntensityStandAlone((IntensityClass *)pObj, numOfObj);
	break;

    case TAG_HOST_COM_e:
	
	break;
    case TAG_PE_STATUS_e:
	
	break;
    default:
	cout << "Error! : no such tag (commMpi2_IsendObj)" << endl;
	abort();
	break;
    }
    req_handle.req = -1;	// for suppress CC Warning
    return(req_handle);
    destRank = destRank;
}

template < class T > 
reqHandle_st commMpi2_IrecvObj(int srcRank, T *pObj, int numOfObj)
{
    assert(srcRank >= 0);
    assert(pObj != NULL);
    assert(numOfObj > 0);
    reqHandle_st req_handle;
    
    
    cout << "Nothing to do at StandAloneMode commMpi2_IrecvObj" << endl;
    req_handle.req = -1;	// for Warning
    return(req_handle);
}

#endif				// #ifdef _mpi2commuStandAlone_h
