#pragma once
#include "env.h"
#include <map>
#include <vector>
namespace CEC
{
class CCECBusDevice;
typedef std::map<cec_logical_address, CCECBusDevice *> CECDEVICEMAP;
typedef std::vector<CCECBusDevice *> CECDEVICEVEC;
class CCECProcessor;
class CCECDeviceMap
{
public:
CCECDeviceMap(CCECProcessor *processor);
virtual ~CCECDeviceMap(void);
CECDEVICEMAP::iterator Begin(void);
CECDEVICEMAP::iterator End(void);
void ResetDeviceStatus(void);
CCECBusDevice * operator[] (cec_logical_address iAddress) const;
CCECBusDevice * operator[] (uint8_t iAddress) const;
CCECBusDevice * At(cec_logical_address iAddress) const;
CCECBusDevice * At(uint8_t iAddress) const;
CCECBusDevice * GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate = true);
void Get(CECDEVICEVEC &devices) const;
void GetLibCECControlled(CECDEVICEVEC &devices) const;
void GetByLogicalAddresses(CECDEVICEVEC &devices, const cec_logical_addresses &addresses);
void GetActive(CECDEVICEVEC &devices) const;
bool IsActiveType(const cec_device_type type, bool suppressPoll = true) const;
void GetByType(const cec_device_type type, CECDEVICEVEC &devices) const;
void GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const;
void SignalAll(cec_opcode opcode);
void GetPowerOffDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const;
void GetWakeDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const;
CCECBusDevice *GetActiveSource(void) const;
void ResetActiveSourceSent(void);
static void FilterLibCECControlled(CECDEVICEVEC &devices);
static void FilterActive(CECDEVICEVEC &devices);
static void FilterTypes(const cec_device_type_list &types, CECDEVICEVEC &devices);
static void FilterType(const cec_device_type type, CECDEVICEVEC &devices);
static cec_logical_addresses ToLogicalAddresses(const CECDEVICEVEC &devices);
private:
void Clear(void);
CECDEVICEMAP m_busDevices;
CCECProcessor *m_processor;
};
}