blob: 5ea73e2dec2e310c30163b848d333f6e976cd6ea (
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
|
#ifndef VEHICLE_DATA_ITEM_SCHEMA_H
#define VEHICLE_DATA_ITEM_SCHEMA_H
#include "policy/policy_table/types.h"
#include "smart_objects/always_false_schema_item.h"
#include "smart_objects/always_true_schema_item.h"
#include "smart_objects/array_schema_item.h"
#include "smart_objects/bool_schema_item.h"
#include "smart_objects/enum_schema_item.h"
#include "smart_objects/number_schema_item.h"
#include "smart_objects/object_schema_item.h"
#include "smart_objects/schema_item.h"
#include "smart_objects/schema_item_parameter.h"
#include "smart_objects/smart_object.h"
#include "smart_objects/string_schema_item.h"
#include "utils/logger.h"
namespace vehicle_info_plugin {
namespace smart_objects = ns_smart_device_link::ns_smart_objects;
namespace policy_table = rpc::policy_table_interface_base;
class VehicleDataItemSchema;
typedef std::shared_ptr<VehicleDataItemSchema> VehicleDataItemSchemaPtr;
typedef smart_objects::TSchemaItemParameter<policy_table::VehicleDataItem>
PolicyDataItem;
/**
* @brief VehicleData schema item.
**/
class VehicleDataItemSchema : public smart_objects::ISchemaItem {
public:
enum SchemaType { MOBILE = 0, HMI };
/**
* @brief Create a new schema item.
* @param PolicyDataItem& SchemaItem for VehicleDataItem elements.
* @return Shared pointer to a new schema item.
**/
static VehicleDataItemSchemaPtr create(PolicyDataItem& policy_item,
SchemaType schema_type);
/**
* @brief Validate smart object.
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
* @param MessageVersion to check mobile RPC version against RPC Spec History
* @param allow_unknown_enums
* false - unknown enum values (left as string values after applySchema)
* will be considered invalid.
* true - such values will be considered valid.
* @return ns_smart_objects::errors::eType
**/
smart_objects::errors::eType validate(
const smart_objects::SmartObject& Object,
rpc::ValidationReport* report__,
const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(),
const bool allow_unknown_enums = false) OVERRIDE;
private:
/**
* @brief Constructor.
* @param PolicyDataItem& SchemaItem for VehicleDataItem elements.
* @param SchemaType defines api type for schema to be generated.
**/
VehicleDataItemSchema(PolicyDataItem& policy_item, SchemaType schema_type);
/*
* @brief Check whether provided type is POD type
* @param const std::string& type_name - name of type to check
* @return true - if type is POD type and false - if not
*/
const bool isPODType(const std::string& type_name) const;
/*
* @brief Get Enum schema for provided type
* @param const std::string& type_name - name of enum type to provide
* @return Shared pointer to a new schema item. If no schema found - nullptr
* is returned.
*/
smart_objects::ISchemaItemPtr getEnumSchema(
const std::string& type_name) const;
/**
* @brief Apply schema.
* @param Object Object to apply schema.
* @param remove_unknown_parameters contains true if need to remove unknown
* parameters from smart object otherwise contains false.
**/
void applySchema(smart_objects::SmartObject& Object,
const bool remove_unknown_parameters,
const utils::SemanticVersion& MessageVersion) OVERRIDE;
/**
* @brief Unapply schema.
* @param Object Object to unapply schema.
* @param remove_unknown_parameters contains true if need to remove unknown
* parameters
**/
void unapplySchema(smart_objects::SmartObject& Object,
const bool remove_unknown_parameters) OVERRIDE;
/*
* @brief Get schema for a POD type
* @param const VehicleDataItem& policy_item - item, that contains info about
* type
* @return Shared pointer to a new schema item. If no schema found - nullptr
* is returned.
*/
smart_objects::ISchemaItemPtr GetPODTypeSchema(
const policy_table::VehicleDataItem& policy_item, SchemaType schema_type);
smart_objects::ISchemaItemPtr so_schema_item_;
};
} // namespace vehicle_info_plugin
#endif // VEHICLE_DATA_ITEM_SCHEMA_H
|