#include "modulecomm_inter.h"

#include <iostream>

#include "intercomm.h"

namespace iv {



modulecomm_inter::modulecomm_inter()
{

}

void modulecomm_inter::RegisterSend(const char *strcommname, const unsigned int nBufSize, const unsigned int nMsgBufCount)
{
    iv::intercomm * pinter = new iv::intercomm(strcommname,nBufSize,nMsgBufCount,iv::intercomm::ModeWrite);
    mpinter = (void *)pinter;
}

void modulecomm_inter::RegisterRecv(const char *strcommname, SMCallBack pCall)
{
    iv::intercomm * pif = new iv::intercomm(strcommname,0,0,iv::intercomm::ModeRead);
    pif->listenmsg(pCall);
    mpinter = (void *)pif;
}

void modulecomm_inter::RegisterRecvPlus(const char *strcommname, ModuleFun xFun)
{
    iv::intercomm * pif = new iv::intercomm(strcommname,0,0,iv::intercomm::ModeRead);
    pif->listenmsg(xFun);
    mpinter = (void *)pif;
}

void modulecomm_inter::ModuleSendMsg(const char *strdata, const unsigned int nDataLen)
{
    iv::intercomm * pif = (iv::intercomm *)mpinter;
    pif->writemsg(strdata,nDataLen);
}

void modulecomm_inter::ContintuComm()
{
    iv::intercomm * pif = (iv::intercomm *)mpinter;
    pif->continuecomm();
}

void modulecomm_inter::PauseComm()
{
    iv::intercomm * pif = (iv::intercomm *)mpinter;
    pif->pausecomm();
}

void modulecomm_inter::Unregister()
{
    iv::intercomm * pif = (iv::intercomm *)mpinter;
    delete pif;
}

}