#include "modulecomm_inter.h"
#include <iostream>

#include "intercomm.h"

namespace iv {
namespace modulecomm_inter {

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

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

void * MODULECOMM_INTER_EXPORT RegisterRecvPlus(const char * strcommname,ModuleFun xFun)
{
    iv::intercomm * pif = new iv::intercomm(strcommname,0,0,iv::intercomm::ModeRead);
    pif->listenmsg(xFun);
    return (void *)pif;
}
void  ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
{
    iv::intercomm * pif = (iv::intercomm *)pHandle;
    pif->writemsg(strdata,nDataLen);
}

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

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

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

}
}