Apollo  6.0
Open source self driving car software
general_message_base.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #ifndef TOOLS_CVT_MONITOR_GENERAL_MESSAGE_BASE_H_
18 #define TOOLS_CVT_MONITOR_GENERAL_MESSAGE_BASE_H_
19 
20 #include <map>
21 #include <utility>
22 
23 #include "cyber/cyber.h"
25 
26 class Screen;
27 
29  protected:
30  static void PrintMessage(GeneralMessageBase* baseMsg,
31  const google::protobuf::Message& msg,
32  int* jump_lines, const Screen* s, int* line_no,
33  int indent);
34  static void PrintField(GeneralMessageBase* baseMsg,
35  const google::protobuf::Message& msg, int* jump_lines,
36  const Screen* s, int* line_no, int indent,
37  const google::protobuf::Reflection* ref,
38  const google::protobuf::FieldDescriptor* field,
39  int index);
40 
41  static int LineCount(const google::protobuf::Message& msg, int screen_width);
42  static int LineCountOfField(const google::protobuf::Message& msg,
43  int screen_width,
44  const google::protobuf::FieldDescriptor* field,
45  const google::protobuf::Reflection* reflection,
46  bool is_folded = true);
47 
48  void InsertRepeatedMessage(int line_no, GeneralMessageBase* item) {
49  children_map_.emplace(line_no, item);
50  }
51 
52  RenderableMessage* Child(int line_no) const override;
53 
57 
58  void clear(void) {
59  for (auto& iter : children_map_) {
60  delete iter.second;
61  }
62 
63  children_map_.clear();
64  }
65 
66  GeneralMessageBase(const GeneralMessageBase&) = delete;
68 
69  std::map<const int, GeneralMessageBase*> children_map_;
70 };
71 
72 #endif // TOOLS_CVT_MONITOR_GENERAL_MESSAGE_BASE_H_
GeneralMessageBase(RenderableMessage *parent=nullptr)
Definition: general_message_base.h:54
std::map< const int, GeneralMessageBase * > children_map_
Definition: general_message_base.h:69
static int LineCount(const google::protobuf::Message &msg, int screen_width)
static void PrintMessage(GeneralMessageBase *baseMsg, const google::protobuf::Message &msg, int *jump_lines, const Screen *s, int *line_no, int indent)
Definition: screen.h:30
Definition: renderable_message.h:24
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)
void clear(void)
Definition: general_message_base.h:58
GeneralMessageBase & operator=(const GeneralMessageBase &)=delete
RenderableMessage * Child(int line_no) const override
Definition: general_message_base.h:28
void InsertRepeatedMessage(int line_no, GeneralMessageBase *item)
Definition: general_message_base.h:48
int * line_no(void)
Definition: renderable_message.h:55
RenderableMessage * parent(void) const
Definition: renderable_message.h:44
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)
~GeneralMessageBase(void)
Definition: general_message_base.h:56