hikyuu2/hikyuu_cpp/hikyuu/KDataImp.h

95 lines
1.6 KiB
C++
Raw Normal View History

/*
* KDataImp.h
*
* Created on: 2013-2-4
* Author: fasiondog
*/
#pragma once
#ifndef KDATAIMP_H_
#define KDATAIMP_H_
#include "Stock.h"
namespace hku {
class HKU_API KDataImp {
public:
KDataImp();
KDataImp(const Stock& stock, const KQuery& query);
virtual ~KDataImp();
2024-02-25 21:03:21 +08:00
const KQuery& getQuery() const {
return m_query;
}
2024-02-25 21:03:21 +08:00
const Stock& getStock() const {
return m_stock;
}
2024-02-25 21:03:21 +08:00
const KRecord& getKRecord(size_t pos) const {
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();
}
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_ */