blob: d61fc108f92382e0d66d363bb97d91c5ef9a662e [file] [log] [blame]
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventob48bbda2020-07-27 19:41:37 -04002/*
3 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08004 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
Zhiyi Zhanga62bf982020-10-26 13:10:02 -070021#ifndef NDNCERT_DETAIL_CA_MEMORY_HPP
22#define NDNCERT_DETAIL_CA_MEMORY_HPP
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080023
Zhiyi Zhangb041d442020-10-22 21:57:11 -070024#include "detail/ca-storage.hpp"
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080025
26namespace ndn {
27namespace ndncert {
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070028namespace ca {
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080029
30class CaMemory : public CaStorage
31{
32public:
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070033 CaMemory(const Name& caName = Name(), const std::string& path = "");
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080034 const static std::string STORAGE_TYPE;
35
36public:
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070037 /**
38 * @throw if request cannot be fetched from underlying data storage
39 */
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070040 RequestState
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -070041 getRequest(const RequestId& requestId) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080042
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070043 /**
44 * @throw if there is an existing request with the same request ID
45 */
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080046 void
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070047 addRequest(const RequestState& request) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080048
49 void
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070050 updateRequest(const RequestState& request) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080051
52 void
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -070053 deleteRequest(const RequestId& requestId) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080054
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070055 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070056 listAllRequests() override;
57
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070058 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070059 listAllRequests(const Name& caName) override;
60
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080061private:
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -070062 std::map<RequestId, RequestState> m_requests;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080063};
64
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070065} // namespace ca
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080066} // namespace ndncert
67} // namespace ndn
68
Zhiyi Zhanga62bf982020-10-26 13:10:02 -070069#endif // NDNCERT_DETAIL_CA_MEMORY_HPP