minor tweaks
authorCraig Dowell <craigdo@ee.washington.edu>
Tue, 10 Jul 2007 22:17:25 -0700
changeset 1071 4d6d67027c63
parent 1070 fa5ec2180ec4
child 1073 2dc7d2dfd6a4
minor tweaks
src/routing/static-router.cc
src/routing/static-router.h
--- a/src/routing/static-router.cc	Tue Jul 10 17:59:11 2007 -0700
+++ b/src/routing/static-router.cc	Tue Jul 10 22:17:25 2007 -0700
@@ -38,9 +38,24 @@
 StaticRouterLSA::StaticRouterLSA (StaticRouterLSA& lsa)
   : m_linkStateId(lsa.m_linkStateId), m_advertisingRtr(lsa.m_advertisingRtr)
 {
-  NS_DEBUG("StaticRouterLSA Copy Constructor");
-  NS_ASSERT_MSG(IsEmpty(), "The LSA must be empty before copy");
+  NS_ASSERT_MSG(IsEmpty(), "The LSA must be empty in its constructor!");
+  CopyLinkRecords (lsa);
+}
 
+  StaticRouterLSA&
+StaticRouterLSA::operator= (StaticRouterLSA& lsa)
+{
+  m_linkStateId = lsa.m_linkStateId;
+  m_advertisingRtr = lsa.m_advertisingRtr;
+
+  ClearLinkRecords ();
+  CopyLinkRecords (lsa);
+  return *this;
+}
+
+  void
+StaticRouterLSA::CopyLinkRecords (StaticRouterLSA& lsa)
+{
   for ( ListOfLinkRecords_t::iterator i = lsa.m_linkRecords.begin ();
         i != lsa.m_linkRecords.end (); 
         i++)
@@ -55,31 +70,6 @@
     }
 }
 
-  StaticRouterLSA&
-StaticRouterLSA::operator= (StaticRouterLSA& lsa)
-{
-  NS_DEBUG("StaticRouterLSA Operator =");
-  NS_ASSERT_MSG(IsEmpty(), "The LSA must be empty before assignment");
-
-  m_linkStateId = lsa.m_linkStateId;
-  m_advertisingRtr = lsa.m_advertisingRtr;
-
-  for ( ListOfLinkRecords_t::iterator i = lsa.m_linkRecords.begin ();
-        i != lsa.m_linkRecords.end (); 
-        i++)
-    {
-      StaticRouterLinkRecord *pSrc = *i;
-      StaticRouterLinkRecord *pDst = new StaticRouterLinkRecord;
-      pDst->m_linkId = pSrc->m_linkId;
-      pDst->m_linkData = pSrc->m_linkData;
-      pDst->m_linkType = pSrc->m_linkType;
-      m_linkRecords.push_back(pDst);
-      pDst = 0;
-    }
-
-  return *this;
-}
-
 StaticRouterLSA::~StaticRouterLSA()
 {
   NS_DEBUG("StaticRouterLSA::~StaticRouterLSA ()");
--- a/src/routing/static-router.h	Tue Jul 10 17:59:11 2007 -0700
+++ b/src/routing/static-router.h	Tue Jul 10 22:17:25 2007 -0700
@@ -116,6 +116,15 @@
    */
   StaticRouterLSA& operator= (StaticRouterLSA& lsa);
   /**
+   * Copy any Static Router Link Records in a given Static Router Link
+   * State Advertisement to the current LSA.  Existing Link Records are not
+   * deleted -- this is a concatenation of Link Records.
+   *
+   * @see ClearLinkRecords ()
+   * @param lsa The LSA to copy the Link Records from.
+   */
+  void CopyLinkRecords (StaticRouterLSA& lsa);
+  /**
    * Add a given Static Router Link Record to a given Static Router Link
    * State Advertisement.
    *