blob: 86b74601c8a2f22dca8be0903393d41086d1cbfc [file] [log] [blame]
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Alexander Afanasyev8722d872014-07-02 13:00:29 -07003 * Copyright (c) 2012-2014 University of California, Los Angeles
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -07004 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -07005 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -07007 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -07008 * 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 Afanasyevf3c03a92012-05-09 12:00:37 -070011 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -070012 * 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 Afanasyevf3c03a92012-05-09 12:00:37 -070015 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -070016 * 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 Afanasyevf3c03a92012-05-09 12:00:37 -070022 */
23
24#ifndef SYNC_INTEREST_CONTAINER_H
25#define SYNC_INTEREST_CONTAINER_H
26
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070027#include <ndn-cxx/util/time.hpp>
Alexander Afanasyev531803b2014-02-05 15:57:35 -080028
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070029#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
42namespace mi = boost::multi_index;
43
44namespace Sync {
45
46struct Interest
47{
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070048 Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070049 : m_digest (digest)
50 , m_name (name)
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070051 , m_time (ndn::time::system_clock::now())
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070052 , m_unknown (unknown)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070053 {
54 }
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070055
Alexander Afanasyev531803b2014-02-05 15:57:35 -080056 DigestConstPtr m_digest;
57 std::string m_name;
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070058 ndn::time::system_clock::TimePoint m_time;
Alexander Afanasyev531803b2014-02-05 15:57:35 -080059 bool m_unknown;
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070060};
61
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070062/// @cond include_hidden
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070063struct named { };
64struct hashed;
65struct timed;
66/// @endcond
67
68/**
69 * \ingroup sync
70 * @brief Container for interests (application PIT)
71 */
72struct 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 Yu7c64e5c2014-04-30 14:06:37 -070080
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070081 mi::hashed_non_unique<
82 mi::tag<hashed>,
83 BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
84 DigestPtrHash,
85 DigestPtrEqual
86 >
87 ,
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070088
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070089 mi::ordered_non_unique<
90 mi::tag<timed>,
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070091 BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070092 >
93 >
94 >
95{
96};
97
98} // Sync
99
100#endif // SYNC_INTEREST_CONTAINER_H