trader  v0.1a
A framework to build trading applications
exchangeratelabapi.h
1 
2 #pragma once
3 #include "app.h"
4 #include "api.h"
5 #include "exchangeratelabconfig.h"
6 #include "helper.h"
7 
8 
9 namespace trader {
10 
11  namespace ExchangeratelabApi {
12 
13  class SingleExchangeRate : public Poco::RefCountedObject {
14  public:
15 
17 
19 
20  void readFile(const std::string& _fileName);
21 
22  void read(Poco::Dynamic::Var val);
23 
24  struct DataObject {
25 
26  void SetBaseCurrency(std::string val)
27  {
28  baseCurrency = val;
29  }
30 
31  bool isSetBaseCurrency() {
32  return (baseCurrency != "Empty");
33  }
34 
35  std::string baseCurrency;
36 
37  void SetExecutionTime(Poco::Int32 val)
38  {
39  executionTime = val;
40  }
41 
42  bool isSetExecutionTime() {
43  return (executionTime != std::numeric_limits<Poco::Int32>::max());
44  }
45 
46  Poco::Int32 executionTime;
47 
48  void SetLicenseMessage(std::string val)
49  {
50  licenseMessage = val;
51  }
52 
53  bool isSetLicenseMessage() {
54  return (licenseMessage != "Empty");
55  }
56 
57  std::string licenseMessage;
58 
59  struct RateObject {
60 
61  void SetRate(double val)
62  {
63  rate = val;
64  }
65 
66  bool isSetRate() {
67  return (rate != std::numeric_limits<double>::max());
68  }
69 
70  double rate;
71 
72  void SetTo(std::string val)
73  {
74  to = val;
75  }
76 
77  bool isSetTo() {
78  return (to != "Empty");
79  }
80 
81  std::string to;
82 
83  RateObject()
84  : rate(std::numeric_limits<double>::max())
85  , to("Empty")
86  {
87  }
88 
89  };
90 
91  RateObject rateObject;
92  // Current Unix timestamp
93  void SetTimeStamp(std::time_t val)
94  {
95  timeStamp = val;
96  }
97 
98  bool isSetTimeStamp() {
99  return (timeStamp != std::numeric_limits<time_t>::max());
100  }
101 
102  std::time_t timeStamp;
103 
104  DataObject()
105  : baseCurrency("Empty")
106  , executionTime(std::numeric_limits<Poco::Int32>::max())
107  , licenseMessage("Empty")
108  , timeStamp(std::numeric_limits<time_t>::max())
109  {
110  }
111 
112  };
113 
114  DataObject dataObject;
115  }; //SingleExchangeRate
116 
117  class EndPoints {
118  public:
119 
120  EndPoints(Poco::AutoPtr<trader::App> app, Api* api);
121 
122  ~EndPoints();
123 
124 
125  // Get current bid and ask
126  Poco::AutoPtr<SingleExchangeRate> GetUSDToSGD();
127 
128  ExchangeratelabConfig config;
129 
130  Poco::AutoPtr<trader::App> _app;
131  Api* _api;
132  std::string _uri;
133  }; //EndPoints
134 
135  } //ExchangeratelabApi
136 } //trader
Definition: exchangeratelabconfig.h:7
Definition: exchangeratelabapi.h:117
Definition: exchangeratelabapi.h:13
Definition: api.h:15
Definition: app.h:7