blob: 0316294fe9b1e817d9904d6c994afe60e0f26a4b [file] [log] [blame]
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2013 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Zhenkai Zhu <zhenkai@cs.ucla.edu>
*/
#ifndef SYNC_LOG_H
#define SYNC_LOG_H
#include "db-helper.h"
#include <sync-state.pb.h>
#include <ccnx-name.h>
typedef boost::shared_ptr<SyncStateMsg> SyncStateMsgPtr;
class SyncLog : public DbHelper
{
public:
SyncLog (const std::string &path, const std::string &localName);
sqlite3_int64
GetNextLocalSeqNo (); // side effect: local seq_no will be increased
void
UpdateDeviceSeqNo (sqlite3_int64 deviceId, sqlite3_int64 seqNo);
// done
void
UpdateDeviceSeqno (const Ccnx::Name &name, sqlite3_int64 seqNo);
// std::string
// LookupForwardingAlias (const std::string &deviceName);
// void
// UpdateForwardingAlias ();
// done
/**
* Create an entry in SyncLog and SyncStateNodes corresponding to the current state of SyncNodes
*/
HashPtr
RememberStateInStateLog ();
// done
sqlite3_int64
LookupSyncLog (const std::string &stateHash);
// done
sqlite3_int64
LookupSyncLog (const Hash &stateHash);
// How difference is exposed will be determined later by the actual protocol
SyncStateMsgPtr
FindStateDifferences (const std::string &oldHash, const std::string &newHash);
SyncStateMsgPtr
FindStateDifferences (const Hash &oldHash, const Hash &newHash);
protected:
// std::string m_localName;
Ccnx::Name m_localName;
sqlite3_int64 m_localDeviceId;
};
#endif // SYNC_LOG_H