Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 28 | namespace ndn { |
| 29 | namespace 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 | */ |
| 37 | class Schedule |
| 38 | { |
| 39 | public: |
| 40 | Schedule(); |
| 41 | |
| 42 | explicit |
| 43 | Schedule(const Block& block); |
| 44 | |
| 45 | public: |
| 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 |
| 69 | */ |
| 70 | Interval |
| 71 | getCoveringInterval(const TimeStamp& ts) const; |
| 72 | |
| 73 | private: |
| 74 | std::set<RepetitiveInterval> m_whiteIntervalList; |
| 75 | std::set<RepetitiveInterval> m_blackIntervalList; |
| 76 | |
| 77 | mutable Block m_wire; |
| 78 | }; |
| 79 | |
| 80 | } // namespace gep |
| 81 | } // namespace ndn |
| 82 | |
| 83 | #endif // NDN_GROUP_ENCRYPT_SECHEDULE_HPP |