blob: f674d05617a8d4ae9cc202593a5ab45243446e7f [file] [log] [blame]
akmhoque66e66182014-02-21 17:56:03 -06001/* -*- 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>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_INTEREST_CONTAINER_H
24#define SYNC_INTEREST_CONTAINER_H
25
26#include <ndn-cpp-dev/util/time.hpp>
27
28#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{
47 Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
48 : m_digest (digest)
49 , m_name (name)
akmhoque05d5fcf2014-04-15 14:58:45 -050050 , m_time (ndn::time::system_clock::now())
akmhoque66e66182014-02-21 17:56:03 -060051 , m_unknown (unknown)
52 {
53 }
54
55 DigestConstPtr m_digest;
56 std::string m_name;
akmhoque05d5fcf2014-04-15 14:58:45 -050057 ndn::time::system_clock::TimePoint m_time;
akmhoque66e66182014-02-21 17:56:03 -060058 bool m_unknown;
59};
60
61/// @cond include_hidden
62struct 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 ,
79
80 mi::hashed_non_unique<
81 mi::tag<hashed>,
82 BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
83 DigestPtrHash,
84 DigestPtrEqual
85 >
86 ,
87
88 mi::ordered_non_unique<
89 mi::tag<timed>,
akmhoque05d5fcf2014-04-15 14:58:45 -050090 BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
akmhoque66e66182014-02-21 17:56:03 -060091 >
92 >
93 >
94{
95};
96
97} // Sync
98
99#endif // SYNC_INTEREST_CONTAINER_H