blob: 15bd07c86a890c2f1a20236cfe6cafe4c5be116d [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>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_INTEREST_CONTAINER_H
24#define SYNC_INTEREST_CONTAINER_H
25
26#include "sync-digest.h"
27
28#include <boost/multi_index_container.hpp>
29#include <boost/multi_index/tag.hpp>
30// #include <boost/multi_index/ordered_index.hpp>
31// #include <boost/multi_index/composite_key.hpp>
32#include <boost/multi_index/hashed_index.hpp>
33#include <boost/multi_index/sequenced_index.hpp>
34#include <boost/multi_index/ordered_index.hpp>
35// #include <boost/multi_index/random_access_index.hpp>
36#include <boost/multi_index/member.hpp>
37#include <boost/multi_index/mem_fun.hpp>
38
39namespace mi = boost::multi_index;
40
41namespace Sync {
42
43struct Interest
44{
45 Interest (DigestConstPtr digest, const std::string &name)
46 : m_digest (digest)
47 , m_name (name)
48 , m_time (TIME_NOW)
49 {
50 }
51
52 DigestConstPtr m_digest;
53 std::string m_name;
54 TimeAbsolute m_time;
55};
56
57/// @cond include_hidden
58struct named { };
59struct hashed;
60struct timed;
61/// @endcond
62
63/**
64 * \ingroup sync
65 * @brief Container for interests (application PIT)
66 */
67struct InterestContainer : public mi::multi_index_container<
68 Interest,
69 mi::indexed_by<
70 mi::hashed_unique<
71 mi::tag<named>,
72 BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
73 >
74 ,
75
76 mi::hashed_non_unique<
77 mi::tag<hashed>,
78 BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
79 DigestPtrHash,
80 DigestPtrEqual
81 >
82 ,
83
84 mi::ordered_non_unique<
85 mi::tag<timed>,
86 BOOST_MULTI_INDEX_MEMBER(Interest, TimeAbsolute, m_time)
87 >
88 >
89 >
90{
91};
92
93} // Sync
94
95#endif // SYNC_INTEREST_CONTAINER_H