blob: c75fcf726483039d80d996933e2cc8b22f5748f9 [file] [log] [blame]
Alexander Afanasyev71b43e72012-12-27 01:03:43 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Alexander Afanasyeva199f972013-01-02 19:37:26 -08003 * Copyright (c) 2013 University of California, Los Angeles
Alexander Afanasyev71b43e72012-12-27 01:03:43 -08004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20 */
21
22#ifndef SYNC_LOG_H
23#define SYNC_LOG_H
24
Alexander Afanasyeva199f972013-01-02 19:37:26 -080025#include "db-helper.h"
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -080026#include <sync-state.pb.h>
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080027#include <ccnx-name.h>
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -080028
29typedef boost::shared_ptr<SyncStateMsg> SyncStateMsgPtr;
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080030
Alexander Afanasyeva199f972013-01-02 19:37:26 -080031class SyncLog : public DbHelper
32{
33public:
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080034 SyncLog (const boost::filesystem::path &path, const std::string &localName);
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080035
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080036 sqlite3_int64
37 GetNextLocalSeqNo (); // side effect: local seq_no will be increased
38
39 void
40 UpdateDeviceSeqNo (sqlite3_int64 deviceId, sqlite3_int64 seqNo);
41
Alexander Afanasyeva199f972013-01-02 19:37:26 -080042 // done
43 void
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080044 UpdateDeviceSeqno (const Ccnx::Name &name, sqlite3_int64 seqNo);
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080045
Alexander Afanasyeva199f972013-01-02 19:37:26 -080046 // std::string
47 // LookupForwardingAlias (const std::string &deviceName);
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080048
Alexander Afanasyeva199f972013-01-02 19:37:26 -080049 // void
50 // UpdateForwardingAlias ();
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080051
Alexander Afanasyeva199f972013-01-02 19:37:26 -080052 // done
53 /**
54 * Create an entry in SyncLog and SyncStateNodes corresponding to the current state of SyncNodes
55 */
56 HashPtr
57 RememberStateInStateLog ();
58
59 // done
60 sqlite3_int64
61 LookupSyncLog (const std::string &stateHash);
62
63 // done
64 sqlite3_int64
65 LookupSyncLog (const Hash &stateHash);
66
67 // How difference is exposed will be determined later by the actual protocol
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -080068 SyncStateMsgPtr
Alexander Afanasyeva199f972013-01-02 19:37:26 -080069 FindStateDifferences (const std::string &oldHash, const std::string &newHash);
70
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -080071 SyncStateMsgPtr
Alexander Afanasyeva199f972013-01-02 19:37:26 -080072 FindStateDifferences (const Hash &oldHash, const Hash &newHash);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080073
74protected:
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080075 // std::string m_localName;
76 Ccnx::Name m_localName;
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080077
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080078 sqlite3_int64 m_localDeviceId;
Alexander Afanasyeva199f972013-01-02 19:37:26 -080079};
80
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080081
82#endif // SYNC_LOG_H