blob: a91976757d4a2bef03c61cf78c09a41e5146fdda [file] [log] [blame]
Zhiyi Zhangcea58d52015-08-26 10:19:56 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Zhiyi Zhang19a11d22018-04-12 22:58:20 -07003 * Copyright (c) 2014-2018, Regents of the University of California
Zhiyi Zhangcea58d52015-08-26 10:19:56 -07004 *
5 * This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN).
6 * See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors.
7 *
8 * ndn-group-encrypt 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,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndn-group-encrypt 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.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndn-group-encrypt, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070019 * @author Zhiyi Zhang <zhiyi@cs.ucla.edu>
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070020 */
21
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070022#ifndef NDN_GEP_SCHEDULE_HPP
23#define NDN_GEP_SCHEDULE_HPP
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070024
25#include "common.hpp"
26#include "repetitive-interval.hpp"
27
28namespace ndn {
29namespace gep {
30
31/**
32 * @brief Schedule is used to manage the time, which contains two sets of RepetitiveIntervals
33 *
34 * whiteIntervalList is used to define the time allowing member's access to data
35 * blackIntervalList is used to define the time not allowing member's access to data
36 */
37class Schedule
38{
39public:
40 Schedule();
41
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070042 explicit Schedule(const Block& block);
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070043
44public:
45 template<encoding::Tag TAG>
46 size_t
47 wireEncode(EncodingImpl<TAG>& encoder) const;
48
49 const Block&
50 wireEncode() const;
51
52 void
53 wireDecode(const Block& wire);
54
55 ///@brief Add an RepetitiveInterval @p repetitiveInterval into white list
56 Schedule&
57 addWhiteInterval(const RepetitiveInterval& repetitiveInterval);
58
59 ///@brief Add the RepetitiveInterval into black list
60 Schedule&
61 addBlackInterval(const RepetitiveInterval& repetitiveInterval);
62
63 /**
64 * @brief Get the Interval that covers the @p ts
65 *
66 * Function iterates two repetitive interval sets and find out
67 * the shortest interval that allows group member to have the access to the data
Zhiyi Zhang7cc09fc2015-09-01 13:40:32 -070068 * if there's no interval covering the @p ts, function will return false and
69 * return a negative interval
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070070 */
Zhiyi Zhang7cc09fc2015-09-01 13:40:32 -070071 std::tuple<bool, Interval>
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070072 getCoveringInterval(const TimeStamp& ts) const;
73
74private:
75 std::set<RepetitiveInterval> m_whiteIntervalList;
76 std::set<RepetitiveInterval> m_blackIntervalList;
77
78 mutable Block m_wire;
79};
80
81} // namespace gep
82} // namespace ndn
83
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070084#endif // NDN_GEP_SCHEDULE_HPP