api: Major API change.  OnInterest/OnData callbacks now use just references, not shared pointers

If shared pointer is necessary, it can be obtained using
.shared_from_this() on Interest or Data object.

This commit also corrects all internal uses of expressInterest/setIntersetFilter.

Change-Id: I20207a5789fd189902f2c6e3827260b6b27a2514
diff --git a/src/security/validator-null.hpp b/src/security/validator-null.hpp
index 27dc63d..d1d8faa 100644
--- a/src/security/validator-null.hpp
+++ b/src/security/validator-null.hpp
@@ -21,20 +21,20 @@
   
 protected:
   virtual void
-  checkPolicy (const shared_ptr<const Data>& data, 
+  checkPolicy (const Data& data, 
                int stepCount, 
                const OnDataValidated &onValidated, 
                const OnDataValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps)
-  { onValidated(data); }
+  { onValidated(data.shared_from_this()); }
   
   virtual void
-  checkPolicy (const shared_ptr<const Interest>& interest, 
+  checkPolicy (const Interest& interest, 
                int stepCount, 
                const OnInterestValidated &onValidated, 
                const OnInterestValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps)
-  { onValidated(interest); }
+  { onValidated(interest.shared_from_this()); }
 };
 
 }
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index 18dc9bf..1b9dcb9 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -75,7 +75,7 @@
 { onValidationFailed(data); }
 
 void
-ValidatorRegex::checkPolicy(const shared_ptr<const Data> &data, 
+ValidatorRegex::checkPolicy(const Data& data, 
                             int stepCount, 
                             const OnDataValidated &onValidated, 
                             const OnDataValidationFailed &onValidationFailed,
@@ -83,25 +83,25 @@
 {
   if(m_stepLimit == stepCount){
     _LOG_DEBUG("reach the maximum steps of verification");
-    onValidationFailed(data);
+    onValidationFailed(data.shared_from_this());
     return;
   }
   
   RuleList::iterator it = m_mustFailVerify.begin();
   for(; it != m_mustFailVerify.end(); it++)
-    if((*it)->satisfy(*data))
+    if((*it)->satisfy(data))
       {
-        onValidationFailed(data);
+        onValidationFailed(data.shared_from_this());
         return;
       }
 
   it = m_verifyPolicies.begin();
   for(; it != m_verifyPolicies.end(); it++)
     {
-      if((*it)->satisfy(*data))
+      if((*it)->satisfy(data))
         {
           try{
-            SignatureSha256WithRsa sig(data->getSignature());                
+            SignatureSha256WithRsa sig(data.getSignature());                
             
             Name keyLocatorName = sig.getKeyLocator().getName();
             shared_ptr<const Certificate> trustedCert;
@@ -111,20 +111,20 @@
               trustedCert = m_trustAnchors[keyLocatorName];
             
             if(static_cast<bool>(trustedCert)){
-              if(verifySignature(*data, sig, trustedCert->getPublicKeyInfo()))
-                onValidated(data);
+              if(verifySignature(data, sig, trustedCert->getPublicKeyInfo()))
+                onValidated(data.shared_from_this());
               else
-                onValidationFailed(data);
+                onValidationFailed(data.shared_from_this());
               
               return;
             }
             else{
               // _LOG_DEBUG("KeyLocator is not trust anchor");                
               OnDataValidated onKeyValidated = bind(&ValidatorRegex::onCertificateValidated, this, 
-                                                    _1, data, onValidated, onValidationFailed);
+                                                    _1, data.shared_from_this(), onValidated, onValidationFailed);
               
               OnDataValidationFailed onKeyValidationFailed = bind(&ValidatorRegex::onCertificateValidationFailed, this, 
-                                                                  _1, data, onValidationFailed);              
+                                                                  _1, data.shared_from_this(), onValidationFailed);              
 
               shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(Interest(boost::cref(sig.getKeyLocator().getName())), 
                                                                                       onKeyValidated,
@@ -136,17 +136,17 @@
             }
           }catch(SignatureSha256WithRsa::Error &e){
             _LOG_DEBUG("ValidatorRegex Error: " << e.what());
-            onValidationFailed(data);
+            onValidationFailed(data.shared_from_this());
             return;
           }catch(KeyLocator::Error &e){
             _LOG_DEBUG("ValidatorRegex Error: " << e.what());
-            onValidationFailed(data);
+            onValidationFailed(data.shared_from_this());
             return;
           }
         }
     }
 
-  onValidationFailed(data);
+  onValidationFailed(data.shared_from_this());
   return;
 }
 
diff --git a/src/security/validator-regex.hpp b/src/security/validator-regex.hpp
index 6b44d13..d6b9b1d 100644
--- a/src/security/validator-regex.hpp
+++ b/src/security/validator-regex.hpp
@@ -48,19 +48,19 @@
 
 protected:
   virtual void
-  checkPolicy (const shared_ptr<const Data>& data, 
+  checkPolicy (const Data& data, 
                int stepCount, 
                const OnDataValidated &onValidated, 
                const OnDataValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps);
 
   virtual void
-  checkPolicy (const shared_ptr<const Interest>& interest, 
+  checkPolicy (const Interest& interest, 
                int stepCount, 
                const OnInterestValidated &onValidated, 
                const OnInterestValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps)
-  { onValidationFailed(interest); }
+  { onValidationFailed(interest.shared_from_this()); }
 
   void
   onCertificateValidated(const shared_ptr<const Data> &signCertificate, 
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index ebb8b55..8b1c17f 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -26,7 +26,7 @@
 {}
 
 void
-Validator::validate(const shared_ptr<const Interest> &interest, 
+Validator::validate(const Interest& interest, 
                     const OnInterestValidated &onValidated, 
                     const OnInterestValidationFailed &onValidationFailed,
                     int stepCount)
@@ -40,7 +40,7 @@
         throw Error("Face should be set prior to verify method to call");
       
       vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
-      OnFailure onFailure = bind(onValidationFailed, interest);
+      OnFailure onFailure = bind(onValidationFailed, interest.shared_from_this());
       for(; it != nextSteps.end(); it++)
         m_face->expressInterest((*it)->m_interest,
                                 bind(&Validator::onData, this, _1, _2, *it), 
@@ -57,7 +57,7 @@
 }
 
 void
-Validator::validate(const shared_ptr<const Data> &data, 
+Validator::validate(const Data& data, 
                     const OnDataValidated &onValidated, 
                     const OnDataValidationFailed &onValidationFailed,
                     int stepCount)
@@ -71,7 +71,7 @@
         throw Error("Face should be set prior to verify method to call");
 
       vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
-      OnFailure onFailure = bind(onValidationFailed, data);
+      OnFailure onFailure = bind(onValidationFailed, data.shared_from_this());
       for(; it != nextSteps.end(); it++)
         m_face->expressInterest((*it)->m_interest,
                                 bind(&Validator::onData, this, _1, _2, *it), 
@@ -88,22 +88,22 @@
 }
 
 void
-Validator::onData(const shared_ptr<const Interest> &interest, 
-                  const shared_ptr<const Data> &data, 
-                  shared_ptr<ValidationRequest> nextStep)
+Validator::onData(const Interest& interest, 
+                  Data& data, 
+                  const shared_ptr<ValidationRequest>& nextStep)
 {
   validate(data, nextStep->m_onValidated, nextStep->m_onDataValidated, nextStep->m_stepCount);
 }
 
 void
-Validator::onTimeout(const shared_ptr<const Interest> &interest, 
+Validator::onTimeout(const Interest& interest, 
                      int retry, 
                      const OnFailure &onFailure, 
-                     shared_ptr<ValidationRequest> nextStep)
+                     const shared_ptr<ValidationRequest>& nextStep)
 {
   if (retry > 0)
     // Issue the same expressInterest except decrement retry.
-    m_face->expressInterest(*interest, 
+    m_face->expressInterest(interest, 
                             bind(&Validator::onData, this, _1, _2, nextStep), 
                             bind(&Validator::onTimeout, this, _1, retry - 1, onFailure, nextStep));
   else
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 1d74aa2..5a1062d 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -39,7 +39,7 @@
    * @param onValidationFailed If the Data validation fails, this calls onValidationFailed(data).
    */
   void
-  validate (const shared_ptr<const Data> &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
+  validate (const Data& data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
   { validate (data, onValidated, onValidationFailed, 0); }
 
   /**
@@ -50,7 +50,7 @@
    * @param onValidationFailed If the Interest validation fails, this calls onValidationFailed(interest).
    */
   void
-  validate (const shared_ptr<const Interest> &interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed)
+  validate (const Interest& interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed)
   { validate (interest, onValidated, onValidationFailed, 0); }
 
   /*****************************************
@@ -95,7 +95,7 @@
    * @param nextSteps On return, contains the next validation step.
    */
   virtual void
-  checkPolicy (const shared_ptr<const Data> &data, 
+  checkPolicy (const Data& data, 
                int stepCount, 
                const OnDataValidated &onValidated, 
                const OnDataValidationFailed &onValidationFailed,
@@ -114,7 +114,7 @@
    * @return the indication of next validation step, null if there is no further step.
    */
   virtual void
-  checkPolicy (const shared_ptr<const Interest> &interest, 
+  checkPolicy (const Interest& interest, 
                int stepCount, 
                const OnInterestValidated &onValidated, 
                const OnInterestValidationFailed &onValidationFailed,
@@ -125,25 +125,25 @@
   
   /// @brief Process the received certificate.
   void
-  onData (const shared_ptr<const Interest> &interest, 
-          const shared_ptr<const Data> &data, 
-          shared_ptr<ValidationRequest> nextStep);
+  onData (const Interest& interest, 
+          Data& data, 
+          const shared_ptr<ValidationRequest>& nextStep);
   
   /// @brief Re-express the interest if it times out.
   void
-  onTimeout (const shared_ptr<const Interest> &interest, 
+  onTimeout (const Interest& interest, 
              int retry, 
              const OnFailure &onFailure, 
-             shared_ptr<ValidationRequest> nextStep);
+             const shared_ptr<ValidationRequest>& nextStep);
 
   void
-  validate (const shared_ptr<const Data> &data, 
+  validate (const Data& data, 
             const OnDataValidated &onValidated, 
             const OnDataValidationFailed &onValidationFailed, 
             int stepCount);
 
   void
-  validate (const shared_ptr<const Interest> &interest, 
+  validate (const Interest& interest, 
             const OnInterestValidated &onValidated, 
             const OnInterestValidationFailed &onValidationFailed, 
             int stepCount);