1 /* 2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef TEST_PC_E2E_ANALYZER_VIDEO_ID_GENERATOR_H_ 12 #define TEST_PC_E2E_ANALYZER_VIDEO_ID_GENERATOR_H_ 13 14 #include <atomic> 15 16 namespace webrtc { 17 namespace webrtc_pc_e2e { 18 19 // IdGenerator generates ids. All provided ids have to be unique. There is no 20 // any order guarantees for provided ids. 21 template <typename T> 22 class IdGenerator { 23 public: 24 virtual ~IdGenerator() = default; 25 26 // Returns next unique id. There is no any order guarantees for provided ids. 27 virtual T GetNextId() = 0; 28 }; 29 30 // Generates int ids. It is assumed, that no more then max int value ids will be 31 // requested from this generator. 32 class IntIdGenerator : public IdGenerator<int> { 33 public: 34 explicit IntIdGenerator(int start_value); 35 ~IntIdGenerator() override; 36 37 int GetNextId() override; 38 39 private: 40 std::atomic<int> next_id_; 41 }; 42 43 } // namespace webrtc_pc_e2e 44 } // namespace webrtc 45 46 #endif // TEST_PC_E2E_ANALYZER_VIDEO_ID_GENERATOR_H_ 47