docs: improve example applications

refs: #1976

Change-Id: I82e719ac497d3cb4eab74c1c6d02bcaa050388eb
diff --git a/examples/producer.cpp b/examples/producer.cpp
index 3b5ff07..81df7df 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2015 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -33,11 +33,22 @@
 // Additional nested namespace could be used to prevent/limit name contentions
 namespace examples {
 
-class Producer
+class Producer : noncopyable
 {
 public:
   void
-  onInterest(const Name& name, const Interest& interest)
+  run()
+  {
+    m_face.setInterestFilter("/example/testApp",
+                             bind(&Producer::onInterest, this, _1, _2),
+                             RegisterPrefixSuccessCallback(),
+                             bind(&Producer::onRegisterFailed, this, _1, _2));
+    m_face.processEvents();
+  }
+
+private:
+  void
+  onInterest(const InterestFilter& filter, const Interest& interest)
   {
     std::cout << "<< I: " << interest << std::endl;
 
@@ -50,40 +61,31 @@
     static const std::string content = "HELLO KITTY";
 
     // Create Data packet
-    Data data;
-    data.setName(dataName);
-    data.setFreshnessPeriod(time::seconds(10));
-    data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
+    shared_ptr<Data> data = make_shared<Data>();
+    data->setName(dataName);
+    data->setFreshnessPeriod(time::seconds(10));
+    data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
 
     // Sign Data packet with default identity
-    m_keyChain.sign(data);
+    m_keyChain.sign(*data);
     // m_keyChain.sign(data, <identityName>);
     // m_keyChain.sign(data, <certificate>);
 
     // Return Data packet to the requester
-    std::cout << ">> D: " << data << std::endl;
-    m_face.put(data);
+    std::cout << ">> D: " << *data << std::endl;
+    m_face.put(*data);
   }
 
 
   void
-  onRegisterFailed(const std::string& reason)
+  onRegisterFailed(const Name& prefix, const std::string& reason)
   {
-    std::cerr << "ERROR: Failed to register prefix in local hub's daemon (" << reason << ")"
+    std::cerr << "ERROR: Failed to register prefix \""
+              << prefix << "\" in local hub's daemon (" << reason << ")"
               << std::endl;
     m_face.shutdown();
   }
 
-  void
-  run()
-  {
-    m_face.setInterestFilter("/example/testApp",
-                             bind(&Producer::onInterest, this, _1, _2),
-                             RegisterPrefixSuccessCallback(),
-                             bind(&Producer::onRegisterFailed, this, _2));
-    m_face.processEvents();
-  }
-
 private:
   Face m_face;
   KeyChain m_keyChain;
@@ -95,11 +97,11 @@
 int
 main(int argc, char** argv)
 {
+  ndn::examples::Producer producer;
   try {
-    ndn::examples::Producer producer;
     producer.run();
   }
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
   }
   return 0;