blob: 2133efec0e165717120c1a4346069b403cb98781 [file] [log] [blame]
Yingdi Yu7d773322015-03-22 21:32:48 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07003 * Copyright (c) 2014-2017, Regents of the University of California
Yingdi Yu7d773322015-03-22 21:32:48 -07004 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07005 * This file is part of NDN DeLorean, An Authentication System for Data Archives in
6 * Named Data Networking. See AUTHORS.md for complete list of NDN DeLorean authors
7 * and contributors.
Yingdi Yu7d773322015-03-22 21:32:48 -07008 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07009 * NDN DeLorean is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
Yingdi Yu7d773322015-03-22 21:32:48 -070013 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070014 * NDN DeLorean is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Yingdi Yu7d773322015-03-22 21:32:48 -070017 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070018 * You should have received a copy of the GNU General Public License along with NDN
19 * DeLorean, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Yingdi Yu7d773322015-03-22 21:32:48 -070020 */
21
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070022#ifndef NDN_DELOREAN_CONF_RULE_HPP
23#define NDN_DELOREAN_CONF_RULE_HPP
Yingdi Yu7d773322015-03-22 21:32:48 -070024
25#include "filter.hpp"
26#include "checker.hpp"
27
Alexander Afanasyev49e2e4c2017-05-06 13:42:57 -070028namespace ndn {
29namespace delorean {
Yingdi Yu7d773322015-03-22 21:32:48 -070030namespace conf {
31
32class Rule
33{
34public:
35 explicit
36 Rule(const std::string& id);
37
38 virtual
39 ~Rule();
40
41 const std::string&
42 getId();
43
44 void
45 addFilter(const shared_ptr<Filter>& filter);
46
47 void
48 addChecker(const shared_ptr<Checker>& checker);
49
50 bool
51 match(const Data& data);
52
53 /**
54 * @brief check if data satisfies certain condition
55 *
56 * @param packet The packet
57 * @return false if data is immediately invalid
58 */
59 bool
60 check(const Data& data);
61
62private:
63 typedef std::vector<shared_ptr<Filter> > FilterList;
64 typedef std::vector<shared_ptr<Checker> > CheckerList;
65
66 std::string m_id;
67 FilterList m_filters;
68 CheckerList m_checkers;
69};
70
71} // namespace conf
Alexander Afanasyev49e2e4c2017-05-06 13:42:57 -070072} // namespace delorean
73} // namespace ndn
Yingdi Yu7d773322015-03-22 21:32:48 -070074
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070075#endif // NDN_DELOREAN_CONF_RULE_HPP