当前位置: 首页>>代码示例>>C++>>正文


C++ CDataAccessor::getErrorCode方法代码示例

本文整理汇总了C++中CDataAccessor::getErrorCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CDataAccessor::getErrorCode方法的具体用法?C++ CDataAccessor::getErrorCode怎么用?C++ CDataAccessor::getErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDataAccessor的用法示例。


在下文中一共展示了CDataAccessor::getErrorCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: err

void L1InterfaceStub::processServiceAllocateResponse(CDataAccessor & accessor)
{
    const UInt32 channel_id = accessor.getChannelID();
    ConnectivityAgentError err(static_cast<ConnectivityAgentError::AgentErrorCodes>
            (accessor.getErrorCode()));

    LOG4CPLUS_TRACE_METHOD(logger, "L1InterfaceStub::processServiceAllocateResponse() => "
            "Channel allocated responce id = "
            + convertIntegerToString(channel_id) + ", err = " +
            convertIntegerToString((int)err.getCode()));

    iviLink::Ipc::DirectionID dirId = -1;

    /// @todo better processing of error codes. PIlin, 31.08.12
    /// There is the error case with wrong processing:
    /// 1) if response with error, obtain ERR_DEFERRED from failAllocateChannel and
    ///   begin deallocation procedure.
    /// 2) if there is no known dirId, channel also needs to be deallocated, even
    /// if its allocation was successfull.
    ///
    /// Here we must initialize channel deallocation procedure, because we unable
    /// to send some message - there is no such in existing protocol.

    if (err.isNoError())
    {
        err = endAllocateChannel(channel_id, dirId);

        if (err.getCode() == ConnectivityAgentError::ERROR_DEFERRED)
        {
            LOG4CPLUS_INFO(logger, "L1InterfaceStub::processServiceAllocateResponse() => "
                    "was E_TRANSITION_AGENT, messaging to other side");
            accessor.setErrorCode(BaseError::IVILINK_NO_ERROR);
            err = sendRequest(accessor);
        }
    }

    if (!err.isNoError() || dirId == -1)
    {
        // SEQ_E_4

        LOG4CPLUS_ERROR(logger, "L1InterfaceStub::processServiceAllocateResponse() => "
                "failed channel allocation");

        failAllocateChannel(channel_id, dirId);
        accessor.setErrorCode(err.getCode());
    }

    if (dirId != -1)
    {
        LOG4CPLUS_INFO(logger, "L1InterfaceStub::processServiceAllocateResponse() => "
                "message about allocation result");
        sendIpcNotification(accessor, dirId);
    }
    else
    {
        LOG4CPLUS_ERROR(logger, "L1InterfaceStub::processServiceAllocateResponse() => "
                "unknown client, failing channel");
    }
}
开发者ID:Luxoft,项目名称:iviLink,代码行数:59,代码来源:L1InterfaceStub.cpp

示例2: sizeof

ConnectivityAgentError L1InterfaceStub::sendRequest( CDataAccessor & accessor)
{
    LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
    Buffer buf;
    UInt32 offset = 0;

    accessor.printContent();

    buf.getFilledSize() = accessor.getObjectSize() + sizeof(UInt16);
    buf.reserveSize(buf.getFilledSize());

    *reinterpret_cast<UInt16*> (buf.getData() + offset) =
            ByteOrder::hton16((UInt16)buf.getFilledSize());
    offset += 2;

    *reinterpret_cast<UInt32*> (buf.getData() + offset) =
            ByteOrder::hton32(accessor.getOpCode());
    offset += 4;

    *reinterpret_cast<UInt32*> (buf.getData() + offset) =
            ByteOrder::hton32(accessor.getChannelID());
    offset += 4;

    *reinterpret_cast<UInt32*> (buf.getData() + offset) =
            ByteOrder::hton32(accessor.getDataSize());
    offset += 4;

    *reinterpret_cast<UInt32*> (buf.getData() + offset) =
            ByteOrder::hton32(accessor.getErrorCode());
    offset += 4;

    if (accessor.getDataSize())
    {
        memcpy(buf.getData() + offset,accessor.getData(), accessor.getDataSize() );
    }

    ConnectivityAgentError ret = mL1ChannelRegistry[CA_SERVICE_CHANNEL].
            mpSourceAgent->fillBuffer(buf);

    buf.forgetData();

    return ret;
}
开发者ID:Luxoft,项目名称:iviLink,代码行数:43,代码来源:L1InterfaceStub.cpp

示例3: receiveAllocateChannelResponse

void CConnectivityAgentProxy::receiveAllocateChannelResponse(CDataAccessor & accessor)
{
	UInt32 channel_id = accessor.getChannelID();
	ERROR_CODE err = static_cast<ERROR_CODE>(accessor.getErrorCode());

	LOG4CPLUS_TRACE_METHOD(logger,
			"CConnectivityAgentProxy::receiveAllocateChannelResponse"
					" channel_id = " + convertIntegerToString(channel_id) + " err = "
					+ convertIntegerToString((int) err));

	mAllocateRequestCond.lock();
	{
		tAllocateRequestMap::iterator it = mAllocateRequestMap.find(channel_id);
		if (it == mAllocateRequestMap.end())
		{
			LOG4CPLUS_WARN(logger,
					"CConnectivityAgentProxy::receiveAllocateChannelResponse() => channel is not requested");
		} else
		{
			AllocateRequestInfo & info = it->second;
			info.mRequestDone = true;
			info.mResult = err;

			if (ERR_OK == err)
			{
				mRegistryMutex.lockWrite();
				mChannelRegistry[channel_id].mType = info.mType;
				mChannelRegistry[channel_id].mpClient = info.mpClient;
				mChannelRegistry[channel_id].mChannelBuffer.reserveSize(MAX_SIZE);
				mRegistryMutex.unlockWrite();
			}

			mAllocateRequestCond.broadcast();
		}
	}
	mAllocateRequestCond.unlock();
}
开发者ID:babenkoav78,项目名称:iviLink,代码行数:37,代码来源:CConnectivityAgentProxy.cpp

示例4: allocateChannel

ERROR_CODE CConnectivityAgentProxy::allocateChannel(TChannelPriority prio, UInt32 channel_id,
		IChannelObserver* observer)
{
	LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
	LOG4CPLUS_INFO(logger,
			"CConnectivityAgentProxy::allocateChannel(type = " + convertIntegerToString((int) prio)
					+ ", id = " + convertIntegerToString(channel_id) + " ), this = "
					+ convertIntegerToString((intptr_t) this));

	ERROR_CODE ret = ERR_FAIL;
	if ((channel_id > 0) && (channel_id <= 0xFFFF) && (NULL != observer))
	{
		mRegistryMutex.lockWrite();
		bool channel_unknown = mChannelRegistry.find(channel_id) == mChannelRegistry.end();
		mRegistryMutex.unlockWrite();

		if (channel_unknown)
		{
			mAllocateRequestCond.lock();
			bool channel_requested = mAllocateRequestMap.find(channel_id)
					!= mAllocateRequestMap.end();
			if (channel_requested)
			{
				ret = ERR_IN_PROGRESS;
				channel_unknown = false;
				LOG4CPLUS_WARN(logger,
						"CConnectivityAgentProxy::allocateChannel() => ERROR: channel allocation in progress!");
			} else
			{
				LOG4CPLUS_INFO(logger,
						"CConnectivityAgentProxy::allocateChannel() => insert request");
				mAllocateRequestMap.insert(
						std::make_pair(channel_id,
								AllocateRequestInfo(prio, observer, false, ERR_UNKNOWN)));
			}
			mAllocateRequestCond.unlock();
		}

		if (channel_unknown)
		{
			CDataAccessor requestDA;
			requestDA.setChannelID(channel_id);
			requestDA.setOpCode(E_ALLOCATE_CHANNEL);
			UInt32 data = prio;
			requestDA.setData(reinterpret_cast<UInt8 *>(&data), sizeof(UInt32));
			UInt8* buf = new UInt8[requestDA.getObjectSize()];
			requestDA.copyToRawArray(buf);

			UInt8 respBuf[100];
			UInt32 respSize = sizeof(respBuf);
			CError err = mpIpc->request(mMsgIdGen.next(), buf, requestDA.getObjectSize(), respBuf,
					respSize);
			delete[] buf;

			if (!err.isNoError())
			{
				LOG4CPLUS_WARN(logger, static_cast<std::string>(err));
				ret = ERR_FAIL;

				mAllocateRequestCond.lock();
				mAllocateRequestMap.erase(channel_id);
				mAllocateRequestCond.unlock();

				LOG4CPLUS_WARN(logger,
						"CConnectivityAgentProxy::allocateChannel() => ERROR: failed to send request");
			} else
			{
				CDataAccessor responseDA;

				if (respSize > 0)
				{
					responseDA = CDataAccessor(respBuf, respSize);
					ret = static_cast<ERROR_CODE>(responseDA.getErrorCode());

					mAllocateRequestCond.lock();
					mAllocateRequestMap.erase(channel_id);
					mAllocateRequestCond.unlock();

					LOG4CPLUS_WARN(logger,
							"CConnectivityAgentProxy::allocateChannel() => ERROR: got error response");
				} else
				{
					mAllocateRequestCond.lock();
					while (true)
					{
						tAllocateRequestMap::iterator it = mAllocateRequestMap.find(channel_id);
						if (it == mAllocateRequestMap.end())
						{
							ret = ERR_FAIL;
							LOG4CPLUS_WARN(logger,
									"CConnectivityAgentProxy::allocateChannel() => ERROR: request was removed");
							break;
						}

						AllocateRequestInfo & info = it->second;
						if (info.mRequestDone)
						{
							LOG4CPLUS_INFO(logger,
									"CConnectivityAgentProxy::allocateChannel() => request done");
							ret = info.mResult;
//.........这里部分代码省略.........
开发者ID:babenkoav78,项目名称:iviLink,代码行数:101,代码来源:CConnectivityAgentProxy.cpp


注:本文中的CDataAccessor::getErrorCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。