Apollo 10.0
自动驾驶开放平台
GeneralMessage类 参考

#include <general_message.h>

类 GeneralMessage 继承关系图:
GeneralMessage 的协作图:

Public 成员函数

 GeneralMessage (GeneralMessageBase *parent, const google::protobuf::Message *msg, const google::protobuf::Reflection *reflection, const google::protobuf::FieldDescriptor *field)
 
 ~GeneralMessage ()
 
int Render (const Screen *s, int key) override
 
- Public 成员函数 继承自 RenderableMessage
 RenderableMessage (RenderableMessage *parent=nullptr, int line_no=0)
 
virtual ~RenderableMessage ()
 
virtual double frame_ratio (void)
 
RenderableMessageparent (void) const
 
void set_parent (RenderableMessage *parent)
 
int page_item_count (void) const
 

额外继承的成员函数

- 静态 Public 属性 继承自 RenderableMessage
static constexpr int FrameRatio_Precision = 2
 
- Protected 成员函数 继承自 GeneralMessageBase
void InsertRepeatedMessage (int line_no, GeneralMessageBase *item)
 
RenderableMessageChild (int line_no) const override
 
 GeneralMessageBase (RenderableMessage *parent=nullptr)
 
 ~GeneralMessageBase (void)
 
void clear (void)
 
 GeneralMessageBase (const GeneralMessageBase &)=delete
 
GeneralMessageBaseoperator= (const GeneralMessageBase &)=delete
 
- Protected 成员函数 继承自 RenderableMessage
int * line_no (void)
 
void set_line_no (int line_no)
 
void reset_line_page (void)
 
void SplitPages (int key)
 
- 静态 Protected 成员函数 继承自 GeneralMessageBase
static void PrintMessage (GeneralMessageBase *baseMsg, const google::protobuf::Message &msg, int *jump_lines, const Screen *s, int *line_no, int indent)
 
static void PrintField (GeneralMessageBase *baseMsg, const google::protobuf::Message &msg, int *jump_lines, const Screen *s, int *line_no, int indent, const google::protobuf::Reflection *ref, const google::protobuf::FieldDescriptor *field, int index)
 
static int LineCount (const google::protobuf::Message &msg, int screen_width)
 
static int LineCountOfField (const google::protobuf::Message &msg, int screen_width, const google::protobuf::FieldDescriptor *field, const google::protobuf::Reflection *reflection, bool is_folded=true)
 
- Protected 属性 继承自 GeneralMessageBase
std::map< const int, GeneralMessageBase * > children_map_
 
- Protected 属性 继承自 RenderableMessage
int line_no_
 
int pages_
 
int page_index_
 
int page_item_count_
 
RenderableMessageparent_
 
double frame_ratio_
 

详细描述

在文件 general_message.h26 行定义.

构造及析构函数说明

◆ GeneralMessage()

GeneralMessage::GeneralMessage ( GeneralMessageBase parent,
const google::protobuf::Message *  msg,
const google::protobuf::Reflection *  reflection,
const google::protobuf::FieldDescriptor *  field 
)

在文件 general_message.cc77 行定义.

82 item_index_(0),
83 is_folded_(true),
84 field_(field),
85 message_ptr_(msg),
86 reflection_ptr_(reflection) {}
RenderableMessage * parent(void) const

◆ ~GeneralMessage()

GeneralMessage::~GeneralMessage ( )
inline

在文件 general_message.h33 行定义.

33 {
34 field_ = nullptr;
35 message_ptr_ = nullptr;
36 reflection_ptr_ = nullptr;
37 }

成员函数说明

◆ Render()

int GeneralMessage::Render ( const Screen s,
int  key 
)
overridevirtual

实现了 RenderableMessage.

在文件 general_message.cc88 行定义.

88 {
90 int line_no = 0;
91 {
92 RenderableMessage* p = this;
93 while (p->parent()->parent()->parent()) {
94 p = p->parent();
95 }
96
97 GeneralChannelMessage* channel_msg_ptr =
98 static_cast<GeneralChannelMessage*>(p->parent());
99 s->AddStr(0, line_no++, "ChannelName: ");
100 s->AddStr(channel_msg_ptr->GetChannelName().c_str());
101
102 s->AddStr(0, line_no++, "MessageType: ");
103 s->AddStr(channel_msg_ptr->message_type().c_str());
104
105 std::ostringstream out_str;
106 out_str << std::fixed << std::setprecision(FrameRatio_Precision)
107 << channel_msg_ptr->frame_ratio();
108 s->AddStr(0, line_no++, "FrameRatio: ");
109 s->AddStr(out_str.str().c_str());
110
111 clear();
112
113 auto channel_msg = channel_msg_ptr->CopyMsgPtr();
114 if (!channel_msg_ptr->raw_msg_class_->ParseFromString(
115 channel_msg->message)) {
116 s->AddStr(0, line_no++,
117 "Cannot Parse the message for Real-Time Updating");
118 return line_no;
119 }
120
121 if (message_ptr_ && reflection_ptr_) {
122 int size = 0;
123 if (field_->is_repeated()) {
124 size = reflection_ptr_->FieldSize(*message_ptr_, field_);
125 } else {
126 if (reflection_ptr_->HasField(*message_ptr_, field_) ||
127 field_->containing_type()->options().map_entry()) {
128 size = 1;
129 }
130 }
131
132 if (size <= item_index_) {
133 out_str.str("");
134 out_str << "The item [" << item_index_ << "] has been empty !!!";
135 s->AddStr(0, line_no++, out_str.str().c_str());
136 return line_no;
137 }
138
139 if (key == ',') {
140 is_folded_ = !is_folded_;
141 } else if (is_folded_) {
142 switch (key) {
143 case 'n':
144 case 'N':
145 ++item_index_;
146 if (item_index_ >= size) {
147 item_index_ = 0;
148 }
149 break;
150
151 case 'm':
152 case 'M':
153 --item_index_;
154 if (item_index_ < 0) {
155 item_index_ = size - 1;
156 }
157 break;
158
159 default: {
160 }
161 }
162 }
163
164 int lcount = LineCountOfField(*message_ptr_, s->Width(), field_,
165 reflection_ptr_, is_folded_);
166 page_item_count_ = s->Height() - line_no - 8;
167 if (page_item_count_ < 1) {
169 }
170 pages_ = lcount / page_item_count_ + 1;
171 SplitPages(key);
172 int jump_lines = page_index_ * page_item_count_;
173 const std::vector<int> indices(
174 SortProtobufMapByKeys(*message_ptr_, field_, *reflection_ptr_, size));
175 if (is_folded_) {
176 GeneralMessageBase::PrintField(this, *message_ptr_, &jump_lines, s,
177 &line_no, 0, reflection_ptr_, field_,
178 indices[item_index_]);
179 } else {
180 for (const int index : indices) {
181 GeneralMessageBase::PrintField(this, *message_ptr_, &jump_lines, s,
182 &line_no, 0, reflection_ptr_, field_,
183 index);
184 }
185 }
186 }
187 }
188
190 return line_no;
191}
const std::string & message_type(void) const
double frame_ratio(void) override
std::string GetChannelName(void) const
static void PrintField(GeneralMessageBase *baseMsg, const google::protobuf::Message &msg, int *jump_lines, const Screen *s, int *line_no, int indent, const google::protobuf::Reflection *ref, const google::protobuf::FieldDescriptor *field, int index)
static int LineCountOfField(const google::protobuf::Message &msg, int screen_width, const google::protobuf::FieldDescriptor *field, const google::protobuf::Reflection *reflection, bool is_folded=true)
static constexpr int FrameRatio_Precision
void AddStr(int x, int y, ColorPair color, const char *str) const
Definition screen.cc:152
int Height(void) const
Definition screen.cc:122
int Width(void) const
Definition screen.cc:120
void SetCurrentColor(ColorPair color) const
Definition screen.cc:124
void ClearCurrentColor(void) const
Definition screen.cc:145
@ WHITE_BLACK
Definition screen.h:39

该类的文档由以下文件生成: