apps: Switch ndn::App::GetId() to use application ID on the node

Previously, GetId() used ID of the underlying application face, which
is less convenient for simulation trace analyses.

Change-Id: I403182ecb4b9e8fb010c4c25ab007c1e274bc86a
diff --git a/apps/ndn-app.cpp b/apps/ndn-app.cpp
index 802f697..a1c9e80 100644
--- a/apps/ndn-app.cpp
+++ b/apps/ndn-app.cpp
@@ -61,6 +61,7 @@
 App::App()
   : m_active(false)
   , m_face(0)
+  , m_appId(std::numeric_limits<uint32_t>::max())
 {
 }
 
@@ -69,6 +70,21 @@
 }
 
 void
+App::DoInitialize()
+{
+  NS_LOG_FUNCTION_NOARGS();
+
+  // find out what is application id on the node
+  for (uint32_t id = 0; id < GetNode()->GetNApplications(); ++id) {
+    if (GetNode()->GetApplication(id) == this) {
+      m_appId = id;
+    }
+  }
+
+  Application::DoInitialize();
+}
+
+void
 App::DoDispose(void)
 {
   NS_LOG_FUNCTION_NOARGS();
@@ -82,10 +98,7 @@
 uint32_t
 App::GetId() const
 {
-  if (m_face == 0)
-    return (uint32_t)-1;
-  else
-    return m_face->getId();
+  return m_appId;
 }
 
 void