blob: abc25f4041ce3c57496ce342002ceabf4963f495 [file] [log] [blame]
Shuo Chen478204c2014-03-18 18:27:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07003 * Copyright (c) 2014, Regents of the University of California.
4 *
5 * This file is part of NDN repo-ng (Next generation of NDN repository).
6 * See AUTHORS.md for complete list of repo-ng authors and contributors.
7 *
8 * repo-ng is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Shuo Chen478204c2014-03-18 18:27:04 -070018 */
19
Alexander Afanasyev39d98072014-05-04 12:46:29 -070020#ifndef REPO_REPO_HPP
21#define REPO_REPO_HPP
Shuo Chen478204c2014-03-18 18:27:04 -070022
Weiqi Shif0330d52014-07-09 10:54:27 -070023//#include "storage/repo_storage.hpp"
24#include "storage/sqlite-storage.hpp"
25#include "storage/repo-storage.hpp"
Shuo Chen478204c2014-03-18 18:27:04 -070026
Alexander Afanasyev39d98072014-05-04 12:46:29 -070027#include "handles/read-handle.hpp"
28#include "handles/write-handle.hpp"
29#include "handles/delete-handle.hpp"
30#include "handles/tcp-bulk-insert-handle.hpp"
31
Shuo Chen028dcd32014-06-21 16:36:44 +080032#include "common.hpp"
Alexander Afanasyev39d98072014-05-04 12:46:29 -070033
Shuo Chen478204c2014-03-18 18:27:04 -070034#include <boost/property_tree/ptree.hpp>
35#include <boost/property_tree/info_parser.hpp>
36
37namespace repo {
38
39using std::string;
40using std::vector;
41using std::pair;
42
43struct RepoConfig
44{
Shuo Chen028dcd32014-06-21 16:36:44 +080045 string repoConfigPath;
Shuo Chen478204c2014-03-18 18:27:04 -070046 //StorageMethod storageMethod; This will be implemtented if there is other method.
47 std::string dbPath;
48 vector<ndn::Name> dataPrefixes;
49 vector<ndn::Name> repoPrefixes;
50 vector<pair<string, string> > tcpBulkInsertEndpoints;
Weiqi Shif0330d52014-07-09 10:54:27 -070051 int64_t nMaxPackets;
Shuo Chen478204c2014-03-18 18:27:04 -070052 boost::property_tree::ptree validatorNode;
53};
54
55RepoConfig
56parseConfig(const std::string& confPath);
57
58class Repo : noncopyable
59{
Shuo Chen478204c2014-03-18 18:27:04 -070060public:
61 class Error : public std::runtime_error
62 {
63 public:
64 explicit
65 Error(const std::string& what)
66 : std::runtime_error(what)
67 {
68 }
69 };
70
71public:
72 Repo(boost::asio::io_service& ioService, const RepoConfig& config);
73
74 void
75 enableListening();
76
Shuo Chen028dcd32014-06-21 16:36:44 +080077 void
78 enableValidation();
79
Shuo Chen478204c2014-03-18 18:27:04 -070080private:
Shuo Chen478204c2014-03-18 18:27:04 -070081 RepoConfig m_config;
82 ndn::Scheduler m_scheduler;
83 ndn::Face m_face;
Weiqi Shif0330d52014-07-09 10:54:27 -070084 shared_ptr<Storage> m_store;
85 RepoStorage m_storageHandle;
Shuo Chen478204c2014-03-18 18:27:04 -070086 KeyChain m_keyChain;
Shuo Chen028dcd32014-06-21 16:36:44 +080087 ValidatorConfig m_validator;
Shuo Chen478204c2014-03-18 18:27:04 -070088 ReadHandle m_readHandle;
89 WriteHandle m_writeHandle;
90 DeleteHandle m_deleteHandle;
91 TcpBulkInsertHandle m_tcpBulkInsertHandle;
92};
93
94} // namespace repo
95
Alexander Afanasyev39d98072014-05-04 12:46:29 -070096#endif // REPO_REPO_HPP