roviz  0.7
Code Documentation of roviz
message.h
1 #ifndef MESSAGE_H
2 #define MESSAGE_H
3 
4 #include <string>
5 #include <initializer_list>
6 #include "core/export_handling.h"
7 #include "streams/stream_object.h"
8 
9 class MessagePrivate;
10 class OutputPrivate;
11 class StreamWidget;
12 
24 class Message : public StreamObject
25 {
26 public:
32  struct Entry
33  {
34  std::string name;
35 
36  enum Type
37  {
38  Invalid,
39  String,
40  Int,
41  Double
42  } type;
43 
44  std::string s;
45 
46  // Can't use it for the string because of its non-trivial constructor/
47  // destructor, but let's at least use it here.
48  union {
49  int i;
50  double d;
51  };
52  };
53 
54  Message(const StreamObject &base);
55  Message(std::initializer_list<SourceID> sources = {});
56  virtual ~Message() = default;
57 
65  const Entry &entry(const std::string &name) const;
66 
75  const Entry &at(int index) const;
76 
84  const Entry &operator[](int index) const;
85 
90  int size(void) const;
91 
92 protected:
93  MessagePrivate *_this;
94 
95 // Handle the displaying of the message
96 #if ROVIZ_BACKEND == ROVIZ_BACKEND_Dev
97 public:
98  static StreamWidget *initWidget(OutputPrivate *out);
99 #endif
100 };
101 
102 DECLARE_STREAM_OBJECT(Message)
103 
104 #endif // MESSAGE_H
Base class of all objects that can be transported with a stream.
Definition: stream_object.h:39
const Entry & operator[](int index) const
Get an entry of the message.
Definition: message.cpp:42
Used to send messages across streams.
Definition: message.h:24
Base class for all widgets representing a StreamObject.
Definition: stream_widget.h:14
An entry of a message.
Definition: message.h:32
Private part of the Ouput class.
Definition: output_p.h:16
Private part of the Message class.
Definition: message_p.h:12
const Entry & at(int index) const
Get an entry of the message.
Definition: message.cpp:33
int size(void) const
Get the size of a message.
Definition: message.cpp:47
const Entry & entry(const std::string &name) const
Get an entry of the message.
Definition: message.cpp:23