NVIDIA DeepStream SDK API Reference

7.0 Release
capture_time_rules.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 #pragma once
14 
15 #include <string>
16 #include <iostream>
17 #include <chrono>
18 #include <vector>
19 
21  typedef std::chrono::time_point<std::chrono::system_clock> t_time_pt;
22  typedef std::chrono::duration<unsigned long long> t_duration;
23 public:
28  void init(const std::string &path, unsigned default_second_interval);
29 
32  t_duration getCurrentTimeInterval();
33 
36  bool is_init_();
37 
38 private:
39  struct TimeRule {
40  unsigned begin_time_hour;
41  unsigned begin_time_minute;
42  unsigned end_time_hour;
43  unsigned end_time_minute;
44  unsigned interval_between_frame_capture_seconds;
45  bool end_time_is_next_day;
46  };
47 
54  static bool isInTimeRule(const TimeRule &t, const tm &now);
55 
56  enum ParseResult{
57  PARSE_RESULT_OK,
58  PARSE_RESULT_BAD_CHARS,
59  PARSE_RESULT_OUT_OF_BOUND,
60  PARSE_RESULT_EMPTY
61  };
62 
63  static ParseResult stoi_err_handling(unsigned& dst, const std::string &src, unsigned max_bound);
64  static bool parsing_contains_error(const std::vector<ParseResult>& parse_res_list,
65  const std::vector<std::string>& str_list, const std::string& curr_line,
66  unsigned line_number);
67  bool single_time_rule_parser(const std::string &path, const std::string &line,
68  unsigned line_number);
69 
70  std::chrono::seconds default_duration_;
71  t_time_pt end_of_current_time_interval_;
72  t_duration current_time_interval_;
73  std::vector<TimeRule> rules_;
74  bool init_ = false;
75 };
76 
77 
CaptureTimeRules::getCurrentTimeInterval
t_duration getCurrentTimeInterval()
Compute the correct time interval using the local computer time.
CaptureTimeRules
Definition: capture_time_rules.h:20
CaptureTimeRules::init
void init(const std::string &path, unsigned default_second_interval)
Fills the time rules with the content of the file in path.
CaptureTimeRules::is_init_
bool is_init_()