blob: b998b18411adb90e9c79a28c54621b5822f358da [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{
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070045 Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070046 : m_digest (digest)
47 , m_name (name)
48 , m_time (TIME_NOW)
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070049 , m_unknown (unknown)
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070050 {
51 }
52
53 DigestConstPtr m_digest;
54 std::string m_name;
55 TimeAbsolute m_time;
Alexander Afanasyev46eb5262012-05-10 16:30:35 -070056 bool m_unknown;
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070057};
58
59/// @cond include_hidden
60struct named { };
61struct hashed;
62struct timed;
63/// @endcond
64
65/**
66 * \ingroup sync
67 * @brief Container for interests (application PIT)
68 */
69struct InterestContainer : public mi::multi_index_container<
70 Interest,
71 mi::indexed_by<
72 mi::hashed_unique<
73 mi::tag<named>,
74 BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
75 >
76 ,
77
78 mi::hashed_non_unique<
79 mi::tag<hashed>,
80 BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
81 DigestPtrHash,
82 DigestPtrEqual
83 >
84 ,
85
86 mi::ordered_non_unique<
87 mi::tag<timed>,
88 BOOST_MULTI_INDEX_MEMBER(Interest, TimeAbsolute, m_time)
89 >
90 >
91 >
92{
93};
94
95} // Sync
96
97#endif // SYNC_INTEREST_CONTAINER_H