summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc8
-rw-r--r--src/components/smart_objects/include/smart_objects/array_schema_item.h15
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h11
-rw-r--r--src/components/smart_objects/src/array_schema_item.cc19
-rw-r--r--src/components/smart_objects/src/object_schema_item.cc31
-rwxr-xr-xtools/InterfaceGenerator/generator/generators/SmartFactoryBase.py38
6 files changed, 84 insertions, 38 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc
index c1cf905e31..39d20cf67d 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc
@@ -294,10 +294,8 @@ void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() {
case SMemberType::SMEMBER_VDR_MOBILE: {
// valid since struct_schema_items is not used in
// InitStructSchemaItem_VehicleDataResult
- mobile_apis::MOBILE_API::TStructsSchemaItems mobile_struct_schema_items;
auto member_schema =
- mobile_apis::MOBILE_API::InitStructSchemaItem_VehicleDataResult(
- mobile_struct_schema_items);
+ mobile_apis::MOBILE_API::InitStructSchemaItem_VehicleDataResult();
return SMember(
member_schema,
false, // root level items should not be mandatory
@@ -330,10 +328,8 @@ void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() {
case SMemberType::SMEMBER_VDR_HMI: {
// valid since struct_schema_items is not used in
// InitStructSchemaItem_Common_VehicleDataResult
- hmi_apis::HMI_API::TStructsSchemaItems hmi_struct_schema_items;
auto member_schema =
- hmi_apis::HMI_API::InitStructSchemaItem_Common_VehicleDataResult(
- hmi_struct_schema_items);
+ hmi_apis::HMI_API::InitStructSchemaItem_Common_VehicleDataResult();
return SMember(
member_schema, false // root level items should not be mandatory
);
diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h
index 8f9a179fff..43870ddb42 100644
--- a/src/components/smart_objects/include/smart_objects/array_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h
@@ -63,6 +63,13 @@ class CArraySchemaItem : public ISchemaItem {
const TSchemaItemParameter<size_t>& MaxSize =
TSchemaItemParameter<size_t>());
+ static std::shared_ptr<CArraySchemaItem> create(
+ ISchemaItem* ElementSchemaItem,
+ const TSchemaItemParameter<size_t>& MinSize =
+ TSchemaItemParameter<size_t>(),
+ const TSchemaItemParameter<size_t>& MaxSize =
+ TSchemaItemParameter<size_t>());
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -131,10 +138,16 @@ class CArraySchemaItem : public ISchemaItem {
const TSchemaItemParameter<size_t>& MinSize,
const TSchemaItemParameter<size_t>& MaxSize);
+ CArraySchemaItem(ISchemaItem* ElementSchemaItem,
+ const TSchemaItemParameter<size_t>& MinSize,
+ const TSchemaItemParameter<size_t>& MaxSize);
+
/**
* @brief SchemaItem for array elements.
**/
- const ISchemaItemPtr mElementSchemaItem;
+ ISchemaItem* mElementSchemaItem;
+ const ISchemaItemPtr mElementSchemaItemShared;
+
/**
* @brief Minimum allowed size.
**/
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index d5c8a7f3e9..0a971d50ee 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -69,6 +69,14 @@ struct SMember {
const bool IsRemoved = false,
const std::vector<SMember>& history_vector = {});
+ SMember(ISchemaItem* SchemaItem,
+ const bool IsMandatory = true,
+ const std::string& Since = "",
+ const std::string& Until = "",
+ const bool IsDeprecated = false,
+ const bool IsRemoved = false,
+ const std::vector<SMember>& history_vector = {});
+
/**
* @brief Checks the version a parameter was removed (until)
* If the mobile's msg version is greater than or
@@ -79,7 +87,8 @@ struct SMember {
/**
* @brief Member schema item.
**/
- ISchemaItemPtr mSchemaItem;
+ ISchemaItem* mSchemaItem;
+ ISchemaItemPtr mSchemaItemShared;
/**
* @brief true if member is mandatory, false otherwise.
**/
diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc
index fd8f3ce71d..6f1e65d2eb 100644
--- a/src/components/smart_objects/src/array_schema_item.cc
+++ b/src/components/smart_objects/src/array_schema_item.cc
@@ -44,6 +44,14 @@ std::shared_ptr<CArraySchemaItem> CArraySchemaItem::create(
new CArraySchemaItem(ElementSchemaItem, MinSize, MaxSize));
}
+std::shared_ptr<CArraySchemaItem> CArraySchemaItem::create(
+ ISchemaItem* ElementSchemaItem,
+ const TSchemaItemParameter<size_t>& MinSize,
+ const TSchemaItemParameter<size_t>& MaxSize) {
+ return std::shared_ptr<CArraySchemaItem>(
+ new CArraySchemaItem(ElementSchemaItem, MinSize, MaxSize));
+}
+
errors::eType CArraySchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report,
@@ -161,10 +169,19 @@ TypeID CArraySchemaItem::GetType() {
return TYPE_ARRAY;
}
-CArraySchemaItem::CArraySchemaItem(const ISchemaItemPtr ElementSchemaItem,
+CArraySchemaItem::CArraySchemaItem(ISchemaItem* ElementSchemaItem,
const TSchemaItemParameter<size_t>& MinSize,
const TSchemaItemParameter<size_t>& MaxSize)
: mElementSchemaItem(ElementSchemaItem)
+ , mElementSchemaItemShared(nullptr)
+ , mMinSize(MinSize)
+ , mMaxSize(MaxSize) {}
+
+CArraySchemaItem::CArraySchemaItem(const ISchemaItemPtr ElementSchemaItem,
+ const TSchemaItemParameter<size_t>& MinSize,
+ const TSchemaItemParameter<size_t>& MaxSize)
+ : mElementSchemaItem(ElementSchemaItem.get())
+ , mElementSchemaItemShared(ElementSchemaItem)
, mMinSize(MinSize)
, mMaxSize(MaxSize) {}
diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc
index d22f1692c8..4b14d9e5a1 100644
--- a/src/components/smart_objects/src/object_schema_item.cc
+++ b/src/components/smart_objects/src/object_schema_item.cc
@@ -51,19 +51,21 @@ namespace ns_smart_device_link {
namespace ns_smart_objects {
SMember::SMember()
- : mSchemaItem(CAlwaysFalseSchemaItem::create())
- , mIsMandatory(true)
- , mIsDeprecated(false)
- , mIsRemoved(false) {}
+ : mIsMandatory(true), mIsDeprecated(false), mIsRemoved(false) {
+ mSchemaItemShared = CAlwaysFalseSchemaItem::create();
+ mSchemaItem = mSchemaItemShared.get();
+}
-SMember::SMember(const ISchemaItemPtr SchemaItem,
+SMember::SMember(ISchemaItem* SchemaItem,
const bool IsMandatory,
const std::string& Since,
const std::string& Until,
const bool IsDeprecated,
const bool IsRemoved,
const std::vector<SMember>& history_vector)
- : mSchemaItem(SchemaItem), mIsMandatory(IsMandatory) {
+ : mSchemaItem(SchemaItem)
+ , mSchemaItemShared(nullptr)
+ , mIsMandatory(IsMandatory) {
if (Since.size() > 0) {
utils::SemanticVersion since_struct(Since);
if (since_struct.isValid()) {
@@ -81,6 +83,23 @@ SMember::SMember(const ISchemaItemPtr SchemaItem,
mHistoryVector = history_vector;
}
+SMember::SMember(const ISchemaItemPtr SchemaItem,
+ const bool IsMandatory,
+ const std::string& Since,
+ const std::string& Until,
+ const bool IsDeprecated,
+ const bool IsRemoved,
+ const std::vector<SMember>& history_vector)
+ : SMember(SchemaItem.get(),
+ IsMandatory,
+ Since,
+ Until,
+ IsDeprecated,
+ IsRemoved,
+ history_vector) {
+ mSchemaItemShared = SchemaItem;
+}
+
bool SMember::CheckHistoryFieldVersion(
const utils::SemanticVersion& MessageVersion) const {
if (MessageVersion.isValid()) {
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
index 736a95f7ac..69e8d71428 100755
--- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
+++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
@@ -785,6 +785,7 @@ class CodeGenerator(object):
result_array.append(self._impl_code_item_decl_template.substitute(
comment="",
var_name=self._gen_schema_item_var_name(item),
+ var_type="std::shared_ptr<ISchemaItem>",
item_decl=self._impl_function_schema))
result_array.append(self._gen_function_history_vector_item_fill(item, member.name))
count += 1
@@ -811,6 +812,7 @@ class CodeGenerator(object):
return self._impl_code_item_decl_template.substitute(
comment=self._gen_comment(member, False),
var_name=self._gen_schema_item_var_name(member),
+ var_type="ISchemaItem*" if type(member.param_type) is Struct else "std::shared_ptr<ISchemaItem>",
item_decl=self._gen_schema_item_decl_code(
member.param_type,
member.name,
@@ -1724,11 +1726,11 @@ class CodeGenerator(object):
u'''\n'''
u'''using namespace ns_smart_device_link::ns_smart_objects;\n'''
u'''\n'''
+ u'''$namespace::$class_name::TStructsSchemaItems $namespace::$class_name::struct_schema_items = {};\n\n'''
u'''$namespace::$class_name::$class_name()\n'''
u''' : ns_smart_device_link::ns_json_handler::CSmartFactory<FunctionID::eType, '''
u'''messageType::eType, StructIdentifiers::eType>() {\n'''
- u''' TStructsSchemaItems struct_schema_items;\n'''
- u''' InitStructSchemes(struct_schema_items);\n'''
+ u''' InitStructSchemes();\n'''
u'''\n'''
u''' std::set<FunctionID::eType> function_id_items;\n'''
u'''${function_id_items}'''
@@ -1736,7 +1738,7 @@ class CodeGenerator(object):
u''' std::set<messageType::eType> message_type_items;\n'''
u'''${message_type_items}'''
u'''\n'''
- u''' InitFunctionSchemes(struct_schema_items, function_id_items, '''
+ u''' InitFunctionSchemes(function_id_items, '''
u'''message_type_items);\n'''
u'''}\n'''
u'''\n'''
@@ -1780,13 +1782,11 @@ class CodeGenerator(object):
u''' InitFunctionSchema(function_id, message_type);\n'''
u'''}\n'''
u'''\n'''
- u'''void $namespace::$class_name::InitStructSchemes(\n'''
- u''' TStructsSchemaItems &struct_schema_items) {'''
+ u'''void $namespace::$class_name::InitStructSchemes() {'''
u'''$struct_schema_items'''
u'''}\n'''
u'''\n'''
u'''void $namespace::$class_name::InitFunctionSchemes(\n'''
- u''' const TStructsSchemaItems &struct_schema_items,\n'''
u''' const std::set<FunctionID::eType> &function_id_items,\n'''
u''' const std::set<messageType::eType> &message_type_items) {\n'''
u'''$pre_function_schemas'''
@@ -1797,8 +1797,6 @@ class CodeGenerator(object):
u''' const FunctionID::eType &function_id,\n'''
u''' const messageType::eType &message_type) {\n'''
u'''\n'''
- u''' TStructsSchemaItems struct_schema_items;\n'''
- u''' InitStructSchemes(struct_schema_items);\n'''
u'''\n'''
u''' std::set<FunctionID::eType> function_id_items { function_id };\n'''
u''' std::set<messageType::eType> message_type_items { message_type };\n'''
@@ -1873,13 +1871,13 @@ class CodeGenerator(object):
u''' ns_smart_device_link::ns_json_handler::SmartSchemaKey<FunctionID::eType, messageType::eType> shema_key(function_id, message_type);\n'''
u''' functions_schemes_[shema_key] = '''
u'''InitFunction_${function_id}_${message_type}('''
- u'''struct_schema_items, function_id_items, message_type_items);\n'''
+ u'''function_id_items, message_type_items);\n'''
u''' break;\n'''
u'''}\n''')
_struct_schema_item_template = string.Template(
u'''std::shared_ptr<ISchemaItem> struct_schema_item_${name} = '''
- u'''InitStructSchemaItem_${name}(struct_schema_items);\n'''
+ u'''InitStructSchemaItem_${name}();\n'''
u'''structs_schemes_.insert(std::make_pair('''
u'''StructIdentifiers::${name}, CSmartSchema('''
u'''struct_schema_item_${name})));\n''')
@@ -1890,12 +1888,11 @@ class CodeGenerator(object):
u'''SmartSchemaKey<FunctionID::eType, messageType::eType>'''
u'''(FunctionID::$function_id, messageType::$message_type), '''
u'''InitFunction_${function_id}_${message_type}('''
- u'''struct_schema_items, function_id_items, message_type_items)));''')
+ u'''function_id_items, message_type_items)));''')
_struct_impl_template = string.Template(
u'''std::shared_ptr<ISchemaItem> $namespace::$class_name::'''
- u'''InitStructSchemaItem_${struct_name}(\n'''
- u''' TStructsSchemaItems &struct_schema_items) {\n'''
+ u'''InitStructSchemaItem_${struct_name}() {\n'''
u'''$code'''
u'''}\n''')
@@ -1932,7 +1929,7 @@ class CodeGenerator(object):
_impl_code_item_decl_template = string.Template(
u'''${comment}'''
- u'''std::shared_ptr<ISchemaItem> ${var_name} = ${item_decl};''')
+ u'''${var_type} ${var_name} = ${item_decl};''')
_impl_code_shared_ptr_vector_template = string.Template(
u'''std::vector<SMember> ${var_name}_history_vector;''')
@@ -1954,7 +1951,7 @@ class CodeGenerator(object):
_impl_code_struct_item_template = string.Template(
u'''ProvideObjectSchemaItemForStruct(struct_schema_items, '''
- u'''StructIdentifiers::${name})''')
+ u'''StructIdentifiers::${name}).get()''')
_impl_code_enum_item_template = string.Template(
u'''TEnumSchemaItem<${type}::eType>::create(${params})''')
@@ -1988,7 +1985,6 @@ class CodeGenerator(object):
_function_impl_template = string.Template(
u'''CSmartSchema $namespace::$class_name::'''
u'''InitFunction_${function_id}_${message_type}(\n'''
- u''' const TStructsSchemaItems &struct_schema_items,\n'''
u''' const std::set<FunctionID::eType> &function_id_items,\n'''
u''' const std::set<messageType::eType> &message_type_items) {\n'''
u'''$code'''
@@ -2066,20 +2062,17 @@ class CodeGenerator(object):
u''' /**\n'''
u''' * @brief Initializes all struct schemes.\n'''
u''' */\n'''
- u''' void InitStructSchemes('''
- u'''TStructsSchemaItems &struct_schema_items);\n'''
+ u''' void InitStructSchemes();\n'''
u'''\n'''
u''' /**\n'''
u''' * @brief Initializes all function schemes.\n'''
u''' *\n'''
- u''' * @param struct_schema_items Struct schema items.\n'''
u''' * @param function_id_items Set of all elements '''
u'''of FunctionID enum.\n'''
u''' * @param message_type_items Set of all elements '''
u'''of messageType enum.\n'''
u''' */\n'''
u''' void InitFunctionSchemes(\n'''
- u''' const TStructsSchemaItems &struct_schema_items,\n'''
u''' const std::set<FunctionID::eType> &function_id_items,\n'''
u''' const std::set<messageType::eType> '''
u'''&message_type_items);\n'''
@@ -2097,6 +2090,7 @@ class CodeGenerator(object):
u'''$init_function_decls'''
u'''\n'''
u''' public:\n'''
+ u''' static TStructsSchemaItems struct_schema_items;\n'''
u'''$init_struct_decls'''
u'''};''')
@@ -2107,7 +2101,6 @@ class CodeGenerator(object):
u'''$comment\n'''
u'''static ns_smart_device_link::ns_smart_objects::CSmartSchema '''
u'''InitFunction_${function_id}_${message_type}(\n'''
- u''' const TStructsSchemaItems &struct_schema_items,\n'''
u''' const std::set<FunctionID::eType> &function_id_items,\n'''
u''' const std::set<messageType::eType> &message_type_items);''')
@@ -2115,8 +2108,7 @@ class CodeGenerator(object):
u'''$comment\n'''
u'''static '''
u'''std::shared_ptr<ns_smart_device_link::ns_smart_objects::ISchemaItem> '''
- u'''InitStructSchemaItem_${struct_name}(\n'''
- u''' TStructsSchemaItems &struct_schema_items);''')
+ u'''InitStructSchemaItem_${struct_name}();\n''')
_class_comment_template = string.Template(
u'''/**\n'''