summaryrefslogtreecommitdiff
path: root/test/navigation/w3c/socket-based-poc/node-cpp-lbs-modules/NavigationCoreConfiguration.hpp
blob: 1e294cbdf4deb98c203dfa1a8872f2e0a2a9a7d1 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef NAVIGATIONCORECONFIGURATION_HPP
#define NAVIGATIONCORECONFIGURATION_HPP

#include <node.h>
#include <node_buffer.h>

#include <string>
#include <vector>
#include <map>

// Do not include this line. It's generally frowned upon to use namespaces
// in header files as it may cause issues with other code that includes your
// header file.
// using namespace v8;

class Version {
public:
    Version() {
        versionMajor = 1;
        versionMinor = 0;
        versionMicro = 0;
        date = "19:02:2016";
	}
    uint16_t versionMajor;
    uint16_t versionMinor;
    uint16_t versionMicro;
    std::string date;
};

class Locale {
public:
    Locale() {
        languageCode = "eng";
        countryCode = "USA";
        scriptCode = "Latn";
    }
    Locale(std::string language, std::string country, std::string script) {
        languageCode = language;
        countryCode = country;
        scriptCode = script;
    }

    std::string languageCode;
    std::string countryCode;
    std::string scriptCode;
};


namespace org {
namespace genivi {
namespace navigationcore {

class Configuration_proxy
{
public:

    union UnitsOfMeasurementValue {
        int32_t intValue;
        double doubleValue;
    };

    enum UnitsOfMeasurementValueType {
        intValue=0,
        doubleValue=1
    };

    typedef struct {
        UnitsOfMeasurementValueType type;
        UnitsOfMeasurementValue value;
    } UnitsOfMeasurementValueStruct;

    enum UnitsOfMeasurementAttribute {
        INVALID,
        LENGTH=1
    };

    enum Units {
        METER		= 50,
        MILE		= 51,
        KM			= 52,
        YARD		= 53,
        FOOT		= 54
    };

    typedef std::map<UnitsOfMeasurementAttribute,UnitsOfMeasurementValueStruct > UnitsOfMeasurement;

    Configuration_proxy()
    {
        Locale en_US { "eng","USA", "Latn" };
        Locale de_DE { "deu","DEU", "Latn" };
        Locale fr_FR { "fra","FRA", "Latn" };
        Locale jp_JP { "jpn","JPN", "Hrkt" };
        m_locale_list.push_back(en_US);
        m_locale_list.push_back(de_DE);
        m_locale_list.push_back(fr_FR);
//        m_locale_list.push_back(jp_JP); //For the test Japanese is not supported

        UnitsOfMeasurementValueStruct value {intValue,METER};

        m_units_of_measurement[LENGTH] = value;
    }

    Version GetVersion()
    {
        return m_version;
    }

    Locale GetLocale()
    {
        return m_locale;
    }
    std::vector<Locale > GetSupportedLocales()
    {
        return m_locale_list;
    }

    void SetLocale(Locale& locale)
    {
        m_locale = locale;
    }

    UnitsOfMeasurement GetUnitsOfMeasurement()
    {
        return m_units_of_measurement;
    }

public:
private:
    Version m_version;
    Locale m_locale;
    std::vector<Locale > m_locale_list;
    UnitsOfMeasurement m_units_of_measurement;
};
} } }

class NavigationCoreConfiguration : public node::ObjectWrap {
public:
    static v8::Persistent<v8::FunctionTemplate> constructor;
    static void Init(v8::Handle<v8::Object> target);

protected:
    NavigationCoreConfiguration();

    static v8::Handle<v8::Value> New(const v8::Arguments& args);
    static v8::Handle<v8::Value> GetVersion(const v8::Arguments& args);
    static v8::Handle<v8::Value> GetSupportedLocales(const v8::Arguments& args);
    static v8::Handle<v8::Value> GetUnitsOfMeasurement(const v8::Arguments& args);

    static v8::Handle<v8::Value> GetProperty(const v8::Arguments& args);
    static v8::Handle<v8::Value> SetProperty(const v8::Arguments& args);

    static void ConfigurationChanged(const v8::Handle<v8::Function> &callback, const v8::Handle<v8::Array>& array);

    // Your own object variables here
    org::genivi::navigationcore::Configuration_proxy m_proxy;
};

#endif