blob: 28b221a212057af5b1f7bc693cde398326cfaa9c [file] [log] [blame]
Alexander Afanasyeva199f972013-01-02 19:37:26 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012-2013 University of California, Los Angeles
4 *
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 ACTION_LOG_H
23#define ACTION_LOG_H
24
25#include "sync-log.h"
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080026#include <boost/tuple/tuple.hpp>
Zhenkai Zhu337e0732013-01-18 20:27:14 -080027#include <action-item.pb.h>
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080028#include <ccnx-wrapper.h>
Alexander Afanasyeva199f972013-01-02 19:37:26 -080029
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080030class ActionLog;
31typedef boost::shared_ptr<ActionLog> ActionLogPtr;
32
Alexander Afanasyeva199f972013-01-02 19:37:26 -080033class ActionLog : public SyncLog
34{
35public:
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080036 ActionLog (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &path,
37 const std::string &localName, const std::string &sharedFolder);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080038
Alexander Afanasyeva199f972013-01-02 19:37:26 -080039 void
40 AddActionUpdate (const std::string &filename,
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080041 const Hash &hash,
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080042 time_t wtime,
Alexander Afanasyev334aac82013-01-18 14:06:39 -080043 int mode,
44 int seg_num);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080045
46 void
47 AddActionMove (const std::string &oldFile, const std::string &newFile);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080048
Alexander Afanasyeva199f972013-01-02 19:37:26 -080049 void
50 AddActionDelete (const std::string &filename);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080051
52private:
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080053 boost::tuple<sqlite3_int64, sqlite3_int64, sqlite3_int64, std::string>
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080054 GetExistingRecord (const std::string &filename);
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080055
56 static void
57 apply_action_xFun (sqlite3_context *context, int argc, sqlite3_value **argv);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080058
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080059private:
60 Ccnx::CcnxWrapperPtr m_ccnx;
61 Ccnx::Name m_sharedFolderName;
Alexander Afanasyeva199f972013-01-02 19:37:26 -080062};
63
64#endif // ACTION_LOG_H