blob: e11b2213120c6acca3f553fa014bee37d624a8b4 [file] [log] [blame]
Zhiyi Zhangcea58d52015-08-26 10:19:56 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, Regents of the University of California
4 *
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 *
19 * @author Zhiyi Zhang <dreamerbarrychang@gmail.com>
20 */
21
22#ifndef NDN_GEP_SECHEDULE_HPP
23#define NDN_GEP_SECHEDULE_HPP
24
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
42 explicit
43 Schedule(const Block& block);
44
45public:
46 template<encoding::Tag TAG>
47 size_t
48 wireEncode(EncodingImpl<TAG>& encoder) const;
49
50 const Block&
51 wireEncode() const;
52
53 void
54 wireDecode(const Block& wire);
55
56 ///@brief Add an RepetitiveInterval @p repetitiveInterval into white list
57 Schedule&
58 addWhiteInterval(const RepetitiveInterval& repetitiveInterval);
59
60 ///@brief Add the RepetitiveInterval into black list
61 Schedule&
62 addBlackInterval(const RepetitiveInterval& repetitiveInterval);
63
64 /**
65 * @brief Get the Interval that covers the @p ts
66 *
67 * Function iterates two repetitive interval sets and find out
68 * the shortest interval that allows group member to have the access to the data
Zhiyi Zhang7cc09fc2015-09-01 13:40:32 -070069 * if there's no interval covering the @p ts, function will return false and
70 * return a negative interval
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070071 */
Zhiyi Zhang7cc09fc2015-09-01 13:40:32 -070072 std::tuple<bool, Interval>
Zhiyi Zhangcea58d52015-08-26 10:19:56 -070073 getCoveringInterval(const TimeStamp& ts) const;
74
75private:
76 std::set<RepetitiveInterval> m_whiteIntervalList;
77 std::set<RepetitiveInterval> m_blackIntervalList;
78
79 mutable Block m_wire;
80};
81
82} // namespace gep
83} // namespace ndn
84
85#endif // NDN_GROUP_ENCRYPT_SECHEDULE_HPP