42 lines
989 B
C++
42 lines
989 B
C++
/*!\file
|
||
* \brief \todo Описание файла.
|
||
*/
|
||
/*
|
||
* FunctionTable.hpp
|
||
*
|
||
* Created on: 23 мая 2019 г.
|
||
* Author: titov
|
||
*/
|
||
|
||
#ifndef SOURCE_APPLICATION_HARDWARE_FUNCTIONTABLE_HPP_
|
||
#define SOURCE_APPLICATION_HARDWARE_FUNCTIONTABLE_HPP_
|
||
|
||
#include "PeripheralId.hh"
|
||
#include "PeripheralFactory.hpp"
|
||
|
||
namespace configuration { namespace hardware {
|
||
|
||
template<const PeripheralFactory::FunctionId * table, std::size_t size,
|
||
PeripheralFactory::FunctionId unknow = 0>
|
||
struct FunctionTable {
|
||
|
||
PeripheralFactory::FunctionId operator()( PeripheralId peripheral_id );
|
||
|
||
};
|
||
|
||
template<const PeripheralFactory::FunctionId * table, std::size_t size,
|
||
PeripheralFactory::FunctionId unknow>
|
||
PeripheralFactory::FunctionId FunctionTable<table, size, unknow>::operator()( PeripheralId peripheral_id ) {
|
||
|
||
if( peripheral_id < size)
|
||
return table[peripheral_id];
|
||
else
|
||
return unknow;
|
||
|
||
}
|
||
|
||
}}
|
||
|
||
|
||
#endif /* SOURCE_APPLICATION_HARDWARE_FUNCTIONTABLE_HPP_ */
|