blob: 33da6d162b23253d99ff75d3c80c3d39f7daea00 [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
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080025#include "db-helper.h"
Alexander Afanasyeva199f972013-01-02 19:37:26 -080026#include "sync-log.h"
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080027
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080028#include <boost/tuple/tuple.hpp>
Zhenkai Zhu337e0732013-01-18 20:27:14 -080029#include <action-item.pb.h>
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080030#include <ccnx-wrapper.h>
Alexander Afanasyeva199f972013-01-02 19:37:26 -080031
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080032class ActionLog;
33typedef boost::shared_ptr<ActionLog> ActionLogPtr;
34
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080035class ActionLog : public DbHelper
Alexander Afanasyeva199f972013-01-02 19:37:26 -080036{
37public:
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080038 ActionLog (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &path,
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080039 SyncLogPtr syncLog,
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080040 const std::string &localName, const std::string &sharedFolder);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080041
Alexander Afanasyeva199f972013-01-02 19:37:26 -080042 void
43 AddActionUpdate (const std::string &filename,
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080044 const Hash &hash,
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080045 time_t wtime,
Alexander Afanasyev334aac82013-01-18 14:06:39 -080046 int mode,
47 int seg_num);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080048
49 void
50 AddActionMove (const std::string &oldFile, const std::string &newFile);
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080051
Alexander Afanasyeva199f972013-01-02 19:37:26 -080052 void
53 AddActionDelete (const std::string &filename);
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080054
55private:
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080056 boost::tuple<sqlite3_int64, sqlite3_int64, sqlite3_int64, std::string>
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080057 GetExistingRecord (const std::string &filename);
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080058
59 static void
60 apply_action_xFun (sqlite3_context *context, int argc, sqlite3_value **argv);
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080061
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080062private:
Alexander Afanasyev8e2104a2013-01-22 10:56:18 -080063 SyncLogPtr m_syncLog;
64
Alexander Afanasyevc9eb68f2013-01-07 13:40:00 -080065 Ccnx::CcnxWrapperPtr m_ccnx;
66 Ccnx::Name m_sharedFolderName;
Alexander Afanasyeva199f972013-01-02 19:37:26 -080067};
68
69#endif // ACTION_LOG_H