Twitch SDK (Internal)
bitsconfigrepository.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2017 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
15 #include "twitchsdk/core/cache.h"
17 
18 #include <memory>
19 #include <map>
20 #include <queue>
21 #include <vector>
22 
23 namespace ttv
24 {
25  class TaskRunner;
26 
27  namespace chat
28  {
29  class BitsConfigRepository;
30  class ChatGetBitsConfigTask;
31  class BitsConfiguration;
32  }
33 }
34 
36 {
37 public:
38  using LookupCallback = std::function<void(TTV_ErrorCode ec, const std::shared_ptr<BitsConfiguration>& bitsConfiguration)>;
39  using LookupId = uint64_t;
40 
41 public:
43 
65 
66  // Component overrides
67  virtual void Update() override;
68  virtual TTV_ErrorCode Shutdown() override;
69  virtual std::string GetLoggerName() const override;
70 
71 private:
72  // Component overrides
73  virtual bool CheckShutdown() override;
74  virtual void CompleteShutdown() override;
75 
77  TTV_ErrorCode CacheBitsConfig(const std::shared_ptr<BitsConfiguration> bitsConfiguration);
78 
80  std::map<ChannelId, std::shared_ptr<CallbackQueue<LookupCallback>>> mPendingBitsConfigLookups;
81  std::map<LookupId, ChannelId> mChannelLookups;
85 };
TTV_ErrorCode FetchGlobalBitsConfiguration(LookupCallback callback)
virtual TTV_ErrorCode Shutdown() override
std::map< ChannelId, std::shared_ptr< CallbackQueue< LookupCallback > > > mPendingBitsConfigLookups
Definition: bitsconfigrepository.h:80
Definition: cache.h:23
virtual void Update() override
virtual std::string GetLoggerName() const override
virtual bool CheckShutdown() override
TTV_ErrorCode FetchChannelBitsConfiguration(ChannelId channelId, LookupCallback callback)
uint64_t LookupId
Definition: bitsconfigrepository.h:39
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
virtual void CompleteShutdown() override
Definition: bitsconfigrepository.h:35
Definition: component.h:50
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
std::function< void(TTV_ErrorCode ec, const std::shared_ptr< BitsConfiguration > &bitsConfiguration)> LookupCallback
Definition: bitsconfigrepository.h:38
std::map< LookupId, ChannelId > mChannelLookups
Definition: bitsconfigrepository.h:81
bool mLookupInProgress
Definition: bitsconfigrepository.h:84
uint32_t ChannelId
Definition: coretypes.h:23
CallbackQueue< LookupCallback > mCancelledBitsConfigLookups
Definition: bitsconfigrepository.h:82
TTV_ErrorCode CacheBitsConfig(const std::shared_ptr< BitsConfiguration > bitsConfiguration)
Cache< ChannelId, std::shared_ptr< BitsConfiguration > > mBitsConfigCache
Definition: bitsconfigrepository.h:79
LookupId mCurrentLookupId
Definition: bitsconfigrepository.h:83
TTV_ErrorCode CancelFetch(LookupId token)