Debugging Leaf, FullLeaf, DiffLeaf

Added unit new tests
diff --git a/model/sync-digest.h b/model/sync-digest.h
index d98868e..52072d2 100644
--- a/model/sync-digest.h
+++ b/model/sync-digest.h
@@ -61,12 +61,18 @@
   /**
    * @brief Obtain a short version of the hash (just first sizeof(size_t) bytes
    *
-   * Side effect: Finalize will be called on `this'
+   * Side effect: finalize() will be called on `this'
    */
   std::size_t
   getHash ();
 
   /**
+   * @brief Finalize digest. All subsequent calls to "operator <<" will fire an exception
+   */
+  void
+  finalize ();
+
+  /**
    * @brief Compare two full digests
    *
    * Side effect: Finalize will be called on `this' and `digest'
@@ -107,12 +113,6 @@
   operator = (Digest &digest) { return *this; }
   
   /**
-   * @brief Finalize digest. All subsequent calls to "operator <<" will fire an exception
-   */
-  void
-  finalize ();
-
-  /**
    * @brief Add size bytes of buffer to the hash
    */
   void
diff --git a/model/sync-full-leaf.cc b/model/sync-full-leaf.cc
index f575056..ee1d3dc 100644
--- a/model/sync-full-leaf.cc
+++ b/model/sync-full-leaf.cc
@@ -37,7 +37,8 @@
 FullLeaf::updateDigest ()
 {
   m_digest.reset ();
-  m_digest << getInfo ().getDigest () << getSeq ().getDigest ();
+  m_digest << getInfo ().getDigest () << *getSeq ().getDigest ();
+  m_digest.finalize ();
 }
 
 // from Leaf
diff --git a/model/sync-leaf.h b/model/sync-leaf.h
index c5f4c20..037e4a5 100644
--- a/model/sync-leaf.h
+++ b/model/sync-leaf.h
@@ -41,7 +41,7 @@
    * @param seq  Initial sequence number of the pointer
    */
   Leaf (NameInfoConstPtr info, const SeqNo &seq);
-  virtual ~Leaf () = 0;
+  virtual ~Leaf ();
   
   /**
    * @brief Get name of the leaf
diff --git a/model/sync-seq-no.cc b/model/sync-seq-no.cc
new file mode 100644
index 0000000..31db4ae
--- /dev/null
+++ b/model/sync-seq-no.cc
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
+ *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "sync-seq-no.h"
+#include <boost/make_shared.hpp>
+
+using namespace boost;
+
+namespace Sync {
+
+DigestConstPtr
+SeqNo::getDigest () const
+{
+  DigestPtr digest = make_shared<Digest> ();
+  *digest << m_session << m_seq;
+  digest->finalize ();
+  return digest;
+}
+
+} // Sync
diff --git a/model/sync-seq-no.h b/model/sync-seq-no.h
index a6005af..354a1b6 100644
--- a/model/sync-seq-no.h
+++ b/model/sync-seq-no.h
@@ -29,14 +29,35 @@
 namespace Sync {
 
 /**
+ * @ingroup sync
  * @brief Sequence number abstraction
- *
- * 
  */
 class SeqNo
 {
 public:
   /**
+   * @brief Copy constructor
+   * @param seq sequence number object to copy from
+   */
+  SeqNo (const SeqNo &seq)
+  {
+    *this = seq;
+  }
+
+  /**
+   * @brief Assignment operator
+   * @param seq sequence number object to copy from
+   */
+  SeqNo &
+  operator = (const SeqNo &seq)
+  {
+    m_session = seq.m_session;
+    m_seq = seq.m_seq;
+
+    return *this;
+  }
+
+  /**
    * @brief Constructor with just sequence number. Session assumed to be zero
    * @param seq Sequence number
    */
@@ -55,7 +76,12 @@
     , m_seq (seq)
   { }
 
-  inline const Digest&
+  /**
+   * @brief Get sequence number digest
+   *
+   * Digest will be calculated every time it is requested
+   */
+  DigestConstPtr
   getDigest () const;
 
   /**
@@ -82,18 +108,17 @@
     return m_session == seq.m_session && m_seq == seq.m_seq;
   }
 
-  SeqNo &
-  operator = (const SeqNo &seq)
-  {
-    m_session = seq.m_session;
-    m_seq = seq.m_seq;
+  /**
+   * @brief Get session id
+   */
+  uint32_t getSession () const
+  { return m_session; }
 
-    return *this;
-  }
-  
-private:
-  inline void
-  updateDigest ();
+  /**
+   * @brief Get sequence number
+   */
+  uint32_t getSeq () const
+  { return m_seq; }
   
 private:
   /**
@@ -112,25 +137,8 @@
    * For now, wrapping sequence number after max to zero is not supported
    */
   uint32_t m_seq;
-
-  Digest m_digest;
 };
 
-
-void
-SeqNo::updateDigest ()
-{
-  m_digest.reset ();
-  m_digest << m_session << m_seq;
-}
-  
-const Digest&
-SeqNo::getDigest () const
-{
-  return m_digest;
-}
-
-
 } // Sync
 
 #endif // SYNC_SEQ_NO_H