summaryrefslogtreecommitdiff
path: root/protocols/Quotes/src/QuotesProviderVisitorTendency.cpp
blob: 00703521b32a31992eff52768a3311db263fdf38 (plain)
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
#include "stdafx.h"
#include "QuotesProviderVisitorTendency.h"
#include "DBUtils.h"
#include "QuotesProviderGoogleFinance.h"
#include "EconomicRateInfo.h"
#include "QuotesProviderYahoo.h"

CQuotesProviderVisitorTendency::CQuotesProviderVisitorTendency(HANDLE hContact,TCHAR chr)
	: m_hContact(hContact),m_chr(chr),m_bValid(false),m_dResult(0.0)
{
}

void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderBase& rProvider)
{
	switch(m_chr)
	{
	case _T('r'):
	case _T('R'):
		GetValue(DB_STR_QUOTE_CURR_VALUE);
		break;
	case _T('p'):
		GetValue(DB_STR_QUOTE_PREV_VALUE);
		break;
	}
}

void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderGoogleFinance& rProvider)
{
	switch(m_chr)
	{
	case _T('o'):
		GetValue(DB_STR_GOOGLE_FINANCE_OPEN_VALUE);
		break;
	case _T('d'):
		GetValue(DB_STR_GOOGLE_FINANCE_DIFF);
		break;
	case _T('y'):
		GetValue(DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE);
		break;
	}
}

void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderYahoo& rProvider)
{
	switch(m_chr)
	{
	case _T('o'):
		GetValue(DB_STR_YAHOO_OPEN_VALUE);
		break;
	case _T('h'):
		GetValue(DB_STR_YAHOO_DAY_HIGH);
		break;
	case _T('P'):
		GetValue(DB_STR_YAHOO_PREVIOUS_CLOSE);
		break;
	case _T('c'):
		GetValue(DB_STR_YAHOO_CHANGE);
		break;
	case _T('g'):
		GetValue(DB_STR_YAHOO_DAY_LOW);
		break;
	}

}


void CQuotesProviderVisitorTendency::GetValue(LPCSTR pszDbKeyName)
{
	m_bValid = Quotes_DBReadDouble(m_hContact,QUOTES_MODULE_NAME,pszDbKeyName,m_dResult);
}