本文整理汇总了C++中CDataAccessor::setErrorCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CDataAccessor::setErrorCode方法的具体用法?C++ CDataAccessor::setErrorCode怎么用?C++ CDataAccessor::setErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataAccessor
的用法示例。
在下文中一共展示了CDataAccessor::setErrorCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: address
bool L1InterfaceStub::processClientGetConnectionAddrRequest(CDataAccessor & accessor,
const iviLink::Ipc::DirectionID dirId)
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
ConnectionInformation fake;
UInt8 * serializedData = fake.serialize();
accessor.setData(serializedData, fake.getSerializedSize());
accessor.setErrorCode(ConnectivityAgentError::ERROR_NOT_FOUND);
delete[] serializedData;
if (mpAgent)
{
iviLink::ConnectivityAgent::HAL::CCarrierAdapter* pca =
mpAgent->getCurrentCarrierAdapter();
if (pca)
{
LOG4CPLUS_INFO(logger, "Retrieving actual connection information");
ConnectionInformation address(pca->getLocalAddress(), pca->getRemoteAddress(),
pca->getTypeName());
UInt8 * serializedData = address.serialize();
accessor.setData(serializedData, address.getSerializedSize());
accessor.setErrorCode(BaseError::IVILINK_NO_ERROR);
delete[] serializedData;
}
}
// we try to send response always
return true;
}
示例2: 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");
}
}
示例3: memcpy
bool L1InterfaceStub::processClientAllocateRequest(CDataAccessor & accessor,
const iviLink::Ipc::DirectionID dirId)
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
const UInt32 channel_id = accessor.getChannelID();
if(CA_SERVICE_CHANNEL == channel_id)
{
// SEQ_E_5
LOG4CPLUS_WARN(logger, "Channel CA_SERVICE_CHANNEL is not allowed to be open");
accessor.resetData();
accessor.setErrorCode(ConnectivityAgentError::ERROR_CHANNEL_BUSY);
return true;
}
UInt32 prio = 0;
memcpy(&prio, accessor.getData(), accessor.getDataSize());
LOG4CPLUS_INFO(logger, "L1InterfaceStub::processClientAllocateRequest() => "
"Allocate Channel Request: ChID = "
+ convertIntegerToString(channel_id) + ", prio = " + convertIntegerToString(prio));
iviLink::Ipc::DirectionID tmpDirId = dirId;
ConnectivityAgentError err = ConnectivityAgentError(ConnectivityAgentError::ERROR_OTHER);
mRequestedMapMutex.lock();
mRegistryMutex.lock();
{
err = beginAllocateChannel(static_cast<TChannelPriority>(prio), channel_id, true,
tmpDirId);
accessor.setErrorCode(err.getCode());
if (err.isNoError())
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::processClientAllocateRequest() => "
"all ok, sending request to other side" );
err = sendRequest(accessor);
}
}
mRegistryMutex.unlock();
mRequestedMapMutex.unlock();
if (err.isNoError()) //> all ok
{
return false;
}
else
{
// something wrong, need message about error
// SEQ_E_5
assert(err.getCode() != ConnectivityAgentError::ERROR_DEFERRED);
accessor.resetData();
accessor.setErrorCode(err.getCode());
return true;
}
}
示例4: testRawArray
void testRawArray()
{
//setup
UInt8 data[] = "012";
CDataAccessor a;
a.setChannelID(123);
a.setErrorCode(234);
a.setOpCode(345);
a.setData(data, sizeof(data));
UInt8 array[100];
a.printContent();
// test
UInt32 size = a.getObjectSize();
a.copyToRawArray(array);
CPPUNIT_ASSERT_EQUAL(sizeof(data) + 4*4, size);
CDataAccessor b(array, size);
b.printContent();
CPPUNIT_ASSERT_EQUAL(123u, b.getChannelID());
CPPUNIT_ASSERT_EQUAL(234u, b.getErrorCode());
CPPUNIT_ASSERT_EQUAL(345u, b.getOpCode());
CPPUNIT_ASSERT_EQUAL(sizeof(data), b.getDataSize());
CPPUNIT_ASSERT(0 == memcmp(data, b.getData(), sizeof(data)));
}
示例5: convertIntegerToString
bool L1InterfaceStub::processClientDeallocateByWD(CDataAccessor & accessor,
const iviLink::Ipc::DirectionID dirId)
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
UInt32 channel_id = accessor.getChannelID();
if(CA_SERVICE_CHANNEL !=channel_id)
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::processClientDeallocateByWD() => "
"Deallocate Channel Request: ChID = " + convertIntegerToString(channel_id));
mRegistryMutex.lock();
tChannelsRegistryMap::iterator iter = mL1ChannelRegistry.find(channel_id);
if (iter != mL1ChannelRegistry.end())
{
iter->second.mClientDir = dirId; // so that Negotiator receives the response
iter->second.mState = E_TRANSITION_CLIENT;
accessor.setOpCode(E_DEALLOCATE_CHANNEL);
sendRequest(accessor);
assert(mTimeoutManager);
mTimeoutManager->addSubscriber(new RequestTimeout(static_cast<tOpCode>
(accessor.getOpCode()),channel_id,this ), 250000);
accessor.setErrorCode(0);
}
else
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::processClientDeallocateByWD() "
"=> Deallocate Channel Request: ChID = " +
convertIntegerToString(channel_id) + " NOT FOUND!");
accessor.setErrorCode(ConnectivityAgentError::ERROR_NOT_FOUND);
}
mRegistryMutex.unlock();
}
else
{
accessor.setErrorCode(ConnectivityAgentError::ERROR_OTHER);
}
return true;
}
示例6: if
bool L1InterfaceStub::processClientGetDeviceList(CDataAccessor & accessor, const iviLink::Ipc::DirectionID dirId)
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
UInt32 number = 0;
if(accessor.getDataSize()<sizeof(UInt32))
{
accessor.resetData();
accessor.setErrorCode(ConnectivityAgentError::ERROR_REQUEST_FAILED);
return true;
}
number=*(reinterpret_cast<UInt32*>(accessor.getData()));
if(number!=0)
{
accessor.resetData();
accessor.setErrorCode(ConnectivityAgentError::ERROR_NOT_FOUND);
return true;
}
else
{
LOG4CPLUS_INFO(logger, "Device Number know, transmitting");
FoundDevice device;
UInt8* serializedData = NULL;
device.mName="N/a";
device.mAddress="";
device.mConnection=CON_UNKNOWN;
if (mpAgent)
{
iviLink::ConnectivityAgent::HAL::CCarrierAdapter* pca = mpAgent->getCurrentCarrierAdapter();
if (pca)
{
const char *remoteAddress = pca->getRemoteAddress();
const char *connTypeName = pca->getTypeName();
if(connTypeName == NULL)
{
connTypeName = "";
}
if(remoteAddress == NULL)
{
remoteAddress = "N/a";
}
std::string typeName = connTypeName;
device.mName = remoteAddress;
device.mAddress = remoteAddress;
if (typeName == "Bluetooth")
{
device.mConnection = CON_BLUETOOTH;
}
else if (typeName == "TCP/IP")
{
device.mConnection = CON_IP;
}
}
}
serializedData = device.serialize();
accessor.resetData();
accessor.setData(serializedData,device.getSerializedSize());
delete[] serializedData;
accessor.setErrorCode(BaseError::IVILINK_NO_ERROR);
return true;
}
}
示例7: switch
void L1InterfaceStub::RequestTimeout::onTimeout()
{
CDataAccessor resp;
UInt32 data = ERR_TIMEOUT;
if (mEnabled)
{
switch (mRequest)
{
case E_ALLOCATE_CHANNEL:
{
mpOwner->mRegistryMutex.lock();
bool found = (mpOwner->mL1ChannelRegistry.find(mChannelID) !=
mpOwner->mL1ChannelRegistry.end());
mpOwner->mRegistryMutex.unlock();
if (found)
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::RequestTimeout::onTimeout()=> channel "
+ convertIntegerToString(mChannelID) + " allocated!");
}
else
{
LOG4CPLUS_WARN(logger, "L1InterfaceStub::RequestTimeout::onTimeout()=> Channel "
+ convertIntegerToString(mChannelID) + " allocation timeout!");
resp.setChannelID(mChannelID);
resp.setOpCode(E_ALLOCATE_CHANNEL_RESP);
resp.setData(reinterpret_cast<UInt8 *>(&data), sizeof(UInt32));
resp.setErrorCode(ConnectivityAgentError::ERROR_TIMEOUT);
mpOwner->mRequestedMapMutex.lock();
mpOwner->mRequestedMap.erase(mChannelID);
mpOwner->mRequestedMapMutex.unlock();
mpOwner->sendRequest(resp);
}
break;
}
case E_DEALLOCATE_CHANNEL:
{
iviLink::Ipc::DirectionID client_dir;
bool found = false;
mpOwner->mRegistryMutex.lock();
{
tChannelsRegistryMap::iterator iter = mpOwner->mL1ChannelRegistry.find(mChannelID);
found = (iter != mpOwner->mL1ChannelRegistry.end());
if (found)
{
client_dir = iter->second.mClientDir;
}
}
mpOwner->mRegistryMutex.unlock();
if (found)
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::RequestTimeout::onTimeout() => "
"Channel deallocation timeout!");
resp.setChannelID(mChannelID);
resp.setOpCode(E_DEALLOCATE_CHANNEL_RESP);
resp.setData(reinterpret_cast<UInt8 *>(&data), sizeof(UInt32));
resp.setErrorCode(ConnectivityAgentError::ERROR_TIMEOUT);
UInt8* buf = new UInt8[resp.getObjectSize()];
resp.copyToRawArray(buf);
BaseError err = mpOwner->mpIpc->asyncRequest(mpOwner->mMsgIdGen.next(),
buf, resp.getObjectSize(), &client_dir);
if (!err.isNoError())
{
LOG4CPLUS_WARN(logger, static_cast<std::string>(err));
}
delete [] buf;
}
else
{
LOG4CPLUS_INFO(logger, "L1InterfaceStub::RequestTimeout::onTimeout() => "
"channel Deallocated!");
}
break;
}
default:
break;
}
}
}