本文整理汇总了C++中CDataAccessor::printContent方法的典型用法代码示例。如果您正苦于以下问题:C++ CDataAccessor::printContent方法的具体用法?C++ CDataAccessor::printContent怎么用?C++ CDataAccessor::printContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataAccessor
的用法示例。
在下文中一共展示了CDataAccessor::printContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)));
}
示例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;
}
示例3: convertIntegerToString
ConnectivityAgentError L1InterfaceStub::receiveData(Buffer & buffer, UInt32 channel_id)
{
LOG4CPLUS_TRACE(logger, "L1InterfaceStub::receiveData() => channel " +
convertIntegerToString(channel_id));
UInt32 offset = 0;
CDataAccessor accessor;
ConnectivityAgentError result;
// TODO ipc errors processing
// TODO incorrect data processing
assert(buffer.getFilledSize() <= buffer.getMaxSize());
LOG4CPLUS_INFO(logger, "L1InterfaceStub::receiveData() => buf size "
+ convertIntegerToString(buffer.getFilledSize()));
if(channel_id == CA_SERVICE_CHANNEL)
{
//> If data received from service channel - process service request
do
{
UInt32 begin = offset;
UInt16 buf_length = ByteOrder::ntoh16(*reinterpret_cast<UInt16*>
(buffer.getData() + offset));
offset += 2;
LOG4CPLUS_INFO(logger, "L1InterfaceStub::receiveData() => buf_length " +
convertIntegerToString(buf_length));
assert(begin + buf_length <= buffer.getFilledSize());
UInt32 operation = ByteOrder::ntoh32(*reinterpret_cast<UInt32*>
(buffer.getData() + offset));
offset += 4;
accessor.setOpCode(operation);
UInt32 channel_id = ByteOrder::ntoh32(*reinterpret_cast<UInt32*>
(buffer.getData() + offset));
offset += 4;
accessor.setChannelID(channel_id);
UInt32 data_size = ByteOrder::ntoh32(*reinterpret_cast<UInt32*>
(buffer.getData() + offset));
offset += 4;
UInt32 error_code = ByteOrder::ntoh32(*reinterpret_cast<UInt32*>
(buffer.getData() + offset));
offset += 4;
accessor.setErrorCode(error_code);
accessor.setData(buffer.getData() + offset, data_size);
offset += data_size;
accessor.printContent();
///>Process service request
tServiceCallbacksMap::iterator iter =
mServiceCallbacksMap.find(static_cast<tOpCode>(operation));
if (iter !=mServiceCallbacksMap.end())
{
///> This funny language structure is just callback invocation.
///> Not obvious, huh? =)
(this->*iter->second)(accessor);
result.setNoError();
}
else
{
LOG4CPLUS_WARN(logger, "L1InterfaceStub::receiveData() => "
"UNKNOWN SERVICE REQUEST = "
+ convertIntegerToString(operation) + "!!!");
}
} while (offset < buffer.getFilledSize());
LOG4CPLUS_INFO(logger, "L1InterfaceStub::receiveData() => offset "
+ convertIntegerToString(offset) + "!!!");
assert(buffer.getFilledSize() == offset);
}
else
{
//> Or pack to accessor and send to client
accessor.setOpCode(E_RECEIVE_DATA_NTF);
accessor.setChannelID(channel_id);
assert (buffer.getFilledSize() > 0);
accessor.setData(buffer.getData(),buffer.getFilledSize());
accessor.printContent();
UInt8* buf = new UInt8[accessor.getObjectSize()];
accessor.copyToRawArray(buf);
BaseError ipcError = mpIpc->asyncRequest(mMsgIdGen.next(),
buf, accessor.getObjectSize(), &mL1ChannelRegistry[channel_id].mClientDir); // TODO use find, and not []
delete [] buf;
if (ipcError.isNoError())
{
result.setNoError();
}
else
{
result.setErrorCode(ConnectivityAgentError::ERROR_REQUEST_FAILED);
}
//.........这里部分代码省略.........