blob: de7043adef33dafbb2adbed04f8f6245eee399d7 [file] [log] [blame]
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Ashlesh Gawande08784d42017-09-06 23:40:21 -05003 * Copyright (c) 2012-2017 University of California, Los Angeles
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -07004 *
5 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
7 *
8 * ChronoSync 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, either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * ChronoSync 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 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/>
20 * @author Chaoyi Bian <bcy@pku.edu.cn>
21 * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
22 * @author Yingdi Yu <yingdi@cs.ucla.edu>
23 */
24
25#ifndef CHRONOSYNC_INTEREST_CONTAINER_HPP
26#define CHRONOSYNC_INTEREST_CONTAINER_HPP
27
28#include "common.hpp"
29#include "mi-tag.hpp"
30#include "diff-state-container.hpp"
31
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -070032#include <boost/multi_index_container.hpp>
33#include <boost/multi_index/tag.hpp>
34#include <boost/multi_index/hashed_index.hpp>
35#include <boost/multi_index/ordered_index.hpp>
36#include <boost/multi_index/member.hpp>
37
38namespace chronosync {
39
40namespace mi = boost::multi_index;
41
42/// @brief Entry to record unsatisfied Sync Interest
43class UnsatisfiedInterest : noncopyable
44{
45public:
Ashlesh Gawande08784d42017-09-06 23:40:21 -050046 UnsatisfiedInterest(const Interest& interest,
47 ConstBufferPtr digest,
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -070048 bool isUnknown = false);
49
50public:
Ashlesh Gawande08784d42017-09-06 23:40:21 -050051 const Interest interest;
52 ConstBufferPtr digest;
53 bool isUnknown;
54 ndn::EventId expirationEvent;
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -070055};
56
Ashlesh Gawande08784d42017-09-06 23:40:21 -050057using UnsatisfiedInterestPtr = shared_ptr<UnsatisfiedInterest>;
58using ConstUnsatisfiedInterestPtr = shared_ptr<const UnsatisfiedInterest>;
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -070059
60/**
61 * @brief Container for unsatisfied Sync Interests
62 */
63struct InterestContainer : public mi::multi_index_container<
64 UnsatisfiedInterestPtr,
65 mi::indexed_by<
66 mi::hashed_unique<
67 mi::tag<hashed>,
Ashlesh Gawande08784d42017-09-06 23:40:21 -050068 mi::member<UnsatisfiedInterest, ConstBufferPtr, &UnsatisfiedInterest::digest>,
Yingdi Yu1c4ba9a2014-08-27 19:05:49 -070069 DigestPtrHash,
70 DigestPtrEqual
71 >
72 >
73 >
74{
75};
76
77} // namespace chronosync
78
79#endif // CHRONOSYNC_INTEREST_CONTAINER_HPP