blob: 2d0cdd04d3d758f8ac15bc4cea4b117a0b49ddcd [file] [log] [blame]
Alexander Afanasyev68f2a952013-01-08 14:34:16 -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 OBJECT_MANAGER_H
23#define OBJECT_MANAGER_H
24
25#include <string>
26#include <ccnx-wrapper.h>
27#include <hash-helper.h>
28#include <boost/filesystem.hpp>
Alexander Afanasyeva35756b2013-01-22 16:59:11 -080029#include <boost/tuple/tuple.hpp>
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080030
31// everything related to managing object files
32
33class ObjectManager
34{
35public:
Alexander Afanasyev1d1cc832013-02-05 20:03:36 -080036 ObjectManager (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &folder, const std::string &appName);
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080037 virtual ~ObjectManager ();
38
Alexander Afanasyev1d1cc832013-02-05 20:03:36 -080039 /**
40 * @brief Creates and saves local file in a local database file
41 *
42 * Format: /<appname>/file/<hash>/<devicename>/<segment>
43 */
Alexander Afanasyeva35756b2013-01-22 16:59:11 -080044 boost::tuple<HashPtr /*object-db name*/, size_t /* number of segments*/>
Alexander Afanasyevdbc06712013-01-08 18:30:28 -080045 localFileToObjects (const boost::filesystem::path &file, const Ccnx::Name &deviceName);
46
47 bool
48 objectsToLocalFile (/*in*/const Ccnx::Name &deviceName, /*in*/const Hash &hash, /*out*/ const boost::filesystem::path &file);
Alexander Afanasyeva35756b2013-01-22 16:59:11 -080049
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080050private:
51 Ccnx::CcnxWrapperPtr m_ccnx;
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080052 boost::filesystem::path m_folder;
Alexander Afanasyev1d1cc832013-02-05 20:03:36 -080053 std::string m_appName;
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080054};
55
56typedef boost::shared_ptr<ObjectManager> ObjectManagerPtr;
57
58namespace Error {
59struct ObjectManager : virtual boost::exception, virtual std::exception { };
60}
61
62#endif // OBJECT_MANAGER_H