Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame] | 3 | * Copyright (c) 2012-2014 University of California, Los Angeles |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame] | 5 | * This file is part of ChronoSync, synchronization library for distributed realtime |
| 6 | * applications for NDN. |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame] | 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. |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame] | 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. |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame] | 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> |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #ifndef SYNC_INTEREST_CONTAINER_H |
| 25 | #define SYNC_INTEREST_CONTAINER_H |
| 26 | |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 27 | #include <ndn-cxx/util/time.hpp> |
Alexander Afanasyev | 531803b | 2014-02-05 15:57:35 -0800 | [diff] [blame] | 28 | |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 29 | #include "sync-digest.h" |
| 30 | |
| 31 | #include <boost/multi_index_container.hpp> |
| 32 | #include <boost/multi_index/tag.hpp> |
| 33 | // #include <boost/multi_index/ordered_index.hpp> |
| 34 | // #include <boost/multi_index/composite_key.hpp> |
| 35 | #include <boost/multi_index/hashed_index.hpp> |
| 36 | #include <boost/multi_index/sequenced_index.hpp> |
| 37 | #include <boost/multi_index/ordered_index.hpp> |
| 38 | // #include <boost/multi_index/random_access_index.hpp> |
| 39 | #include <boost/multi_index/member.hpp> |
| 40 | #include <boost/multi_index/mem_fun.hpp> |
| 41 | |
| 42 | namespace mi = boost::multi_index; |
| 43 | |
| 44 | namespace Sync { |
| 45 | |
| 46 | struct Interest |
| 47 | { |
Alexander Afanasyev | 46eb526 | 2012-05-10 16:30:35 -0700 | [diff] [blame] | 48 | Interest (DigestConstPtr digest, const std::string &name, bool unknown=false) |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 49 | : m_digest (digest) |
| 50 | , m_name (name) |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 51 | , m_time (ndn::time::system_clock::now()) |
Alexander Afanasyev | 46eb526 | 2012-05-10 16:30:35 -0700 | [diff] [blame] | 52 | , m_unknown (unknown) |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 53 | { |
| 54 | } |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 55 | |
Alexander Afanasyev | 531803b | 2014-02-05 15:57:35 -0800 | [diff] [blame] | 56 | DigestConstPtr m_digest; |
| 57 | std::string m_name; |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 58 | ndn::time::system_clock::TimePoint m_time; |
Alexander Afanasyev | 531803b | 2014-02-05 15:57:35 -0800 | [diff] [blame] | 59 | bool m_unknown; |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 62 | /// @cond include_hidden |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 63 | struct named { }; |
| 64 | struct hashed; |
| 65 | struct timed; |
| 66 | /// @endcond |
| 67 | |
| 68 | /** |
| 69 | * \ingroup sync |
| 70 | * @brief Container for interests (application PIT) |
| 71 | */ |
| 72 | struct InterestContainer : public mi::multi_index_container< |
| 73 | Interest, |
| 74 | mi::indexed_by< |
| 75 | mi::hashed_unique< |
| 76 | mi::tag<named>, |
| 77 | BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name) |
| 78 | > |
| 79 | , |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 80 | |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 81 | mi::hashed_non_unique< |
| 82 | mi::tag<hashed>, |
| 83 | BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest), |
| 84 | DigestPtrHash, |
| 85 | DigestPtrEqual |
| 86 | > |
| 87 | , |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 88 | |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 89 | mi::ordered_non_unique< |
| 90 | mi::tag<timed>, |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 91 | BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time) |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 92 | > |
| 93 | > |
| 94 | > |
| 95 | { |
| 96 | }; |
| 97 | |
| 98 | } // Sync |
| 99 | |
| 100 | #endif // SYNC_INTEREST_CONTAINER_H |