blob: 428877e2b1dec4e1cf9c66169b44f855c6895ae7 [file] [log] [blame]
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -08001/* -*- 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 Afanasyev8f25cbb2012-03-01 23:53:40 -08004 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -07005 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -08007 *
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 Afanasyev8f25cbb2012-03-01 23:53:40 -080011 *
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 Afanasyev8f25cbb2012-03-01 23:53:40 -080015 *
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 Afanasyev8f25cbb2012-03-01 23:53:40 -080022 */
23
24#ifndef SYNC_DIFF_STATE_CONTAINER_H
25#define SYNC_DIFF_STATE_CONTAINER_H
26
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080027#include "sync-diff-state.h"
Alexander Afanasyeva5858032012-03-09 15:55:10 -080028#include "sync-digest.h"
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080029
30#include <boost/multi_index_container.hpp>
Alexander Afanasyeva5858032012-03-09 15:55:10 -080031#include <boost/multi_index/tag.hpp>
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080032// #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/random_access_index.hpp>
Alexander Afanasyev3a229132012-04-25 15:07:26 -070037#include <boost/multi_index/member.hpp>
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080038#include <boost/multi_index/mem_fun.hpp>
39
40namespace mi = boost::multi_index;
41
Alexander Afanasyevc1030192012-03-08 22:21:28 -080042namespace Sync {
43
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070044/// @cond include_hidden
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080045struct sequenced { };
Alexander Afanasyev3a229132012-04-25 15:07:26 -070046struct timed { };
Alexander Afanasyevc1030192012-03-08 22:21:28 -080047/// @endcond
48
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080049/**
50 * \ingroup sync
51 * @brief Container for differential states
52 */
Alexander Afanasyevc1030192012-03-08 22:21:28 -080053struct DiffStateContainer : public mi::multi_index_container<
Alexander Afanasyeva5858032012-03-09 15:55:10 -080054 DiffStatePtr,
55 mi::indexed_by<
56 // For fast access to elements using DiffState hashes
57 mi::hashed_unique<
58 mi::tag<hashed>,
59 mi::const_mem_fun<DiffState, DigestConstPtr, &DiffState::getDigest>,
Alexander Afanasyeve4e2bf72012-03-12 12:44:54 -070060 DigestPtrHash,
61 DigestPtrEqual
Alexander Afanasyeva5858032012-03-09 15:55:10 -080062 >
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070063 ,
Alexander Afanasyeva5858032012-03-09 15:55:10 -080064 // sequenced index to access older/newer element (like in list)
65 mi::sequenced<mi::tag<sequenced> >
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080066 >
Alexander Afanasyeva5858032012-03-09 15:55:10 -080067 >
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080068{
69};
70
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080071} // Sync
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080072
73#endif // SYNC_DIFF_STATE_CONTAINER_H