summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src/ICurrencyRatesProvider.h
blob: bc850aa676d23f277f980a2a14c5851ebaedddf1 (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
#pragma once

#ifndef __ac71e133_786c_41a7_ab07_625b76ff2a8c_CurrencyRatesProvider_h__
#define __ac71e133_786c_41a7_ab07_625b76ff2a8c_CurrencyRatesProvider_h__

class CCurrencyRatesProviderVisitor;

/////////////////////////////////////////////////////////////////////////////////////////
// CFormatSpecificator - array of variables to replace

using CFormatSpecificator = std::pair<const wchar_t *, const wchar_t *>;
typedef std::vector<CFormatSpecificator> TFormatSpecificators;

/////////////////////////////////////////////////////////////////////////////////////////
// ICurrencyRatesProvider - abstract interface

class ICurrencyRatesProvider : private boost::noncopyable
{
public:
	struct CProviderInfo
	{
		CMStringW m_sName;
		CMStringW m_sURL;
	};

public:
	ICurrencyRatesProvider() {}
	virtual ~ICurrencyRatesProvider() {}

	virtual bool Init() = 0;
	virtual const CProviderInfo& GetInfo() const = 0;

	virtual MCONTACT ImportContact(const TiXmlNode*) = 0;

	virtual void RefreshAllContacts() = 0;
	virtual void RefreshSettings() = 0;
	virtual void RefreshContact(MCONTACT hContact) = 0;

	virtual void FillFormat(TFormatSpecificators&) const = 0;
	virtual bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d) const = 0;
	virtual CMStringW FormatSymbol(MCONTACT hContact, wchar_t c, int nWidth = 0) const = 0;

	virtual void Run() = 0;
};

/////////////////////////////////////////////////////////////////////////////////////////

class CCurrencyRatesProviderBase;

struct TCurrencyRatesProviders : public OBJLIST<CCurrencyRatesProviderBase>
{
	TCurrencyRatesProviders() : 
		OBJLIST<CCurrencyRatesProviderBase>(1)
	{}

	void push(CCurrencyRatesProviderBase *pNew);
};

extern TCurrencyRatesProviders g_apProviders;
extern CCurrencyRatesProviderBase *g_pCurrentProvider;

CCurrencyRatesProviderBase* FindProvider(const CMStringW &rsName);

void InitProviders();
void ClearProviders();

#endif //__ac71e133_786c_41a7_ab07_625b76ff2a8c_CurrencyRatesProvider_h__