2017-10-09 02:25:02 +08:00
|
|
|
/*
|
|
|
|
* BaseInfoDriver.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2017-10-8
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include "BaseInfoDriver.h"
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
2017-10-20 02:11:57 +08:00
|
|
|
HKU_API std::ostream & operator<<(std::ostream& os, const BaseInfoDriver& driver) {
|
|
|
|
os << "BaseInfoDriver(" << driver.name() << ", " << driver.getParameter() << ")";
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
HKU_API std::ostream & operator<<(std::ostream& os, const BaseInfoDriverPtr& driver) {
|
|
|
|
if (driver) {
|
|
|
|
os << *driver;
|
|
|
|
} else {
|
|
|
|
os << "BaseInfoDriver(NULL)";
|
|
|
|
}
|
|
|
|
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2017-10-09 02:25:02 +08:00
|
|
|
BaseInfoDriver::BaseInfoDriver(const string& name)
|
|
|
|
: m_name(name) {
|
|
|
|
boost::to_upper(m_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseInfoDriver::checkType() {
|
|
|
|
bool result = false;
|
|
|
|
try {
|
|
|
|
string type = getParam<string>("type");
|
|
|
|
boost::to_upper(type);
|
|
|
|
if (type == m_name) {
|
|
|
|
result = true;
|
|
|
|
} else {
|
|
|
|
result = false;
|
|
|
|
HKU_WARN("Type of driver mismatch! ("
|
|
|
|
<< type << " != " << m_name << ") "
|
|
|
|
<< "[BaseInfoDriver::checkType]");
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(...) {
|
|
|
|
result = false;
|
|
|
|
HKU_ERROR("Can't get type of driver! [BaseInfoDriver::checkType]");
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseInfoDriver::init(const Parameter& params) {
|
|
|
|
if (m_params == params)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
m_params = params;
|
|
|
|
if (!checkType()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return _init();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseInfoDriver::loadBaseInfo() {
|
|
|
|
if (!checkType()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-30 02:38:13 +08:00
|
|
|
HKU_INFO("Loading market information...");
|
2017-10-09 02:25:02 +08:00
|
|
|
if (!_loadMarketInfo()) {
|
|
|
|
HKU_FATAL("Can't load Market Information.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-30 02:38:13 +08:00
|
|
|
HKU_INFO("Loading stock type information...");
|
2017-10-09 02:25:02 +08:00
|
|
|
if (!_loadStockTypeInfo()) {
|
|
|
|
HKU_FATAL("Can't load StockType Information.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-30 02:38:13 +08:00
|
|
|
HKU_INFO("Loading stock information...");
|
2017-10-09 02:25:02 +08:00
|
|
|
if (!_loadStock()) {
|
|
|
|
HKU_FATAL("Can't load Stock");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-07 22:55:47 +08:00
|
|
|
Parameter BaseInfoDriver
|
|
|
|
::getFinanceInfo(const string& market, const string& code) {
|
|
|
|
return Parameter();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-09 02:25:02 +08:00
|
|
|
} /* namespace hku */
|