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

Method readBuiltinTopicData

tools/monitor/MonitorTask.cpp:849–937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847
848template< class ReaderType, class DataType, class DataTypeSeq>
849bool
850Monitor::MonitorTask::readBuiltinTopicData(
851 const OpenDDS::DCPS::GUID_t& id,
852 DataType& data,
853 const char* topicName
854)
855{
856 // Grab the BuiltinTopic subscriber.
857 DDS::Subscriber_var subscriber
858 = this->participant_->get_builtin_subscriber();
859
860 // Lookup the reader for this BuiltinTopic type.
861 DDS::DataReader_var reader =
862 subscriber->lookup_datareader( topicName);
863
864 // Get the specific reader we need.
865 typename ReaderType::_var_type typedReader
866 = ReaderType::_narrow(reader.in());
867
868 // Find the instance to read.
869 OpenDDS::DCPS::DomainParticipantImpl* dpi =
870 dynamic_cast<OpenDDS::DCPS::DomainParticipantImpl*>(this->participant_.in());
871 const DDS::InstanceHandle_t instance = dpi->lookup_handle(id);
872
873 if (this->options_.verbose()) {
874 ACE_DEBUG((LM_DEBUG,
875 ACE_TEXT("(%P|%t) MonitorTask::readBuiltinTopicData<%s>() - ")
876 ACE_TEXT("id: %C ==> BuiltinTopic key: ")
877 ACE_TEXT("[0x%x, 0x%x, 0x%x], handle %d.\n"),
878 topicName,
879 OpenDDS::DCPS::LogGuid(id).c_str(),
880 data.key.value[0], data.key.value[1], data.key.value[2],
881 instance
882 ));
883 }
884
885 if (instance == DDS::HANDLE_NIL) {
886 ACE_DEBUG((LM_DEBUG,
887 ACE_TEXT("(%P|%t) MonitorTask::readBuiltinTopicData<%s>() - ")
888 ACE_TEXT("no data for id %C at this time.\n"),
889 topicName,
890 OpenDDS::DCPS::LogGuid(id).c_str()
891 ));
892 return false;
893 }
894
895 // with HISTORY.depth == 1, this should be the sample that we are
896 // interested in.
897 DDS::SampleInfoSeq infoSeq( 1);
898 DataTypeSeq dataSeq( 1);
899 if( DDS::RETCODE_OK != typedReader->read_instance(
900 dataSeq, infoSeq, 1, instance,
901 DDS::ANY_SAMPLE_STATE,
902 DDS::ANY_VIEW_STATE,
903 DDS::ANY_INSTANCE_STATE
904 )) {
905 ACE_ERROR((LM_ERROR,
906 ACE_TEXT("(%P|%t) ERROR: MonitorTask::readBuiltinTopicData<%s>() - ")

Callers

nothing calls this directly

Calls 8

LogGuidFunction · 0.85
lookup_handleMethod · 0.80
lookup_datareaderMethod · 0.45
inMethod · 0.45
verboseMethod · 0.45
read_instanceMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected