2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
#ifndef __RANGED_NUM_H
|
|
|
|
#define __RANGED_NUM_H
|
|
|
|
|
|
|
|
template <class T> class RANGED_NUM {
|
2015-02-18 16:53:46 +00:00
|
|
|
public:
|
|
|
|
RANGED_NUM( T aValue = 0, T aTolerancePlus = 0, T aToleranceMinus = 0 ) :
|
|
|
|
m_value( aValue ),
|
|
|
|
m_tolerancePlus( aTolerancePlus ),
|
|
|
|
m_toleranceMinus( aToleranceMinus )
|
|
|
|
{}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
operator T()
|
|
|
|
{
|
|
|
|
return m_value;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
RANGED_NUM& operator=( const T aValue )
|
|
|
|
{
|
|
|
|
m_value = aValue;
|
|
|
|
return *this;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
bool Matches( const T& aOther ) const
|
|
|
|
{
|
|
|
|
return ( aOther >= m_value - m_toleranceMinus && aOther <= m_value + m_tolerancePlus );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
private:
|
|
|
|
T m_value, m_tolerancePlus, m_toleranceMinus;
|
2015-02-18 00:29:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|