MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/configuration/hardware/FunctionTable.hpp

42 lines
972 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_ */