hikyuu2/hikyuu_cpp/hikyuu/data_driver/BlockInfoDriver.cpp

59 lines
1.3 KiB
C++
Raw Normal View History

/*
* BaseInfoDriver.cpp
*
* Created on: 2017-10-8
* Author: fasiondog
*/
#include "BlockInfoDriver.h"
namespace hku {
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const BlockInfoDriver& driver) {
2017-10-20 02:11:57 +08:00
os << "BlockInfoDriver(" << driver.name() << ", " << driver.getParameter() << ")";
return os;
}
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const BlockInfoDriverPtr& driver) {
2017-10-20 02:11:57 +08:00
if (driver) {
os << *driver;
} else {
os << "BlockInfoDriver(NULL)";
}
return os;
}
2019-11-10 23:31:41 +08:00
BlockInfoDriver::BlockInfoDriver(const string& name) : m_name(name) {
to_upper(m_name);
}
bool BlockInfoDriver::checkType() {
bool result = false;
try {
string type = getParam<string>("type");
to_upper(type);
if (type == m_name) {
result = true;
} else {
result = false;
HKU_WARN("Type of driver mismatch! ({} != {})", type, m_name);
}
2019-11-10 23:31:41 +08:00
} catch (...) {
result = false;
2019-06-16 19:06:06 +08:00
HKU_ERROR("Can't get type of driver!");
}
return result;
}
bool BlockInfoDriver::init(const Parameter& params) {
2020-11-22 18:34:37 +08:00
HKU_IF_RETURN(m_params == params, true);
m_params = params;
2020-11-22 18:34:37 +08:00
HKU_IF_RETURN(!checkType(), false);
return _init();
}
} /* namespace hku */