Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | a35756b | 2013-01-22 16:59:11 -0800 | [diff] [blame] | 29 | #include <boost/tuple/tuple.hpp> |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 30 | |
| 31 | // everything related to managing object files |
| 32 | |
| 33 | class ObjectManager |
| 34 | { |
| 35 | public: |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 36 | ObjectManager (Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path &folder, const std::string &appName); |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 37 | virtual ~ObjectManager (); |
| 38 | |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 39 | /** |
| 40 | * @brief Creates and saves local file in a local database file |
| 41 | * |
| 42 | * Format: /<appname>/file/<hash>/<devicename>/<segment> |
| 43 | */ |
Alexander Afanasyev | a35756b | 2013-01-22 16:59:11 -0800 | [diff] [blame] | 44 | boost::tuple<HashPtr /*object-db name*/, size_t /* number of segments*/> |
Alexander Afanasyev | dbc0671 | 2013-01-08 18:30:28 -0800 | [diff] [blame] | 45 | 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 Afanasyev | a35756b | 2013-01-22 16:59:11 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 50 | private: |
| 51 | Ccnx::CcnxWrapperPtr m_ccnx; |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 52 | boost::filesystem::path m_folder; |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 53 | std::string m_appName; |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | typedef boost::shared_ptr<ObjectManager> ObjectManagerPtr; |
| 57 | |
| 58 | namespace Error { |
| 59 | struct ObjectManager : virtual boost::exception, virtual std::exception { }; |
| 60 | } |
| 61 | |
| 62 | #endif // OBJECT_MANAGER_H |