blob: ed7a76a2cfeec6c4c559a09e68c90eca9b1c59e6 [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>
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080027#include <ccnx-wrapper.h>
Alexander Afanasyeva199f972013-01-02 19:37:26 -080028
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080029class ActionLog;
30typedef boost::shared_ptr<ActionLog> ActionLogPtr;
31
Alexander Afanasyeva199f972013-01-02 19:37:26 -080032class ActionLog : public SyncLog
33{
34public:
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080035 ActionLog (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &path,
36 const std::string &localName, const std::string &sharedFolder);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080037
Alexander Afanasyeva199f972013-01-02 19:37:26 -080038 void
39 AddActionUpdate (const std::string &filename,
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080040 const Hash &hash,
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080041 time_t wtime,
Alexander Afanasyev334aac82013-01-18 14:06:39 -080042 int mode,
43 int seg_num);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080044
45 void
46 AddActionMove (const std::string &oldFile, const std::string &newFile);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080047
Alexander Afanasyeva199f972013-01-02 19:37:26 -080048 void
49 AddActionDelete (const std::string &filename);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080050
51private:
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080052 boost::tuple<sqlite3_int64, sqlite3_int64, sqlite3_int64, std::string>
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080053 GetExistingRecord (const std::string &filename);
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080054
55 static void
56 apply_action_xFun (sqlite3_context *context, int argc, sqlite3_value **argv);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080057
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080058private:
59 Ccnx::CcnxWrapperPtr m_ccnx;
60 Ccnx::Name m_sharedFolderName;
Alexander Afanasyeva199f972013-01-02 19:37:26 -080061};
62
63#endif // ACTION_LOG_H