blob: 3eb2325993a2e2a913369b41ced3c2c4ed27b28d [file] [log] [blame]
Zhenkai Zhue42b4572013-01-22 15:57:54 -08001#ifndef CONTENT_SERVER_H
2#define CONTENT_SERVER_H
3/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
4/*
5 * Copyright (c) 2013 University of California, Los Angeles
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
21 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
22 */
23
24#include "ccnx-wrapper.h"
25#include "object-db.h"
26#include "action-log.h"
27#include <set>
28#include <boost/thread/shared_mutex.hpp>
29#include <boost/thread/locks.hpp>
30
31class ContentServer
32{
33public:
34 ContentServer(Ccnx::CcnxWrapperPtr ccnx, ActionLogPtr actionLog, const boost::filesystem::path &rootDir);
35 ~ContentServer();
36
37 // the assumption is, when the interest comes in, interest is informs of
38 // /some-prefix/topology-independent-name
39 // currently /topology-independent-name must begin with /action or /file
40 // so that ContentServer knows where to look for the content object
41 void registerPrefix(const Ccnx::Name &prefix);
42 void deregisterPrefix(const Ccnx::Name &prefix);
43
44 void
45 serve(const Ccnx::Name &interest);
46
47private:
48 Ccnx::CcnxWrapperPtr m_ccnx;
49 ActionLogPtr m_actionLog;
50 typedef boost::shared_mutex Mutex;
51 typedef boost::unique_lock<Mutex> WriteLock;
52 typedef boost::shared_lock<Mutex> ReadLock;
53 typedef std::set<Ccnx::Name>::iterator PrefixIt;
54 std::set<Ccnx::Name> m_prefixes;
55 Mutex m_mutex;
56 boost::filesystem::path m_dbFolder;
57};
58#endif // CONTENT_SERVER_H