Advertisement
dshil

Untitled

Oct 15th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "mapbox/variant.hpp"
  4.  
  5. #include <map>
  6. #include <memory>
  7.  
  8. namespace media {
  9. namespace diagnostic {
  10.  
  11. using CounterVariant = mapbox::util::variant<
  12.     vbl::baselong,
  13.     vbl::CVBLString,
  14.     SCounter
  15. >;
  16.  
  17. struct CounterHolder {
  18. public:
  19.     CounterHolder() = default;
  20.  
  21.     explicit CounterHolder(CounterVariant val)
  22.         : valid(true)
  23.         , value(val) {
  24.     }
  25.  
  26.     CounterVariant& Get() {
  27.         VBL_ASSERT(valid);
  28.         return value;
  29.     }
  30.  
  31.     vbl::basebool valid{ false };
  32.  
  33. private:
  34.     CounterVariant value;
  35. };
  36.  
  37. using CounterMap = std::map<vbl::CVBLString, CounterHolder>;
  38. using CounterMapPtr = std::shared_ptr<CounterMap>;
  39.  
  40. // IProvider represents a read-only interface for counter receiving.
  41. class IProvider {
  42. public:
  43.     // Destroy.
  44.     virtual ~IProvider() = default;
  45.  
  46.     // Returns the counter for the provided @p key.
  47.     //
  48.     // @remarks
  49.     //  It is safe to modify received counter.
  50.     virtual CounterHolder Get(const vbl::CVBLString& key) const = 0;
  51.  
  52.     // Returns all existing counters.
  53.     //
  54.     // @remarks
  55.     //  It is safe to modify received counters.
  56.     virtual CounterMap GetAll() const = 0;
  57. };
  58.  
  59. } // diagnostic namespace
  60. } // media namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement