Skip to content

Commit

Permalink
build: == Dependency change == ChronoSync now depends on ndn-cxx library
Browse files Browse the repository at this point in the history
  • Loading branch information
bruinfish committed Apr 30, 2014
1 parent a873d64 commit 7c64e5c
Show file tree
Hide file tree
Showing 38 changed files with 256 additions and 257 deletions.
4 changes: 2 additions & 2 deletions src/sync-diff-leaf.cc
Expand Up @@ -17,12 +17,12 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#include "sync-diff-leaf.h"
#include <boost/throw_exception.hpp>
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info;
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info;

using namespace Sync::Error;

Expand Down
4 changes: 2 additions & 2 deletions src/sync-diff-leaf.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_DIFF_LEAF_H
Expand All @@ -40,7 +40,7 @@ enum Operation

/**
* @ingroup sync
* @brief Annotated SYNC leaf
* @brief Annotated SYNC leaf
*/
class DiffLeaf : public Leaf
{
Expand Down
6 changes: 3 additions & 3 deletions src/sync-diff-state-container.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_DIFF_STATE_CONTAINER_H
Expand All @@ -40,7 +40,7 @@ namespace mi = boost::multi_index;

namespace Sync {

/// @cond include_hidden
/// @cond include_hidden
struct sequenced { };
struct timed { };
/// @endcond
Expand All @@ -59,7 +59,7 @@ struct DiffStateContainer : public mi::multi_index_container<
DigestPtrHash,
DigestPtrEqual
>
,
,
// sequenced index to access older/newer element (like in list)
mi::sequenced<mi::tag<sequenced> >
>
Expand Down
8 changes: 4 additions & 4 deletions src/sync-diff-state.cc
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#include "sync-diff-state.h"
Expand All @@ -43,7 +43,7 @@ DiffStatePtr
DiffState::diff () const
{
DiffStatePtr ret = make_shared<DiffState> ();

DiffStatePtr state = m_next;
while (state != 0)
{
Expand Down Expand Up @@ -71,10 +71,10 @@ DiffState::operator += (const DiffState &state)
BOOST_ASSERT (false);
}
}

return *this;
}

// from State
boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
DiffState::update (NameInfoConstPtr info, const SeqNo &seq)
Expand Down
8 changes: 4 additions & 4 deletions src/sync-diff-state.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_DIFF_STATE_H
Expand Down Expand Up @@ -67,7 +67,7 @@ class DiffState : public State
*/
DigestConstPtr
getDigest () const { return m_digest; }

/**
* @brief Accumulate differences from `this' state to the most current state
* @returns Accumulated differences from `this' state to the most current state
Expand All @@ -84,14 +84,14 @@ class DiffState : public State
*/
DiffState&
operator += (const DiffState &state);

// from State
virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
update (NameInfoConstPtr info, const SeqNo &seq);

virtual bool
remove (NameInfoConstPtr info);

private:
DiffStatePtr m_next;
DigestConstPtr m_digest;
Expand Down
25 changes: 12 additions & 13 deletions src/sync-digest.cc
Expand Up @@ -17,16 +17,16 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#include "sync-digest.h"
#include <string.h>

#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;

// for printing, may be disabled in optimized build

Expand Down Expand Up @@ -89,7 +89,7 @@ struct hex_to_4_bit
value = lookup_table [(unsigned)ch];
if (value == -1)
BOOST_THROW_EXCEPTION (Sync::Error::DigestCalculationError () << errmsg_info_int ((int)ch));

return value;
}
};
Expand Down Expand Up @@ -146,7 +146,7 @@ Digest::finalize ()
if (!m_buffer.empty ()) return;

m_buffer.resize (HASH_FUNCTION_LEN);

unsigned int tmp;
int ok = EVP_DigestFinal_ex (m_context,
&m_buffer[0], &tmp);
Expand All @@ -160,14 +160,14 @@ std::size_t
Digest::getHash () const
{
if (isZero ()) return 0;

if (sizeof (std::size_t) > m_buffer.size ())
{
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Hash is not zero and length is less than size_t")
<< errmsg_info_int (m_buffer.size ()));
}

// just getting first sizeof(std::size_t) bytes
// not ideal, but should work pretty well
return *(reinterpret_cast<const std::size_t*> (&m_buffer[0]));
Expand All @@ -192,7 +192,7 @@ void
Digest::update (const uint8_t *buffer, size_t size)
{
// cout << "Update: " << (void*)buffer << " / size: " << size << "\n";

// cannot update Digest when it has been finalized
if (!m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
Expand All @@ -209,7 +209,7 @@ Digest::update (const uint8_t *buffer, size_t size)
Digest &
Digest::operator << (const Digest &src)
{
if (src.m_buffer.empty ())
if (src.m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has not been yet finalized"));

Expand All @@ -222,7 +222,7 @@ std::ostream &
operator << (std::ostream &os, const Digest &digest)
{
BOOST_ASSERT (!digest.m_buffer.empty ());

std::ostreambuf_iterator<char> out_it (os); // ostream iterator
// need to encode to base64
copy (string_from_binary (digest.m_buffer.begin ()),
Expand All @@ -241,7 +241,7 @@ operator >> (std::istream &is, Digest &digest)
if (str.size () == 0)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Input is empty"));

// uint8_t padding = (3 - str.size () % 3) % 3;
// for (uint8_t i = 0; i < padding; i++) str.push_back ('=');

Expand All @@ -251,7 +251,7 @@ operator >> (std::istream &is, Digest &digest)
<< errmsg_info_str ("Digest has been already finalized"));

digest.m_buffer.clear ();

copy (string_to_binary (str.begin ()),
string_to_binary (str.end ()),
std::back_inserter (digest.m_buffer));
Expand All @@ -261,4 +261,3 @@ operator >> (std::istream &is, Digest &digest)


} // Sync

12 changes: 6 additions & 6 deletions src/sync-digest.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_DIGEST_H
Expand Down Expand Up @@ -47,7 +47,7 @@ class Digest
*/
bool
empty () const;

/**
* @brief Reset digest to the initial state
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ class Digest
bool
operator != (const Digest &digest) const
{ return ! (*this == digest); }


/**
* @brief Add existing digest to digest calculation
Expand Down Expand Up @@ -116,11 +116,11 @@ class Digest
*/
bool
isZero () const;

private:
Digest &
operator = (Digest &digest) { (void)digest; return *this; }

/**
* @brief Add size bytes of buffer to the hash
*/
Expand All @@ -132,7 +132,7 @@ class Digest

friend std::istream &
operator >> (std::istream &is, Digest &digest);

private:
EVP_MD_CTX *m_context;
std::vector<uint8_t> m_buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/sync-event.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_EVENT_H
Expand Down
2 changes: 1 addition & 1 deletion src/sync-full-leaf.cc
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#include "sync-full-leaf.h"
Expand Down
8 changes: 4 additions & 4 deletions src/sync-full-leaf.h
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_FULL_LEAF_H
Expand All @@ -29,7 +29,7 @@ namespace Sync {

/**
* @ingroup sync
* @brief SYNC leaf for the full state (with support of Digest calculation)
* @brief SYNC leaf for the full state (with support of Digest calculation)
*/
class FullLeaf : public Leaf
{
Expand All @@ -49,12 +49,12 @@ class FullLeaf : public Leaf
* (including updates of child classes)
*/
const Digest &
getDigest () const { return m_digest; }
getDigest () const { return m_digest; }

// from Leaf
virtual void
setSeq (const SeqNo &seq);

private:
void
updateDigest ();
Expand Down
2 changes: 1 addition & 1 deletion src/sync-full-state.cc
Expand Up @@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#include "sync-full-state.h"
Expand Down
8 changes: 4 additions & 4 deletions src/sync-full-state.h
Expand Up @@ -17,13 +17,13 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/

#ifndef SYNC_FULL_STATE_H
#define SYNC_FULL_STATE_H

#include <ndn-cpp-dev/util/time.hpp>
#include <ndn-cxx/util/time.hpp>
#include "sync-state.h"

namespace Sync {
Expand Down Expand Up @@ -61,14 +61,14 @@ class FullState : public State
*/
DigestConstPtr
getDigest ();

// from State
virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
update (NameInfoConstPtr info, const SeqNo &seq);

virtual bool
remove (NameInfoConstPtr info);

private:
ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
DigestPtr m_digest;
Expand Down

0 comments on commit 7c64e5c

Please sign in to comment.