libhidl: introduce Return<void>

Return<void> is a specialization of the generic Return template intended
to be returned from "void" HIDL methods.  It simply encapsulates the
Status object.  With Return<void>, we can auto-generate Return-returning
C++ code all HIDL methods.

b/31367910
b/31348667

Change-Id: If56b4da5117c52e8a1e13bb6d5114ecf576868b4
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/include/hidl/Status.h b/include/hidl/Status.h
index aa8f1b2..59e4d65 100644
--- a/include/hidl/Status.h
+++ b/include/hidl/Status.h
@@ -147,20 +147,33 @@
 std::stringstream& operator<< (std::stringstream& stream, const Status& s);
 
 template<typename T> class Return {
+private:
+      T val {};
+      Status status {};
 public:
-      T val;
-      Status status;
-public:
-      Return(T v) : val(v), status(Status::ok()) { }
-      Return(Status s) : status(s) {
-          // TODO(malchev): Spew a LOG error here
-      }
-      ~Return() {
-          // TODO(malchev): Assert that status isOk() if it hasn't been checked
-      }
+      Return(T v) : val{v} {}
+      Return(Status s) : status(s) {}
       operator T() { return val; }
+      const Status& getStatus() const {
+          return status;
+      }
 };
 
+template<> class Return<void> {
+private:
+      Status status {};
+public:
+      Return() = default;
+      Return(Status s) : status(s) {}
+      const Status& getStatus() const {
+          return status;
+      }
+};
+
+static inline Return<void> Void() {
+    return Return<void>();
+}
+
 }  // namespace hardware
 }  // namespace android