Skip to content
Snippets Groups Projects
Commit e36b30ee authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

del unused stuff in BaseLib

parent 720f0a90
No related branches found
No related tags found
No related merge requests found
/**
* \file
* \author Thomas Fischer
* \date Sep 28, 2012
* \brief Implementation of the RangeValidator class.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
namespace BaseLib {
template <typename NUMERIC_TYPE>
RangeValidator<NUMERIC_TYPE>::RangeValidator(NUMERIC_TYPE lower_limit, NUMERIC_TYPE upper_limit) :
_lower_limit(lower_limit), _upper_limit(upper_limit)
{
}
template <typename NUMERIC_TYPE>
RangeValidator<NUMERIC_TYPE>::~RangeValidator()
{}
template <typename NUMERIC_TYPE>
void RangeValidator<NUMERIC_TYPE>::resetLowerLimits(NUMERIC_TYPE lower_limit)
{
_lower_limit = lower_limit;
}
template <typename NUMERIC_TYPE>
void RangeValidator<NUMERIC_TYPE>:: resetUpperLimits(NUMERIC_TYPE upper_limit)
{
_upper_limit = upper_limit;
}
template <typename NUMERIC_TYPE>
bool RangeValidator<NUMERIC_TYPE>::isValidValue (NUMERIC_TYPE test_value) const
{
if (test_value < _lower_limit)
return false;
if (_upper_limit < test_value)
return false;
return true;
}
} // end namespace BaseLib
/**
* \file
* \author Thomas Fischer
* \date Sep 28, 2012
* \brief Definition of the RangeValidator calss.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef RANGEVALIDATOR_H_
#define RANGEVALIDATOR_H_
namespace BaseLib {
template <typename NUMERIC_TYPE>
class RangeValidator {
public:
RangeValidator(NUMERIC_TYPE lower_limit, NUMERIC_TYPE upper_limit);
void resetLowerLimits(NUMERIC_TYPE lower_limit);
void resetUpperLimits(NUMERIC_TYPE upper_limit);
bool isValidValue (NUMERIC_TYPE test_value) const;
virtual ~RangeValidator();
private:
NUMERIC_TYPE _lower_limit;
NUMERIC_TYPE _upper_limit;
};
}
#include "RangeValidator-impl.h"
#endif /* RANGEVALIDATOR_H_ */
/**
* \file
* \author Norihiro Watanabe
* \date 2012-07-16
* \brief Definition of some system helper functions.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef SYSTEMTOOLS_H
#define SYSTEMTOOLS_H
namespace BaseLib
{
/// return if this system supports little endian or not
inline bool IsLittleEndian()
{
#ifdef ENDIAN_IS_BIG
return false;
#elif ENDIAN_IS_LITTLE
return true;
#endif
}
}
#endif
/**
* \file
* \author Karsten Rink
* \date 2011-02-17
* \brief Definition of the wait function.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef WAIT_H
#define WAIT_H
#include <ctime>
namespace BaseLib {
void wait(int seconds)
{
time_t start_time, cur_time;
time(&start_time);
do
{
time(&cur_time);
}
while((cur_time - start_time) < seconds);
}
} // end namespace BaseLib
#endif //WAIT_H
/**
* \file
* \author Lars Bilke
* \date 2010-04-29
* \brief
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
// ** INCLUDES **
#include "gtest/gtest.h"
TEST(BaseLib, SwapInt) {
int arg0 = 5;
int arg1 = 10;
std::swap(arg0, arg1);
ASSERT_EQ ( arg0, 10 );
ASSERT_EQ ( arg1, 5 );
}
TEST(BaseLib, SwapDouble) {
double arg0 = 5.0;
double arg1 = 10.0;
std::swap(arg0, arg1);
ASSERT_EQ ( arg0, 10.0 );
ASSERT_EQ ( arg1, 5.0 );
}
TEST(BaseLib, SwapString) {
std::string arg0 = "5";
std::string arg1 = "10";
std::swap(arg0, arg1);
ASSERT_EQ ( arg0, std::string("10") );
ASSERT_EQ ( arg1, std::string("5") );
}
/**
* \file
* \author Norihiro Watanabe
* \date 2012-10-30
* \brief
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
// ** INCLUDES **
#include "gtest/gtest.h"
#include "BaseLib/SystemTools.h"
TEST(BaseLib, EndianLittle) {
bool isLittle = false;
int x = 0x00000001;
if (*(char*)&x)
isLittle = true; //am little
ASSERT_EQ (isLittle, BaseLib::IsLittleEndian());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment