blob: ff26f306fac7d7bf213383ce6810a6ddd26abc42 [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 Afanasyevdbc06712013-01-08 18:30:28 -080036 ObjectManager (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &folder);
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080037 virtual ~ObjectManager ();
38
Alexander Afanasyeva35756b2013-01-22 16:59:11 -080039 boost::tuple<HashPtr /*object-db name*/, size_t /* number of segments*/>
Alexander Afanasyevdbc06712013-01-08 18:30:28 -080040 localFileToObjects (const boost::filesystem::path &file, const Ccnx::Name &deviceName);
41
42 bool
43 objectsToLocalFile (/*in*/const Ccnx::Name &deviceName, /*in*/const Hash &hash, /*out*/ const boost::filesystem::path &file);
Alexander Afanasyeva35756b2013-01-22 16:59:11 -080044
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080045private:
46 Ccnx::CcnxWrapperPtr m_ccnx;
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080047 boost::filesystem::path m_folder;
48};
49
50typedef boost::shared_ptr<ObjectManager> ObjectManagerPtr;
51
52namespace Error {
53struct ObjectManager : virtual boost::exception, virtual std::exception { };
54}
55
56#endif // OBJECT_MANAGER_H