2022-03-11 22:35:40 +08:00
|
|
|
/*
|
|
|
|
* KDataImp.h
|
|
|
|
*
|
|
|
|
* Created on: 2013-2-4
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#ifndef KDATAIMP_H_
|
|
|
|
#define KDATAIMP_H_
|
|
|
|
|
|
|
|
#include "Stock.h"
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
2024-02-01 01:51:50 +08:00
|
|
|
class HKU_API KDataImp {
|
2022-03-11 22:35:40 +08:00
|
|
|
public:
|
|
|
|
KDataImp();
|
|
|
|
KDataImp(const Stock& stock, const KQuery& query);
|
|
|
|
virtual ~KDataImp();
|
|
|
|
|
2024-02-25 21:03:21 +08:00
|
|
|
const KQuery& getQuery() const {
|
2022-03-11 22:35:40 +08:00
|
|
|
return m_query;
|
|
|
|
}
|
|
|
|
|
2024-02-25 21:03:21 +08:00
|
|
|
const Stock& getStock() const {
|
2022-03-11 22:35:40 +08:00
|
|
|
return m_stock;
|
|
|
|
}
|
|
|
|
|
2024-02-25 21:03:21 +08:00
|
|
|
const KRecord& getKRecord(size_t pos) const {
|
2022-03-11 22:35:40 +08:00
|
|
|
return m_buffer[pos];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool empty() const {
|
|
|
|
return m_buffer.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() {
|
|
|
|
return m_buffer.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t startPos();
|
|
|
|
size_t endPos();
|
|
|
|
size_t lastPos();
|
|
|
|
|
|
|
|
size_t getPos(const Datetime& datetime);
|
|
|
|
|
2024-02-25 21:03:21 +08:00
|
|
|
const KRecord* data() const {
|
|
|
|
return m_buffer.data();
|
|
|
|
}
|
|
|
|
|
2024-02-25 22:53:44 +08:00
|
|
|
DatetimeList getDatetimeList() const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef KRecordList::iterator iterator;
|
|
|
|
typedef KRecordList::const_iterator const_iterator;
|
|
|
|
|
|
|
|
iterator begin() {
|
|
|
|
return m_buffer.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
iterator end() {
|
|
|
|
return m_buffer.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
const_iterator cbegin() const {
|
|
|
|
return m_buffer.cbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
const_iterator cend() const {
|
|
|
|
return m_buffer.cend();
|
|
|
|
}
|
|
|
|
|
2022-03-11 22:35:40 +08:00
|
|
|
private:
|
|
|
|
void _getPosInStock();
|
|
|
|
void _recoverForward();
|
|
|
|
void _recoverBackward();
|
|
|
|
void _recoverEqualForward();
|
|
|
|
void _recoverEqualBackward();
|
|
|
|
void _recoverForUpDay();
|
|
|
|
|
|
|
|
private:
|
|
|
|
KRecordList m_buffer;
|
|
|
|
KQuery m_query;
|
|
|
|
Stock m_stock;
|
|
|
|
size_t m_start;
|
|
|
|
size_t m_end;
|
|
|
|
bool m_have_pos_in_stock;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef shared_ptr<KDataImp> KDataImpPtr;
|
|
|
|
|
|
|
|
} /* namespace hku */
|
|
|
|
#endif /* KDATAIMP_H_ */
|