hikyuu2/hikyuu_cpp/hikyuu/data_driver/KDataDriver.cpp

96 lines
2.5 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* KDataDriver.cpp
*
* Created on: 201492
* Author: fasiondog
*/
#include "../StockManager.h"
#include "KDataDriver.h"
namespace hku {
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const KDataDriver& driver) {
2017-10-20 02:11:57 +08:00
os << "KDataDriver(" << driver.name() << ", " << driver.getParameter() << ")";
return os;
}
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const KDataDriverPtr& driver) {
2017-10-20 02:11:57 +08:00
if (driver) {
os << *driver;
} else {
os << "KDataDriver(NULL)";
}
return os;
}
KDataDriver::KDataDriver() : m_name("") {}
2015-01-07 01:26:14 +08:00
KDataDriver::KDataDriver(const string& name) : m_name(name) {
to_upper(m_name);
2015-01-07 01:26:14 +08:00
}
bool KDataDriver::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 KDataDriver::init(const Parameter& params) {
if (m_params == params) {
return true;
}
m_params = params;
if (!checkType()) {
return false;
}
return _init();
}
2019-11-10 23:31:41 +08:00
size_t KDataDriver::getCount(const string& market, const string& code, KQuery::KType kType) {
2020-08-04 00:03:54 +08:00
HKU_INFO("The getCount method has not been implemented! (KDataDriver: {})", m_name);
return 0;
}
bool KDataDriver::getIndexRangeByDate(const string& market, const string& code, const KQuery& query,
size_t& out_start, size_t& out_end) {
2020-08-04 00:03:54 +08:00
HKU_INFO("The getIndexRangeByDate method has not been implemented! (KDataDriver: {})", m_name);
return false;
}
2020-10-02 17:31:33 +08:00
KRecordList KDataDriver::getKRecordList(const string& market, const string& code,
const KQuery& query) {
2020-10-01 00:06:58 +08:00
HKU_INFO("The getKRecordList method has not been implemented! (KDataDriver: {})", m_name);
return KRecordList();
}
TimeLineList KDataDriver::getTimeLineList(const string& market, const string& code,
const KQuery& query) {
2020-08-04 00:03:54 +08:00
HKU_INFO("The getTimeLineList method has not been implemented! (KDataDriver: {})", m_name);
2019-02-11 16:33:55 +08:00
return TimeLineList();
2019-02-08 22:41:20 +08:00
}
TransList KDataDriver::getTransList(const string& market, const string& code, const KQuery& query) {
2020-08-04 00:03:54 +08:00
HKU_INFO("The getTransList method has not been implemented! (KDataDriver: {})", m_name);
2019-02-11 21:13:06 +08:00
return TransList();
}
2015-01-07 01:26:14 +08:00
} /* namespace hku */