NVIDIA DeepStream SDK API Reference

9.1 Release
sources/apps/sample_apps/deepstream-transfer-learning-app/capture_time_rules.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <string>
21 #include <iostream>
22 #include <chrono>
23 #include <vector>
24 
26  typedef std::chrono::time_point<std::chrono::system_clock> t_time_pt;
27  typedef std::chrono::duration<unsigned long long> t_duration;
28 public:
33  void init(const std::string &path, unsigned default_second_interval);
34 
37  t_duration getCurrentTimeInterval();
38 
41  bool is_init_();
42 
43 private:
44  struct TimeRule {
45  unsigned begin_time_hour;
46  unsigned begin_time_minute;
47  unsigned end_time_hour;
48  unsigned end_time_minute;
49  unsigned interval_between_frame_capture_seconds;
50  bool end_time_is_next_day;
51  };
52 
59  static bool isInTimeRule(const TimeRule &t, const tm &now);
60 
61  enum ParseResult{
62  PARSE_RESULT_OK,
63  PARSE_RESULT_BAD_CHARS,
64  PARSE_RESULT_OUT_OF_BOUND,
65  PARSE_RESULT_EMPTY
66  };
67 
68  static ParseResult stoi_err_handling(unsigned& dst, const std::string &src, unsigned max_bound);
69  static bool parsing_contains_error(const std::vector<ParseResult>& parse_res_list,
70  const std::vector<std::string>& str_list, const std::string& curr_line,
71  unsigned line_number);
72  bool single_time_rule_parser(const std::string &path, const std::string &line,
73  unsigned line_number);
74 
75  std::chrono::seconds default_duration_;
76  t_time_pt end_of_current_time_interval_;
77  t_duration current_time_interval_;
78  std::vector<TimeRule> rules_;
79  bool init_ = false;
80 };
81 
82 
CaptureTimeRules::getCurrentTimeInterval
t_duration getCurrentTimeInterval()
Compute the correct time interval using the local computer time.
CaptureTimeRules
Definition: sources/apps/sample_apps/deepstream-transfer-learning-app/capture_time_rules.h:25
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_()