Twitch SDK (Internal)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ttv::ModuleBase Class Referenceabstract

#include <module.h>

Inheritance diagram for ttv::ModuleBase:
ttv::IModule ttv::ads::AdsAPI ttv::broadcast::BroadcastAPI ttv::chat::ChatAPI ttv::CoreAPI ttv::experiment::ExperimentAPI ttv::social::SocialAPI ttv::tracking::TrackingAPI

Public Types

enum  State { State::Uninitialized, State::Initializing, State::Initialized, State::ShuttingDown }
 
using InitializeCallback = std::function< void(TTV_ErrorCode ec)>
 
using ShutdownCallback = std::function< void(TTV_ErrorCode ec)>
 

Public Member Functions

 ModuleBase ()
 
virtual ~ModuleBase ()
 
virtual State GetState () const override
 
virtual TTV_ErrorCode Initialize (const InitializeCallback &callback) override
 
virtual TTV_ErrorCode Update () override
 
virtual TTV_ErrorCode Shutdown (const ShutdownCallback &callback) override
 
virtual std::string GetModuleName () const =0
 

Protected Member Functions

void NotifyStateChange ()
 
void RegisterInitializeCallback (const InitializeCallback &callback)
 
void RegisterShutdownCallback (const ShutdownCallback &callback)
 
virtual bool CheckShutdown ()
 
virtual void CompleteShutdown ()
 
template<typename T >
void Invoke (std::function< void(std::shared_ptr< T >)> callback)
 
std::shared_ptr< ComponentContainerGetComponentContainer ()
 

Protected Attributes

EventSource< IModuleListenermListeners
 
State mState
 
State mLastReportedState
 

Private Attributes

std::shared_ptr< ComponentContainermComponentContainer
 
CallbackQueue< InitializeCallbackmInitializeCallbacks
 
CallbackQueue< ShutdownCallbackmShutdownCallbacks
 

Detailed Description

A base class providing common functionality for modules.

Member Typedef Documentation

◆ InitializeCallback

using ttv::IModule::InitializeCallback = std::function<void(TTV_ErrorCode ec)>
inherited

◆ ShutdownCallback

using ttv::IModule::ShutdownCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Member Enumeration Documentation

◆ State

enum ttv::IModule::State
stronginherited
Enumerator
Uninitialized 
Initializing 
Initialized 
ShuttingDown 

Constructor & Destructor Documentation

◆ ModuleBase()

ttv::ModuleBase::ModuleBase ( )

◆ ~ModuleBase()

virtual ttv::ModuleBase::~ModuleBase ( )
virtual

Member Function Documentation

◆ CheckShutdown()

virtual bool ttv::ModuleBase::CheckShutdown ( )
protectedvirtual

◆ CompleteShutdown()

virtual void ttv::ModuleBase::CompleteShutdown ( )
protectedvirtual

◆ GetComponentContainer()

std::shared_ptr<ComponentContainer> ttv::ModuleBase::GetComponentContainer ( )
inlineprotected

Returns the common ComponentContainer which hosts all components which live at the module level.

◆ GetModuleName()

virtual std::string ttv::IModule::GetModuleName ( ) const
pure virtualinherited

◆ GetState()

virtual State ttv::ModuleBase::GetState ( ) const
overridevirtual

Returns the current state of the module.

Implements ttv::IModule.

◆ Initialize()

virtual TTV_ErrorCode ttv::ModuleBase::Initialize ( const InitializeCallback callback)
overridevirtual

Initializes the module asynchronously. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. You should only expect changes to the module state if this method succeeds.

Implements ttv::IModule.

Reimplemented in ttv::chat::ChatAPI, ttv::CoreAPI, ttv::broadcast::BroadcastAPI, ttv::social::SocialAPI, ttv::experiment::ExperimentAPI, ttv::ads::AdsAPI, and ttv::tracking::TrackingAPI.

◆ Invoke()

template<typename T >
void ttv::ModuleBase::Invoke ( std::function< void(std::shared_ptr< T >)>  callback)
inlineprotected

Invokes the callback for the module listeners.

◆ NotifyStateChange()

void ttv::ModuleBase::NotifyStateChange ( )
protected

◆ RegisterInitializeCallback()

void ttv::ModuleBase::RegisterInitializeCallback ( const InitializeCallback callback)
inlineprotected

◆ RegisterShutdownCallback()

void ttv::ModuleBase::RegisterShutdownCallback ( const ShutdownCallback callback)
inlineprotected

◆ Shutdown()

virtual TTV_ErrorCode ttv::ModuleBase::Shutdown ( const ShutdownCallback callback)
overridevirtual

Initiates an asynchronous shutdown of the module. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. All modules that depend on this module need to be shutdown first. You should only expect changes to the module state if this method succeeds.

Implements ttv::IModule.

Reimplemented in ttv::chat::ChatAPI, ttv::CoreAPI, ttv::broadcast::BroadcastAPI, ttv::social::SocialAPI, ttv::experiment::ExperimentAPI, ttv::ads::AdsAPI, and ttv::tracking::TrackingAPI.

◆ Update()

virtual TTV_ErrorCode ttv::ModuleBase::Update ( )
overridevirtual

Updates the internal state of the module and fires any pending callbacks.

Implements ttv::IModule.

Reimplemented in ttv::chat::ChatAPI, ttv::CoreAPI, ttv::broadcast::BroadcastAPI, ttv::social::SocialAPI, ttv::experiment::ExperimentAPI, ttv::ads::AdsAPI, and ttv::tracking::TrackingAPI.

Member Data Documentation

◆ mComponentContainer

std::shared_ptr<ComponentContainer> ttv::ModuleBase::mComponentContainer
private

The set of components that are managed at the module level. This may contain components which have been passed to the client via the public interface.

◆ mInitializeCallbacks

CallbackQueue<InitializeCallback> ttv::ModuleBase::mInitializeCallbacks
private

◆ mLastReportedState

State ttv::ModuleBase::mLastReportedState
protected

◆ mListeners

EventSource<IModuleListener> ttv::ModuleBase::mListeners
protected

The registered listeners. These listeners extend IModuleListener and will be of the type required for the module.

◆ mShutdownCallbacks

CallbackQueue<ShutdownCallback> ttv::ModuleBase::mShutdownCallbacks
private

◆ mState

State ttv::ModuleBase::mState
protected

The documentation for this class was generated from the following file: