Replace Get* methods returning unique_ptr with reference alternative

Existing code created temporarily objects and returned them to the
client. It was not efficient and error-prone as client code could
retrieve pointers to internal objects without keeping unique_ptr alive.

Change-Id: I9e17c8d9f66dfc9f52ce9ffc9a31992b16b00461
Reviewed-on: https://weave-review.googlesource.com/1672
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/examples/daemon/speaker/speaker.cc b/examples/daemon/speaker/speaker.cc
index 89595b0..cd7d62f 100644
--- a/examples/daemon/speaker/speaker.cc
+++ b/examples/daemon/speaker/speaker.cc
@@ -72,10 +72,10 @@
       return;
     LOG(INFO) << "received command: " << cmd->GetName();
 
-    auto params = cmd->GetParameters();
+    const auto& params = cmd->GetParameters();
     // Handle volume parameter
     int32_t volume_value = 0;
-    if (params->GetInteger("volume", &volume_value)) {
+    if (params.GetInteger("volume", &volume_value)) {
       // Display this command in terminal.
       LOG(INFO) << cmd->GetName() << " volume: " << volume_value;
 
@@ -89,7 +89,7 @@
 
     // Handle isMuted parameter
     bool isMuted_status = false;
-    if (params->GetBoolean("isMuted", &isMuted_status)) {
+    if (params.GetBoolean("isMuted", &isMuted_status)) {
       // Display this command in terminal.
       LOG(INFO) << cmd->GetName() << " is "
                 << (isMuted_status ? "muted" : "not muted");
@@ -111,9 +111,9 @@
     if (!cmd)
       return;
     LOG(INFO) << "received command: " << cmd->GetName();
-    auto params = cmd->GetParameters();
+    const auto& params = cmd->GetParameters();
     std::string requested_state;
-    if (params->GetString("state", &requested_state)) {
+    if (params.GetString("state", &requested_state)) {
       LOG(INFO) << cmd->GetName() << " state: " << requested_state;
 
       bool new_speaker_status = requested_state == "on";