MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / BlockDescription

Function BlockDescription

lib/mdflib/mdflib/src/ca4block.cpp:82–146  ·  view source on GitHub ↗

\brief Create a descriptive text from a generic MDF block pointer. * * @param block Pointer to an MDF block. * @return Descriptive text about the block. */

Source from the content-addressed store, hash-verified

80 * @return Descriptive text about the block.
81 */
82std::string BlockDescription(const mdf::detail::MdfBlock* block) {
83 std::ostringstream desc;
84 if (block == nullptr) {
85 return desc.str();
86 }
87
88 try {
89 if (block->BlockType() == "DG") {
90 const auto* dg_group = dynamic_cast<const mdf::IDataGroup*>(block);
91 if (dg_group == nullptr) {
92 desc << "DG: Invalid link";
93 } else if (!dg_group->Description().empty()) {
94 desc << "DG: " << dg_group->Description();
95 } else {
96 desc << "DG: " << block->Comment();
97 }
98 } else if (block->BlockType() == "CG") {
99 const auto* cg_group = dynamic_cast<const mdf::IChannelGroup*>(block);
100 if (cg_group == nullptr) {
101 desc << "CG: Invalid link";
102 } else if (!cg_group->Name().empty()) {
103 desc << "CG: " << cg_group->Name();
104 } else if (!cg_group->Description().empty()) {
105 desc << "CG: " << cg_group->Description();
106 } else {
107 desc << "CG: " << block->Comment();
108 }
109 } else if (block->BlockType() == "CN") {
110 const auto* cn_group = dynamic_cast<const mdf::IChannel*>(block);
111 if (cn_group == nullptr) {
112 desc << "CN: Invalid link";
113 } else if (!cn_group->Name().empty()) {
114 desc << "CN: " << cn_group->Name();
115 } else if (!cn_group->Description().empty()) {
116 desc << "CN: " << cn_group->Description();
117 } else {
118 desc << "CN: " << block->Comment();
119 }
120 } else if (block->BlockType() == "CC") {
121 const auto* cc_group = dynamic_cast<const mdf::IChannelConversion*>(block);
122 if (cc_group == nullptr) {
123 desc << "CC: 1:1";
124 } else if (!cc_group->Name().empty()) {
125 desc << "CC: " << cc_group->Name();
126 } else if (!cc_group->Description().empty()) {
127 desc << "CC: " << cc_group->Description();
128 } else {
129 desc << "CC: " << block->Comment();
130 }
131 } else if (block->BlockType() == "CA") {
132 const auto* ca_group = dynamic_cast<const mdf::IChannelArray*>(block);
133 if (ca_group == nullptr) {
134 desc << "CA: Invalid link";
135 } else {
136 desc << "CA: " << ::MakeTypeString(
137 static_cast<uint8_t>(ca_group->Type()));
138 }
139 } else {

Callers 1

GetBlockPropertyMethod · 0.85

Calls 7

emptyMethod · 0.80
MakeTypeStringFunction · 0.70
BlockTypeMethod · 0.45
DescriptionMethod · 0.45
CommentMethod · 0.45
NameMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected