blob: 96086fae1dc9d89d8555d7428884e8b49b7311de [file] [log] [blame]
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Chaoyi Bian <bcy@pku.edu.cn>
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070021 */
22
23#ifndef SYNC_INTEREST_CONTAINER_H
24#define SYNC_INTEREST_CONTAINER_H
25
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070026#include <ndn-cxx/util/time.hpp>
Alexander Afanasyev531803b2014-02-05 15:57:35 -080027
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070028#include "sync-digest.h"
29
30#include <boost/multi_index_container.hpp>
31#include <boost/multi_index/tag.hpp>
32// #include <boost/multi_index/ordered_index.hpp>
33// #include <boost/multi_index/composite_key.hpp>
34#include <boost/multi_index/hashed_index.hpp>
35#include <boost/multi_index/sequenced_index.hpp>
36#include <boost/multi_index/ordered_index.hpp>
37// #include <boost/multi_index/random_access_index.hpp>
38#include <boost/multi_index/member.hpp>
39#include <boost/multi_index/mem_fun.hpp>
40
41namespace mi = boost::multi_index;
42
43namespace Sync {
44
45struct Interest
46{
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070047 Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070048 : m_digest (digest)
49 , m_name (name)
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070050 , m_time (ndn::time::system_clock::now())
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070051 , m_unknown (unknown)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070052 {
53 }
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070054
Alexander Afanasyev531803b2014-02-05 15:57:35 -080055 DigestConstPtr m_digest;
56 std::string m_name;
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070057 ndn::time::system_clock::TimePoint m_time;
Alexander Afanasyev531803b2014-02-05 15:57:35 -080058 bool m_unknown;
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070059};
60
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070061/// @cond include_hidden
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070062struct named { };
63struct hashed;
64struct timed;
65/// @endcond
66
67/**
68 * \ingroup sync
69 * @brief Container for interests (application PIT)
70 */
71struct InterestContainer : public mi::multi_index_container<
72 Interest,
73 mi::indexed_by<
74 mi::hashed_unique<
75 mi::tag<named>,
76 BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
77 >
78 ,
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070079
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070080 mi::hashed_non_unique<
81 mi::tag<hashed>,
82 BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
83 DigestPtrHash,
84 DigestPtrEqual
85 >
86 ,
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070087
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070088 mi::ordered_non_unique<
89 mi::tag<timed>,
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070090 BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070091 >
92 >
93 >
94{
95};
96
97} // Sync
98
99#endif // SYNC_INTEREST_CONTAINER_H