//------------------------------------------------------------
// $Id: HostComm.h,v 1.2.2.1 2000/06/14 15:00:10 yamauchi Exp $
//------------------------------------------------------------
//	HostComm.h Host Command class
//	1999年6月21日(月)
//	Copyright (C) 1999 YAMAUCHI Hitoshi 山内 斉
//------------------------------------------------------------
#ifndef _HostComm_h
#define _HostComm_h 1

// Host の発するコマンドの種類
enum HostCommand_e {
    HOSTCOM_End_Radiosity_e,	       // radiosity stage 終了
    HOSTCOM_End_PrepareShading_e,      // prepare shading stage 終了
    HOSTCOM_End_Raytrace_e,	       // ray-tracing stage 終了
    HOSTCOM_Issue_BarrierSync_e,       // synchronization
    HOSTCOM_Suspend_GenNewRays_e,      // 大域負荷分散: stop generate new rays
    HOSTCOM_Resume_GenNewRays_e,       // 大域負荷分散: resume generate new ray
    HOSTCOM_Send_Patch_Descriptions_e, // パッチ情報の送信要求 : Hostが送信する
				       // (中間結果の取得のため，PE ->
				       //  Host へのパッチの送信要求)  
    HOSTCOM_ELSE_e    
};

class HostCommClass {
protected:
    enum HostCommand_e mHostComm;
    
public:
    HostCommClass(void)
    {
	this->mHostComm = HOSTCOM_ELSE_e;
    }
    HostCommClass(const HostCommClass& rhs)
    {
	this->mHostComm = rhs.mHostComm;
    }
    HostCommClass(const HostCommand_e & com)
    {
	this->mHostComm = com;
    }
    const HostCommClass &operator=(const HostCommClass& rhs)
    {
	if(this != &rhs)
	{
	    this->mHostComm	= rhs.mHostComm;
	}
	return(*this);
    }

    // status 
    void setCommand(HostCommand_e hostcom) 	
    { 
	this->mHostComm = hostcom;
    }
    HostCommand_e getCommand(void) const { return(this->mHostComm);	}
    
    // misc
    const char * toString(void) const 
    {
	static const char *pHCom[] = { 
	    "End Radiosity stage",
	    "End PrepareShading stage",
	    "End RayTrace stage",
	    "Issue Barrier sync",
	    "Suspend Generate new rays",
	    "Resume  Generate new rays",
	    "Send Patch descriptions to host",
	    "Warning! : null host command",
	    NULL 
	};
	return(pHCom[this->mHostComm]);
    }
public:
    // タグを返す
    static communication_tags_e getTAG(void) { return(TAG_HOST_COM_e);	}
};

#endif				// _HostComm_h
