本文整理汇总了C++中ACE_OutputCDR::good_bit方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_OutputCDR::good_bit方法的具体用法?C++ ACE_OutputCDR::good_bit怎么用?C++ ACE_OutputCDR::good_bit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_OutputCDR
的用法示例。
在下文中一共展示了ACE_OutputCDR::good_bit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
CmResult COFP13MPAggregateFlowStatsRequestMsg::
StreamTo(ACE_OutputCDR &os)
{
if (COFP13MultipartMsg::StreamTo(os) != CM_OK)
{
return CM_ERROR_FAILURE;
}
os<<m_stats_request.table_id;
os.write_octet_array(m_stats_request.pad, sizeof(m_stats_request.pad));
os<<m_stats_request.out_port;
os<<m_stats_request.out_group;
os.write_octet_array(m_stats_request.pad2, sizeof(m_stats_request.pad2));
os<<m_stats_request.cookie;
os<<m_stats_request.cookie_mask;
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return m_match.StreamTo(os);
}
示例2: while
CmResult COFP10PacketOutMsg::StreamTo(ACE_OutputCDR &os)
{
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamTo(os);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10PacketOutMsg::StreamTo, COFPMessage::StreamTo fail\n")));
return lRet;
}
os<<m_tMember.buffer_id;
os<<m_tMember.in_port;
os<<m_tMember.actions_len;
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
std::list<COFP10Action *>::const_iterator it = m_action_list.begin();
while (it != m_action_list.end())
{
lRet = (*it)->StreamTo(os);
CM_ASSERT_RETURN(CM_SUCCEEDED(lRet), CM_ERROR_FAILURE);
it++;
}
if (m_PacketData)
{
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("COFP10PacketOutMsg::StreamTo, m_PacketData->total_length() = %u\n"),
m_PacketData->total_length()));
std::string str = m_PacketData->flatten_chained();
os.write_char_array(str.c_str(), str.length());
}
bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return CM_OK;
}
示例3:
//
// operator <<
//
bool operator << (ACE_OutputCDR & out, const ::OASIS::PointImpl & s)
{
if (!(out << s.x))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%T (%t) - %M - failed to package x\n")),
false);
if (!(out << s.y))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%T (%t) - %M - failed to package y\n")),
false);
return out.good_bit ();
}
示例4: sendHeader
// send the test header (only contains number of iterations)
int sendHeader(ACE_SOCK_Stream & stream) {
// create an ACE CDR output stream and place the header information
// into it
ACE_OutputCDR hdrCDR;
hdrCDR << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
hdrCDR << ACE_CDR::ULong(Options_Manager::test_iterations+primerIterations);
if (!hdrCDR.good_bit())
return (0);
// send the header to the server (HEADER IS 8 BYTES LONG)
size_t bt;
if (stream.send_n(hdrCDR.begin(), 0, &bt) == -1)
return 0;
return 1;
}
示例5: StreamTo
CmResult COFPSwitchConfig::StreamTo(ACE_OutputCDR &os)
{
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamTo(os);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFPSwitchConfig::StreamTo, COFPMessage::StreamTo fail\n")));
return lRet;
}
os<<m_wFlags;
os<<m_wMissSendLen;
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return CM_OK;
}
示例6: defined
int
operator<< (ACE_OutputCDR &cdr,
const ACE_Log_Record &log_record)
{
// The written message length can't be more than 32 bits (ACE_CDR::ULong)
// so reduce it here if needed.
ACE_CDR::ULong u_msglen =
ACE_Utils::truncate_cast<ACE_CDR::ULong> (log_record.msg_data_len ());
// Insert each field from <log_record> into the output CDR stream.
cdr << ACE_CDR::Long (log_record.type ());
cdr << ACE_CDR::Long (log_record.pid ());
cdr << ACE_CDR::LongLong (log_record.time_stamp ().sec ());
cdr << ACE_CDR::Long (log_record.time_stamp ().usec ());
cdr << u_msglen;
#if defined (ACE_USES_WCHAR)
cdr.write_wchar_array (log_record.msg_data (), u_msglen);
#else
cdr.write_char_array (log_record.msg_data (), u_msglen);
#endif /* ACE_USES_WCHAR */
return cdr.good_bit ();
}
示例7: write
int DataWrapper::write(const ACE_OutputCDR& cdr)
{
//This method writes to an ace socket stream. First, it will collect
//the appropriate header which includes the message length. It will then
//combine ACE blocks that hold the header and message, and send it.
//If preparing the block or sending fails, it returns an appropriate error.
//If the actual socket send fails, the connection will be closed (not sure what
//else to do, since it shouldn't fail under a good connection)
if(!cdr.good_bit())
ACE_ERROR_RETURN((LM_ERROR, "%s, %p\n",toString(theAddress).c_str(),"Failed while sending CDR"), -1);
ACE_OutputCDR aceHead(headerLength);
//Put header info into a CDR
if(!(aceHead << (ACE_CDR::ULong)bitsForward) || !(aceHead << (ACE_CDR::ULong)cdr.length()))
ACE_ERROR_RETURN( (LM_ERROR, "%s, %p\n",toString(theAddress).c_str(),"Failed while sending, CDR header"), -1 );
//Create a block with the header and message
const_cast<ACE_Message_Block*>(aceHead.begin())->cont(const_cast<ACE_Message_Block*>(cdr.begin()));
const ssize_t msgLength = headerLength + ACE_CDR::total_length(cdr.begin(), cdr.end());
// cout << toString(theAddress) << endl;
//Send the message
const ssize_t bytesSent = theStream.send_n(aceHead.begin());
// Clear the block
const_cast<ACE_Message_Block*>(aceHead.begin())->cont(NULL);
//Check whether the send succeeded (sent all the bytes). If not, we assume the socket has disconnected.
// cout << "Bytes sent: " << bytesSent << " | msgLength: " << msgLength << endl;
if( bytesSent != msgLength ) {
theStream.close_writer();
ACE_ERROR_RETURN((LM_ERROR, "%s - %p\n",toString(theAddress).c_str(),"Socket failed while sending"), -1);
}
//Everything sent successfully
return 0;
}
示例8: GetMessageLength
CmResult COFP13PacketOutMsg::StreamTo(ACE_OutputCDR &os)
{
CmResult lRet = CM_ERROR_FAILURE;
ACE_CDR::Octet pad[6];
lRet = COFPMessage::StreamTo(os);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13PacketOutMsg::StreamTo, COFPMessage::StreamTo fail\n")));
return lRet;
}
ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13PacketOutMsg::StreamTo():\n")));
ACE_DEBUG((LM_DEBUG, ACE_TEXT("msgLen=%u\n"), GetMessageLength()));
os<<m_buffer_id;
os<<m_in_port;
os<<m_actions_len;
os.write_octet_array(pad, sizeof(pad));
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_actions_len=%u\n"), m_actions_len));
#if 0
while(!m_action_list.empty())
{
CCmComAutoPtr<COpenFlowProtAction> action;
action = m_action_list.front();
m_action_list.pop_front();
action->EncodeAction(os);
}
#endif
ACE_UINT16 i = 0;
std::list<COFP13Action *>::const_iterator it = m_action_list.begin();
while(it != m_action_list.end())
{
lRet = (*it)->StreamTo(os);
CM_ASSERT_RETURN(CM_SUCCEEDED(lRet), CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("action[%u]'s length=%u\n"), i++, (*it)->GetActionLen()));
bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
it++;
}
// just for debugging
ACE_UINT32 length = sizeof(m_buffer_id)+sizeof(m_in_port)+sizeof(m_actions_len)+sizeof(m_pad);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("length=%u\n"), length));
ACE_INT32 dataLen = GetStreamLen()-COFPMessage::GetStreamLen()-length-m_actions_len;
ACE_DEBUG((LM_DEBUG, ACE_TEXT("dataLen=%d\n"), dataLen));
if (m_PacketData)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_PacketData->total_length() = %u\n"), m_PacketData->total_length()));
std::string str = m_PacketData->flatten_chained();
bGood = os.write_char_array(str.c_str(), str.length());
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
}
return CM_OK;
}
示例9: while
// Logic of StreamTo is similar to StreamFrom.
CmResult COFP13HelloMsg::StreamTo(ACE_OutputCDR &os)
{
bool bGood = false;
ACE_UINT16 i = 0;
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamTo(os);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13HelloMsg::StreamTo, COFPMessage::StreamTo fail\n")));
return lRet;
}
if (m_wLength < COFPMessage::GetStreamLen())
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamTo(): m_wLength(%u) is less than OFP_MESSAGE_HDR_SIZE(%u).\n"),
m_wLength,
COFPMessage::GetStreamLen()));
return CM_ERROR_FAILURE;
}
ACE_UINT16 data_size = m_wElemListLen; //m_wLength-OPENFLOW_MESSAGE_HDR_SIZE;
ACE_UINT16 iter_size = 0;
const ACE_CDR::Octet *pElem = m_pElemList;
while (iter_size < m_wElemListLen)
{
ACE_UINT16 elem_type = GetHelloElemType(pElem);
ACE_UINT16 elem_size = GetHelloElemLen(pElem); // elem size, excluding paddings
os<<elem_type;
os<<elem_size;
bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13HelloMsg::StreamTo(): encode hello elem %u\n"), i++));
ACE_DEBUG((LM_DEBUG, ACE_TEXT("elem_type=%u, elem_size=%u\n"), elem_type, elem_size));
if (elem_size < 4)
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13HelloMsg::StreamTo(): elem_size(%u) error, less than 4."), elem_size));
return CM_ERROR_FAILURE;
}
if ((elem_size + 7)/8*8 > data_size)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamTo(): (elem_size + 7)/8*8=%u, greater than data_size(%u)\n"),
(elem_size + 7)/8*8,
data_size));
return CM_ERROR_FAILURE;
}
if (elem_type != OFPHET_VERSIONBITMAP)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamTo(): elem_type(%u) isnot OFPHET_VERSIONBITMAP(%u).\n"),
elem_type,
OFPHET_VERSIONBITMAP));
return CM_ERROR_FAILURE;
}
ACE_UINT16 bitmap_size = elem_size-4;
CM_ASSERT_RETURN((bitmap_size/4*4 == bitmap_size), CM_ERROR_INVALID_ARG);
ACE_UINT16 iter_bitmap_size = 0;
ACE_UINT16 bitmap_index = 0;
while (iter_bitmap_size < bitmap_size)//(bitmap_size > 0)
{
ACE_UINT32 bitmap = GetVerBMHelloElemBitmap(pElem, bitmap_index);
os<<bitmap;
bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13HelloMsg::StreamTo, bitmap[%u]=%u\n"), bitmap_index++, bitmap));
//bitmap_size -= sizeof(bitmap);
iter_bitmap_size += sizeof(bitmap);
}
// deal with paddings
ACE_UINT16 pad_length = (elem_size + 7)/8*8 - elem_size;
bGood = os.write_octet_array(pElem + 4 + sizeof(ACE_UINT32) * bitmap_index, pad_length);
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
iter_size += (elem_size + pad_length);
data_size -= (elem_size + pad_length);
pElem += (elem_size + pad_length);
}
return CM_OK;
}