MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / serialize_sample

Method serialize_sample

dds/DCPS/DataWriterImpl.cpp:2990–3070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2988}
2989
2990ACE_Message_Block* DataWriterImpl::serialize_sample(const Sample& sample)
2991{
2992 const bool encapsulated = cdr_encapsulation();
2993 const Encoding& encoding = encoding_mode_.encoding();
2994 Message_Block_Ptr mb;
2995 ACE_Message_Block* tmp_mb;
2996
2997 // Don't use the cached allocator for the registered sample message
2998 // block.
2999 if (sample.key_only() && !skip_serialize_) {
3000 ACE_NEW_RETURN(tmp_mb,
3001 ACE_Message_Block(
3002 encoding_mode_.buffer_size(sample),
3003 ACE_Message_Block::MB_DATA,
3004 0, // cont
3005 0, // data
3006 0, // alloc_strategy
3007 get_db_lock()),
3008 0);
3009 } else {
3010 ACE_NEW_MALLOC_RETURN(tmp_mb,
3011 static_cast<ACE_Message_Block*>(
3012 mb_allocator_->malloc(sizeof(ACE_Message_Block))),
3013 ACE_Message_Block(
3014 encoding_mode_.buffer_size(sample),
3015 ACE_Message_Block::MB_DATA,
3016 0, // cont
3017 0, // data
3018 data_allocator_.get(), // allocator_strategy
3019 get_db_lock(), // data block locking_strategy
3020 ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY,
3021 ACE_Time_Value::zero,
3022 ACE_Time_Value::max_time,
3023 db_allocator_.get(),
3024 mb_allocator_.get()),
3025 0);
3026 }
3027 mb.reset(tmp_mb);
3028
3029 if (skip_serialize_) {
3030 if (!sample.to_message_block(*mb)) {
3031 if (log_level >= LogLevel::Error) {
3032 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: DataWriterImpl::serialize_sample: "
3033 "to_message_block failed\n"));
3034 }
3035 return 0;
3036 }
3037 } else {
3038 Serializer serializer(mb.get(), encoding);
3039 if (encapsulated) {
3040 EncapsulationHeader encap;
3041 if (!from_encoding(encap, encoding, type_support_->base_extensibility())) {
3042 // from_encoding logged the error
3043 return 0;
3044 }
3045 if (!(serializer << encap)) {
3046 if (log_level >= LogLevel::Error) {
3047 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: DataWriterImpl::serialize_sample: "

Callers

nothing calls this directly

Calls 11

cdr_encapsulationFunction · 0.85
get_db_lockFunction · 0.85
from_encodingFunction · 0.85
buffer_sizeMethod · 0.45
mallocMethod · 0.45
getMethod · 0.45
resetMethod · 0.45
to_message_blockMethod · 0.45
base_extensibilityMethod · 0.45
serializeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected