xbmc
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PERIPHERALS::CPeripheralBus Class Referenceabstract

#include <PeripheralBus.h>

Inheritance diagram for PERIPHERALS::CPeripheralBus:
Inheritance graph
[legend]
Collaboration diagram for PERIPHERALS::CPeripheralBus:
Collaboration graph
[legend]

Public Member Functions

 CPeripheralBus (const std::string &threadname, CPeripherals &manager, PeripheralBusType type)
 
PeripheralBusType Type (void) const
 
bool NeedsPolling (void) const
 
virtual bool InitializeProperties (CPeripheral &peripheral)
 Initialize the properties of a peripheral with a known location.
 
virtual PeripheralPtr GetPeripheral (const std::string &strLocation) const
 Get the instance of the peripheral at the given location. More...
 
virtual bool HasPeripheral (const std::string &strLocation) const
 Check whether a peripheral is present at the given location. More...
 
virtual bool SupportsFeature (PeripheralFeature feature) const
 Check if the bus supports the given feature. More...
 
virtual unsigned int GetPeripheralsWithFeature (PeripheralVector &results, const PeripheralFeature feature) const
 Get all peripheral instances that have the given feature. More...
 
virtual unsigned int GetNumberOfPeripherals () const
 
virtual unsigned int GetNumberOfPeripheralsWithId (const int iVendorId, const int iProductId) const
 
virtual void GetFeatures (std::vector< PeripheralFeature > &features) const
 Get all features that are supported by devices on this bus. More...
 
virtual bool HasFeature (const PeripheralFeature feature) const
 Check whether there is at least one device present with the given feature. More...
 
virtual void OnDeviceAdded (const std::string &strLocation)
 Callback method for when a device has been added. Will perform a device scan. More...
 
virtual void OnDeviceChanged (const std::string &strLocation)
 Callback method for when a device has been changed. Will perform a device scan. More...
 
virtual void OnDeviceRemoved (const std::string &strLocation)
 Callback method for when a device has been removed. Will perform a device scan. More...
 
virtual void Initialise (void)
 Initialise this bus and start a polling thread if this bus needs polling.
 
virtual void Clear (void)
 Stop the polling thread and clear all known devices on this bus.
 
virtual void TriggerDeviceScan (void)
 Scan for devices.
 
virtual void GetDirectory (const std::string &strPath, CFileItemList &items) const
 Get all fileitems for a path. More...
 
virtual PeripheralPtr GetByPath (const std::string &strPath) const
 Get the instance of a peripheral given it's path. More...
 
virtual void Register (const PeripheralPtr &peripheral)
 Register a new peripheral on this bus. More...
 
virtual bool FindComPort (std::string &strLocation)
 
virtual void ProcessEvents (void)
 Poll for events.
 
virtual void EnableButtonMapping ()
 Initialize button mapping. More...
 
virtual void PowerOff (const std::string &strLocation)
 Power off the specified device. More...
 

Protected Member Functions

void Process (void) override
 
virtual bool ScanForDevices (void)
 
virtual void UnregisterRemovedDevices (const PeripheralScanResults &results)
 
virtual void RegisterNewDevices (const PeripheralScanResults &results)
 
virtual bool PerformDeviceScan (PeripheralScanResults &results)=0
 Scan for devices on this bus and add them to the results list. This will have to be implemented for each bus. More...
 
- Protected Member Functions inherited from CThread
 CThread (const char *ThreadName)
 
virtual void OnStartup ()
 
virtual void OnExit ()
 
WaitResponse AbortableWait (CEvent &event, std::chrono::milliseconds duration=std::chrono::milliseconds(-1))
 This call will wait on a CEvent in an interruptible way such that if stop is called on the thread the wait will return with a response indicating what happened.
 
 CThread (IRunnable *pRunnable, const char *ThreadName)
 
void Create (bool bAutoDelete=false)
 
template<typename Rep , typename Period >
void Sleep (std::chrono::duration< Rep, Period > duration)
 
bool IsAutoDelete () const
 
virtual void StopThread (bool bWait=true)
 
bool IsRunning () const
 
bool IsCurrentThread () const
 
bool Join (std::chrono::milliseconds duration)
 
bool SetPriority (const ThreadPriority &priority)
 Set the threads priority. This uses the platforms native threading library to do so.
 
virtual void OnException ()
 

Protected Attributes

PeripheralVector m_peripherals
 
std::chrono::milliseconds m_iRescanTime
 
bool m_bNeedsPolling
 
CPeripheralsm_manager
 
const PeripheralBusType m_type
 
CCriticalSection m_critSection
 
CEvent m_triggerEvent
 
- Protected Attributes inherited from CThread
std::atomic< bool > m_bStop
 

Additional Inherited Members

- Protected Types inherited from CThread
enum  WaitResponse { WAIT_INTERRUPTED = -1, WAIT_SIGNALED = 0, WAIT_TIMEDOUT = 1 }
 
- Static Protected Member Functions inherited from CThread
static const std::thread::id GetCurrentThreadId ()
 
static CThreadGetCurrentThread ()
 

Detailed Description

This represents a bus on the system. By default, this bus instance will scan for changes every 5 seconds. If this bus only has to be updated after a notification sent by the system, set m_bNeedsPolling to false in the constructor, and implement the OnDeviceAdded(), OnDeviceChanged() and OnDeviceRemoved() methods.

The PerformDeviceScan() method has to be implemented by each specific bus implementation.

Member Function Documentation

◆ EnableButtonMapping()

virtual void PERIPHERALS::CPeripheralBus::EnableButtonMapping ( )
inlinevirtual

Initialize button mapping.

Returns
True if button mapping is enabled for this bus

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ GetByPath()

PeripheralPtr CPeripheralBus::GetByPath ( const std::string &  strPath) const
virtual

Get the instance of a peripheral given it's path.

Parameters
strPathThe path to the peripheral.
Returns
The peripheral or NULL if it wasn't found.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ GetDirectory()

void CPeripheralBus::GetDirectory ( const std::string &  strPath,
CFileItemList items 
) const
virtual

Get all fileitems for a path.

Parameters
strPathThe path to the directory to get the items from.
itemsThe item list.

Reimplemented in PERIPHERALS::CPeripheralBusAddon, and PERIPHERALS::CPeripheralBusApplication.

◆ GetFeatures()

void CPeripheralBus::GetFeatures ( std::vector< PeripheralFeature > &  features) const
virtual

Get all features that are supported by devices on this bus.

Parameters
featuresAll features.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ GetPeripheral()

PeripheralPtr CPeripheralBus::GetPeripheral ( const std::string &  strLocation) const
virtual

Get the instance of the peripheral at the given location.

Parameters
strLocationThe location.
Returns
The peripheral or NULL if it wasn't found.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ GetPeripheralsWithFeature()

unsigned int CPeripheralBus::GetPeripheralsWithFeature ( PeripheralVector &  results,
const PeripheralFeature  feature 
) const
virtual

Get all peripheral instances that have the given feature.

Parameters
resultsThe list of results.
featureThe feature to search for.
Returns
The number of devices that have been found.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ HasFeature()

bool CPeripheralBus::HasFeature ( const PeripheralFeature  feature) const
virtual

Check whether there is at least one device present with the given feature.

Parameters
featureThe feature to check for.
Returns
True when at least one device was found with this feature, false otherwise.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ HasPeripheral()

bool CPeripheralBus::HasPeripheral ( const std::string &  strLocation) const
virtual

Check whether a peripheral is present at the given location.

Parameters
strLocationThe location.
Returns
True when a peripheral was found, false otherwise.

◆ NeedsPolling()

bool PERIPHERALS::CPeripheralBus::NeedsPolling ( void  ) const
inline
Returns
True if this bus needs to be polled for changes, false if this bus performs updates via callbacks

◆ OnDeviceAdded()

void CPeripheralBus::OnDeviceAdded ( const std::string &  strLocation)
virtual

Callback method for when a device has been added. Will perform a device scan.

Parameters
strLocationThe location of the device that has been added.

◆ OnDeviceChanged()

void CPeripheralBus::OnDeviceChanged ( const std::string &  strLocation)
virtual

Callback method for when a device has been changed. Will perform a device scan.

Parameters
strLocationThe location of the device that has been changed.

◆ OnDeviceRemoved()

void CPeripheralBus::OnDeviceRemoved ( const std::string &  strLocation)
virtual

Callback method for when a device has been removed. Will perform a device scan.

Parameters
strLocationThe location of the device that has been removed.

◆ PerformDeviceScan()

virtual bool PERIPHERALS::CPeripheralBus::PerformDeviceScan ( PeripheralScanResults results)
protectedpure virtual

Scan for devices on this bus and add them to the results list. This will have to be implemented for each bus.

Parameters
resultsThe result list.
Returns
True when the scan was successful, false otherwise.

Implemented in PERIPHERALS::CPeripheralBusAddon, PERIPHERALS::CPeripheralBusAndroid, PERIPHERALS::CPeripheralBusApplication, PERIPHERALS::CPeripheralBusCEC, PERIPHERALS::CPeripheralBusGCController, PERIPHERALS::CPeripheralBusUSB, PERIPHERALS::CPeripheralBusUSB, PERIPHERALS::CPeripheralBusUSB, PERIPHERALS::CPeripheralBusUSB, and PERIPHERALS::CPeripheralBusUSB.

◆ PowerOff()

virtual void PERIPHERALS::CPeripheralBus::PowerOff ( const std::string &  strLocation)
inlinevirtual

Power off the specified device.

Parameters
strLocationThe device's location

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ Register()

void CPeripheralBus::Register ( const PeripheralPtr &  peripheral)
virtual

Register a new peripheral on this bus.

Parameters
peripheralThe peripheral to register.

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ SupportsFeature()

virtual bool PERIPHERALS::CPeripheralBus::SupportsFeature ( PeripheralFeature  feature) const
inlinevirtual

Check if the bus supports the given feature.

Parameters
featureThe feature to check for
Returns
True if the bus supports the feature, false otherwise

Reimplemented in PERIPHERALS::CPeripheralBusAddon.

◆ Type()

PeripheralBusType PERIPHERALS::CPeripheralBus::Type ( void  ) const
inline
Returns
The bus type

Member Data Documentation

◆ m_bNeedsPolling

bool PERIPHERALS::CPeripheralBus::m_bNeedsPolling
protected

true when this bus needs to be polled for new devices, false when it uses callbacks to notify this bus of changed


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