Split //aos/common:queues into queues and messages.
These were already distinct concepts; probably makes more sense for them
to be separate. Also it makes it easier for teams to pick and choose
what parts of aos they want to use.
Change-Id: I3e6af61c8e4c1e337714f44b4e7f74a3b8f88060
diff --git a/aos/common/BUILD b/aos/common/BUILD
index 7a15731..0e109fb 100644
--- a/aos/common/BUILD
+++ b/aos/common/BUILD
@@ -144,19 +144,30 @@
)
cc_library(
- name = 'queues',
+ name = 'messages',
srcs = [
- 'queue.cc',
+ 'message.cc',
],
hdrs = [
+ 'message.h',
+ ],
+ deps = [
+ ':time',
+ ':macros',
+ ':byteorder',
+ ],
+)
+
+cc_library(
+ name = 'queues',
+ srcs = [],
+ hdrs = [
'queue.h',
],
deps = [
'//aos/linux_code/ipc_lib:queue',
- ':time',
- ':macros',
'//aos/linux_code:queue',
- ':byteorder',
+ ':messages',
],
)
diff --git a/aos/common/queue.cc b/aos/common/message.cc
similarity index 97%
rename from aos/common/queue.cc
rename to aos/common/message.cc
index ba85a72..818c945 100644
--- a/aos/common/queue.cc
+++ b/aos/common/message.cc
@@ -1,4 +1,4 @@
-#include "aos/common/queue.h"
+#include "aos/common/message.h"
#include <inttypes.h>
#include <chrono>
diff --git a/aos/common/message.h b/aos/common/message.h
new file mode 100644
index 0000000..8ae7f16
--- /dev/null
+++ b/aos/common/message.h
@@ -0,0 +1,53 @@
+#ifndef AOS_COMMON_MESSAGE_H_
+#define AOS_COMMON_MESSAGE_H_
+
+#include "aos/common/time.h"
+
+namespace aos {
+
+struct MessageType;
+
+// This class is a base class for all messages sent over queues.
+// All of the methods are overloaded in (generated) subclasses to do the same
+// thing for the whole thing.
+class Message {
+ public:
+ // The time that the message was sent at.
+ monotonic_clock::time_point sent_time;
+
+ Message() : sent_time(monotonic_clock::min_time) {}
+
+ // Zeros out the time.
+ void Zero();
+ // Returns the size of the common fields.
+ static size_t Size() { return sizeof(sent_time); }
+
+ // Deserializes the common fields from the buffer.
+ size_t Deserialize(const char *buffer);
+ // Serializes the common fields into the buffer.
+ size_t Serialize(char *buffer) const;
+
+ // Populates sent_time with the current time.
+ void SetTimeToNow() { sent_time = monotonic_clock::now(); }
+
+ // Writes the contents of the message to the provided buffer.
+ size_t Print(char *buffer, int length) const;
+
+ // Compares two messages for equality, excluding their sent_time.
+ bool EqualsNoTime(const Message & /*other*/) const { return true; }
+
+ static const MessageType *GetType();
+};
+
+// Specializations for the Builders will be automatically generated in the .q.h
+// header files with all of the handy builder methods.
+template <class T>
+class MessageBuilder {
+ public:
+ typedef T Message;
+ bool Send();
+};
+
+} // namespace aos
+
+#endif // AOS_COMMON_MESSAGE_H_
diff --git a/aos/common/queue.h b/aos/common/queue.h
index 7f43a3e..97947ad 100644
--- a/aos/common/queue.h
+++ b/aos/common/queue.h
@@ -5,47 +5,11 @@
#include "aos/common/macros.h"
#include "aos/linux_code/ipc_lib/queue.h"
-#include "aos/common/time.h"
+#include "aos/common/message.h"
namespace aos {
-struct MessageType;
-
-// This class is a base class for all messages sent over queues.
-// All of the methods are overloaded in (generated) subclasses to do the same
-// thing for the whole thing.
-class Message {
- public:
- // The time that the message was sent at.
- monotonic_clock::time_point sent_time;
-
- Message() : sent_time(monotonic_clock::min_time) {}
-
- // Zeros out the time.
- void Zero();
- // Returns the size of the common fields.
- static size_t Size() { return sizeof(sent_time); }
-
- // Deserializes the common fields from the buffer.
- size_t Deserialize(const char *buffer);
- // Serializes the common fields into the buffer.
- size_t Serialize(char *buffer) const;
-
- // Populates sent_time with the current time.
- void SetTimeToNow() { sent_time = monotonic_clock::now(); }
-
- // Writes the contents of the message to the provided buffer.
- size_t Print(char *buffer, int length) const;
-
- // Compares two messages for equality, excluding their sent_time.
- bool EqualsNoTime(const Message & /*other*/) const { return true; }
-
- static const MessageType *GetType();
-};
-
template <class T> class Queue;
-template <class T> class MessageBuilder;
-template <class T> class ScopedMessagePtr;
// A ScopedMessagePtr<> manages a queue message pointer.
// It frees it properly when the ScopedMessagePtr<> goes out of scope or gets
@@ -145,15 +109,6 @@
DISALLOW_COPY_AND_ASSIGN(ScopedMessagePtr<T>);
};
-// Specializations for the Builders will be automatically generated in the .q.h
-// header files with all of the handy builder methods.
-template <class T>
-class MessageBuilder {
- public:
- typedef T Message;
- bool Send();
-};
-
// TODO(aschuh): Base class
// T must be a Message with the same format as the messages generated by
// the .q files.