-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathChartEntryPrice.cpp
88 lines (73 loc) · 2.76 KB
/
ChartEntryPrice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/************************************************************************
* Copyright(c) 2017, One Unified. All rights reserved. *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
/*
* File: ChartEntryPrice.cpp
* Author: rpb
*
* Created on May 6, 2017, 7:03 PM
*/
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/bind/bind_member_function.hpp>
#include "ChartEntryPrice.h"
namespace ou { // One Unified
ChartEntryPrice::ChartEntryPrice()
: ChartEntryTime() {
}
ChartEntryPrice::ChartEntryPrice( ChartEntryPrice&& rhs )
: ChartEntryTime( std::move( rhs ) )
, m_vDouble( std::move( rhs.m_vDouble ) )
, m_queue( std::move( rhs.m_queue ) )
{}
ChartEntryPrice::~ChartEntryPrice() {
ClearQueue(); // clear out prior to m_vDouble disappears.
}
void ChartEntryPrice::Reserve( size_type nSize ) {
m_vDouble.reserve( nSize );
}
void ChartEntryPrice::Clear() {
m_vDouble.clear();
ChartEntryTime::Clear();
}
void ChartEntryPrice::Append( const ou::tf::Price& price) {
m_queue.Append( price );
}
void ChartEntryPrice::Append( const boost::posix_time::ptime &dt, double price ) {
Append( ou::tf::Price( dt, price ) );
}
void ChartEntryPrice::ClearQueue() {
namespace args = boost::phoenix::placeholders;
m_queue.Sync( boost::phoenix::bind( &ChartEntryPrice::Pop, this, args::arg1 ) );
}
void ChartEntryPrice::Pop( const ou::tf::Price& price ) {
ChartEntryTime::AppendFg( price.DateTime() );
m_vDouble.push_back( price.Value() );
}
bool ChartEntryPrice::AddEntryToChart( XYChart *pXY, structChartAttributes *pAttributes ) {
bool bAdded( false );
ClearQueue();
if ( 0 != this->ChartEntryTime::Size() ) {
DoubleArray daXData = ChartEntryTime::GetDateTimes();
if ( 0 != daXData.len ) {
LineLayer *ll = pXY->addLineLayer( this->GetPrices() );
ll->setXData( daXData );
pAttributes->dblXMin = daXData[0];
pAttributes->dblXMax = daXData[ daXData.len - 1 ];
DataSet *pds = ll->getDataSet(0);
pds->setDataColor( m_eColour );
pds->setDataName( GetName().c_str() );
bAdded = true;
}
}
return bAdded;
}
} // namespace ou