diff --git a/Development/nmos/configuration_utils.cpp b/Development/nmos/configuration_utils.cpp index 849befb3a..7c90457f0 100644 --- a/Development/nmos/configuration_utils.cpp +++ b/Development/nmos/configuration_utils.cpp @@ -724,7 +724,7 @@ namespace nmos } // Order role paths by length so we implicitly process blocks before the child objects of that block - std::sort(role_paths.begin(), role_paths.end(), [](auto a, auto b) { return a.size() < b.size(); }); + std::sort(role_paths.begin(), role_paths.end(), [](const web::json::array& a, const web::json::array& b) { return a.size() < b.size(); }); for (const auto& role_path: role_paths) { diff --git a/Development/nmos/control_protocol_handlers.h b/Development/nmos/control_protocol_handlers.h index 18fa3824e..08328f65d 100644 --- a/Development/nmos/control_protocol_handlers.h +++ b/Development/nmos/control_protocol_handlers.h @@ -49,8 +49,12 @@ namespace nmos struct counter { utility::string_t name; - uint64_t value{0}; + uint64_t value; utility::string_t description; + + counter() : name(), value(0), description() {} + counter(const utility::string_t& name, uint64_t value, const utility::string_t& description) + : name(name), value(value), description(description) {} }; } typedef std::function(void)> get_packet_counters_handler; diff --git a/Development/nmos/control_protocol_resource.h b/Development/nmos/control_protocol_resource.h index 902b995b0..633777dcf 100644 --- a/Development/nmos/control_protocol_resource.h +++ b/Development/nmos/control_protocol_resource.h @@ -507,185 +507,185 @@ namespace nmos namespace details { // Deprecated : use nc::details::make_method_result - inline web::json::value make_nc_method_result(const nc_method_result& method_result) { return nc::details::make_method_result(method_result); }; - inline web::json::value make_nc_method_result_error(const nc_method_result& method_result, const utility::string_t& error_message) { return nc::details::make_method_result_error(method_result, error_message); }; - inline web::json::value make_nc_method_result(const nc_method_result& method_result, const web::json::value& value) { return nc::details::make_method_result(method_result, value); }; + inline web::json::value make_nc_method_result(const nc_method_result& method_result) { return nc::details::make_method_result(method_result); } + inline web::json::value make_nc_method_result_error(const nc_method_result& method_result, const utility::string_t& error_message) { return nc::details::make_method_result_error(method_result, error_message); } + inline web::json::value make_nc_method_result(const nc_method_result& method_result, const web::json::value& value) { return nc::details::make_method_result(method_result, value); } // Deprecated: use nc::details::make use nc::details::make_element_id - inline web::json::value make_nc_element_id(const nc_element_id& element_id) { return nc::details::make_element_id(element_id); }; + inline web::json::value make_nc_element_id(const nc_element_id& element_id) { return nc::details::make_element_id(element_id); } // Deprecated: use nc::details::make use nc::details::parse_element_id - inline nc_element_id parse_nc_element_id(const web::json::value& element_id) { return nc::details::parse_element_id(element_id); }; + inline nc_element_id parse_nc_element_id(const web::json::value& element_id) { return nc::details::parse_element_id(element_id); } // Deprecated: use nc::details::make use nc::details::make_event_id - inline web::json::value make_nc_event_id(const nc_event_id& event_id) { return nc::details::make_event_id(event_id); }; + inline web::json::value make_nc_event_id(const nc_event_id& event_id) { return nc::details::make_event_id(event_id); } // Deprecated use nc::details::parse_event_id - inline nc_event_id parse_nc_event_id(const web::json::value& event_id) { return nc::details::parse_event_id(event_id); }; + inline nc_event_id parse_nc_event_id(const web::json::value& event_id) { return nc::details::parse_event_id(event_id); } // Deprecated: use nc::details::make use nc::details::make_method_id - inline web::json::value make_nc_method_id(const nc_method_id& method_id) { return nc::details::make_method_id(method_id); }; + inline web::json::value make_nc_method_id(const nc_method_id& method_id) { return nc::details::make_method_id(method_id); } // Deprecated: use nc::details::parse_method_id - inline nc_method_id parse_nc_method_id(const web::json::value& method_id) { return nc::details::parse_method_id(method_id); }; + inline nc_method_id parse_nc_method_id(const web::json::value& method_id) { return nc::details::parse_method_id(method_id); } // Deprecated: use nc::details::make_property_id - inline web::json::value make_nc_property_id(const nc_property_id& property_id) { return nc::details::make_property_id(property_id); }; + inline web::json::value make_nc_property_id(const nc_property_id& property_id) { return nc::details::make_property_id(property_id); } // Deprecated: use nc::details::parse_property_id - inline nc_property_id parse_nc_property_id(const web::json::value& property_id) { return nc::details::parse_property_id(property_id); }; + inline nc_property_id parse_nc_property_id(const web::json::value& property_id) { return nc::details::parse_property_id(property_id); } // Deprecated: use nc::details::make_class_id - inline web::json::value make_nc_class_id(const nc_class_id& class_id) { return nc::details::make_class_id(class_id); }; + inline web::json::value make_nc_class_id(const nc_class_id& class_id) { return nc::details::make_class_id(class_id); } // Deprecated: use nc::details::make - inline nc_class_id parse_nc_class_id(const web::json::array& class_id) { return nc::details::parse_class_id(class_id); }; + inline nc_class_id parse_nc_class_id(const web::json::array& class_id) { return nc::details::parse_class_id(class_id); } // Deprecated: use nc::details::make_manufacturer - inline web::json::value make_nc_manufacturer(const utility::string_t& name, nc_organization_id organization_id, const web::uri& website) { return nc::details::make_manufacturer(name, organization_id, website); }; - inline web::json::value make_nc_manufacturer(const utility::string_t& name, nc_organization_id organization_id) { return nc::details::make_manufacturer(name, organization_id); }; - inline web::json::value make_nc_manufacturer(const utility::string_t& name) { return nc::details::make_manufacturer(name); }; + inline web::json::value make_nc_manufacturer(const utility::string_t& name, nc_organization_id organization_id, const web::uri& website) { return nc::details::make_manufacturer(name, organization_id, website); } + inline web::json::value make_nc_manufacturer(const utility::string_t& name, nc_organization_id organization_id) { return nc::details::make_manufacturer(name, organization_id); } + inline web::json::value make_nc_manufacturer(const utility::string_t& name) { return nc::details::make_manufacturer(name); } // Deprecated: use nc::details::make_product inline web::json::value make_nc_product(const utility::string_t& name, const utility::string_t& key, const utility::string_t& revision_level, - const utility::string_t& brand_name, const nc_uuid& uuid, const utility::string_t& description) { return nc::details::make_product(name, key, revision_level, brand_name, uuid, description); }; + const utility::string_t& brand_name, const nc_uuid& uuid, const utility::string_t& description) { return nc::details::make_product(name, key, revision_level, brand_name, uuid, description); } inline web::json::value make_nc_product(const utility::string_t& name, const utility::string_t& key, const utility::string_t& revision_level, - const utility::string_t& brand_name, const nc_uuid& uuid) { return nc::details::make_product(name, key, revision_level, brand_name, uuid); }; + const utility::string_t& brand_name, const nc_uuid& uuid) { return nc::details::make_product(name, key, revision_level, brand_name, uuid); } inline web::json::value make_nc_product(const utility::string_t& name, const utility::string_t& key, const utility::string_t& revision_level, - const utility::string_t& brand_name) { return nc::details::make_product(name, key, revision_level, brand_name); }; - inline web::json::value make_nc_product(const utility::string_t& name, const utility::string_t& key, const utility::string_t& revision_level) { return nc::details::make_product(name, key, revision_level); }; + const utility::string_t& brand_name) { return nc::details::make_product(name, key, revision_level, brand_name); } + inline web::json::value make_nc_product(const utility::string_t& name, const utility::string_t& key, const utility::string_t& revision_level) { return nc::details::make_product(name, key, revision_level); } // Deprecated: use nc::details::make_device_operational_state - inline web::json::value make_nc_device_operational_state(nc_device_generic_state::state generic_state, const web::json::value& device_specific_details) { return nc::details::make_device_operational_state(generic_state, device_specific_details); }; + inline web::json::value make_nc_device_operational_state(nc_device_generic_state::state generic_state, const web::json::value& device_specific_details) { return nc::details::make_device_operational_state(generic_state, device_specific_details); } // Deprecated: use nc::details::make_block_member_descriptor - inline web::json::value make_nc_block_member_descriptor(const utility::string_t& description, const utility::string_t& role, nc_oid oid, bool constant_oid, const nc_class_id& class_id, const utility::string_t& user_label, nc_oid owner) { return nc::details::make_block_member_descriptor(description, role, oid, constant_oid, class_id, user_label, owner); }; + inline web::json::value make_nc_block_member_descriptor(const utility::string_t& description, const utility::string_t& role, nc_oid oid, bool constant_oid, const nc_class_id& class_id, const utility::string_t& user_label, nc_oid owner) { return nc::details::make_block_member_descriptor(description, role, oid, constant_oid, class_id, user_label, owner); } // Deprecated: use nc::details::make_class_descriptor - inline web::json::value make_nc_class_descriptor(const utility::string_t& description, const nc_class_id& class_id, const nc_name& name, const utility::string_t& fixed_role, const web::json::value& properties, const web::json::value& methods, const web::json::value& events) { return nc::details::make_class_descriptor(description, class_id, name, fixed_role, properties, methods, events); }; - inline web::json::value make_nc_class_descriptor(const utility::string_t& description, const nc_class_id& class_id, const nc_name& name, const web::json::value& properties, const web::json::value& methods, const web::json::value& events) { return nc::details::make_class_descriptor(description, class_id, name, properties, methods, events); }; + inline web::json::value make_nc_class_descriptor(const utility::string_t& description, const nc_class_id& class_id, const nc_name& name, const utility::string_t& fixed_role, const web::json::value& properties, const web::json::value& methods, const web::json::value& events) { return nc::details::make_class_descriptor(description, class_id, name, fixed_role, properties, methods, events); } + inline web::json::value make_nc_class_descriptor(const utility::string_t& description, const nc_class_id& class_id, const nc_name& name, const web::json::value& properties, const web::json::value& methods, const web::json::value& events) { return nc::details::make_class_descriptor(description, class_id, name, properties, methods, events); } // Deprecated: use nc::details::make_enum_item_descriptor - inline web::json::value make_nc_enum_item_descriptor(const utility::string_t& description, const nc_name& name, uint16_t val) { return nc::details::make_enum_item_descriptor(description, name, val); }; + inline web::json::value make_nc_enum_item_descriptor(const utility::string_t& description, const nc_name& name, uint16_t val) { return nc::details::make_enum_item_descriptor(description, name, val); } // Deprecated: use nc::details::make_event_descriptor - inline web::json::value make_nc_event_descriptor(const utility::string_t& description, const nc_event_id& id, const nc_name& name, const utility::string_t& event_datatype, bool is_deprecated) { return nc::details::make_event_descriptor(description, id, name, event_datatype, is_deprecated); }; + inline web::json::value make_nc_event_descriptor(const utility::string_t& description, const nc_event_id& id, const nc_name& name, const utility::string_t& event_datatype, bool is_deprecated) { return nc::details::make_event_descriptor(description, id, name, event_datatype, is_deprecated); } // Deprecated: use nc::details::make_field_descriptor - inline web::json::value make_nc_field_descriptor(const utility::string_t& description, const nc_name& name, const utility::string_t& type_name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_field_descriptor(description, name, type_name, is_nullable, is_sequence, constraints); }; - inline web::json::value make_nc_field_descriptor(const utility::string_t& description, const nc_name& name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_field_descriptor(description, name, is_nullable, is_sequence, constraints); }; + inline web::json::value make_nc_field_descriptor(const utility::string_t& description, const nc_name& name, const utility::string_t& type_name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_field_descriptor(description, name, type_name, is_nullable, is_sequence, constraints); } + inline web::json::value make_nc_field_descriptor(const utility::string_t& description, const nc_name& name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_field_descriptor(description, name, is_nullable, is_sequence, constraints); } // Deprecated: use nc::details::make_method_descriptor - inline web::json::value make_nc_method_descriptor(const utility::string_t& description, const nc_method_id& id, const nc_name& name, const utility::string_t& result_datatype, const web::json::value& parameters, bool is_deprecated) { return nc::details::make_method_descriptor(description, id, name, result_datatype, parameters, is_deprecated); }; + inline web::json::value make_nc_method_descriptor(const utility::string_t& description, const nc_method_id& id, const nc_name& name, const utility::string_t& result_datatype, const web::json::value& parameters, bool is_deprecated) { return nc::details::make_method_descriptor(description, id, name, result_datatype, parameters, is_deprecated); } // Deprecated: use nc::details::make_parameter_descriptor - inline web::json::value make_nc_parameter_descriptor(const utility::string_t& description, const nc_name& name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_parameter_descriptor(description, name, is_nullable, is_sequence, constraints); }; - inline web::json::value make_nc_parameter_descriptor(const utility::string_t& description, const nc_name& name, const utility::string_t& type_name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_parameter_descriptor(description, name, type_name, is_nullable, is_sequence, constraints); }; + inline web::json::value make_nc_parameter_descriptor(const utility::string_t& description, const nc_name& name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_parameter_descriptor(description, name, is_nullable, is_sequence, constraints); } + inline web::json::value make_nc_parameter_descriptor(const utility::string_t& description, const nc_name& name, const utility::string_t& type_name, bool is_nullable, bool is_sequence, const web::json::value& constraints) { return nc::details::make_parameter_descriptor(description, name, type_name, is_nullable, is_sequence, constraints); } // Deprecated: use nc::details::make_property_descriptor inline web::json::value make_nc_property_descriptor(const utility::string_t& description, const nc_property_id& id, const nc_name& name, const utility::string_t& type_name, - bool is_read_only, bool is_nullable, bool is_sequence, bool is_deprecated, const web::json::value& constraints) { return nc::details::make_property_descriptor(description, id, name, type_name, is_read_only, is_nullable, is_sequence, is_deprecated, constraints); }; + bool is_read_only, bool is_nullable, bool is_sequence, bool is_deprecated, const web::json::value& constraints) { return nc::details::make_property_descriptor(description, id, name, type_name, is_read_only, is_nullable, is_sequence, is_deprecated, constraints); } // Deprecated: use nc::details::make_datatype_descriptor_enum - inline web::json::value make_nc_datatype_descriptor_enum(const utility::string_t& description, const nc_name& name, const web::json::value& items, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_enum(description, name, items, constraints); }; + inline web::json::value make_nc_datatype_descriptor_enum(const utility::string_t& description, const nc_name& name, const web::json::value& items, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_enum(description, name, items, constraints); } // Deprecated: use nc::details::make_datatype_descriptor_primitive - inline web::json::value make_nc_datatype_descriptor_primitive(const utility::string_t& description, const nc_name& name, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_primitive(description, name, constraints); }; + inline web::json::value make_nc_datatype_descriptor_primitive(const utility::string_t& description, const nc_name& name, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_primitive(description, name, constraints); } // Deprecated: use nc::details::make_datatype_descriptor_struct - inline web::json::value make_nc_datatype_descriptor_struct(const utility::string_t& description, const nc_name& name, const web::json::value& fields, const utility::string_t& parent_type, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_struct(description, name, fields, parent_type, constraints); }; - inline web::json::value make_nc_datatype_descriptor_struct(const utility::string_t& description, const nc_name& name, const web::json::value& fields, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_struct(description, name, fields, constraints); }; + inline web::json::value make_nc_datatype_descriptor_struct(const utility::string_t& description, const nc_name& name, const web::json::value& fields, const utility::string_t& parent_type, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_struct(description, name, fields, parent_type, constraints); } + inline web::json::value make_nc_datatype_descriptor_struct(const utility::string_t& description, const nc_name& name, const web::json::value& fields, const web::json::value& constraints) { return nc::details::make_datatype_descriptor_struct(description, name, fields, constraints); } // Deprecated: use nc::details::make_datatype_typedef - inline web::json::value make_nc_datatype_typedef(const utility::string_t& description, const nc_name& name, bool is_sequence, const utility::string_t& parent_type, const web::json::value& constraints) { return nc::details::make_datatype_typedef(description, name, is_sequence, parent_type, constraints); }; + inline web::json::value make_nc_datatype_typedef(const utility::string_t& description, const nc_name& name, bool is_sequence, const utility::string_t& parent_type, const web::json::value& constraints) { return nc::details::make_datatype_typedef(description, name, is_sequence, parent_type, constraints); } // Deprecated: use nc::details::make_property_constraints - inline web::json::value make_nc_property_constraints(const nc_property_id& property_id, const web::json::value& default_value) { return nc::details::make_property_constraints(property_id, default_value); }; + inline web::json::value make_nc_property_constraints(const nc_property_id& property_id, const web::json::value& default_value) { return nc::details::make_property_constraints(property_id, default_value); } // Deprecated: use nc::details::make_property_constraints_number - inline web::json::value make_nc_property_constraints_number(const nc_property_id& property_id, uint64_t default_value, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_property_constraints_number(property_id, default_value, minimum, maximum, step); }; - inline web::json::value make_nc_property_constraints_number(const nc_property_id& property_id, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_property_constraints_number(property_id, minimum, maximum, step); }; + inline web::json::value make_nc_property_constraints_number(const nc_property_id& property_id, uint64_t default_value, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_property_constraints_number(property_id, default_value, minimum, maximum, step); } + inline web::json::value make_nc_property_constraints_number(const nc_property_id& property_id, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_property_constraints_number(property_id, minimum, maximum, step); } // Deprecated: use nc::details::make_property_constraints_string - inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, const utility::string_t& default_value, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, default_value, max_characters, pattern); }; - inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, max_characters, pattern); }; - inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, uint32_t max_characters) { return nc::details::make_property_constraints_string(property_id, max_characters); }; - inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, pattern); }; + inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, const utility::string_t& default_value, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, default_value, max_characters, pattern); } + inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, max_characters, pattern); } + inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, uint32_t max_characters) { return nc::details::make_property_constraints_string(property_id, max_characters); } + inline web::json::value make_nc_property_constraints_string(const nc_property_id& property_id, const nc_regex& pattern) { return nc::details::make_property_constraints_string(property_id, pattern); } // Deprecated: use nc::details::make_parameter_constraints - inline web::json::value make_nc_parameter_constraints(const web::json::value& default_value) { return nc::details::make_parameter_constraints(default_value); }; + inline web::json::value make_nc_parameter_constraints(const web::json::value& default_value) { return nc::details::make_parameter_constraints(default_value); } // Deprecated: use nc::details::make_parameter_constraints_number - inline web::json::value make_nc_parameter_constraints_number(uint64_t default_value, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_parameter_constraints_number(default_value, minimum, maximum, step); }; - inline web::json::value make_nc_parameter_constraints_number(uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_parameter_constraints_number(minimum, maximum, step); }; + inline web::json::value make_nc_parameter_constraints_number(uint64_t default_value, uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_parameter_constraints_number(default_value, minimum, maximum, step); } + inline web::json::value make_nc_parameter_constraints_number(uint64_t minimum, uint64_t maximum, uint64_t step) { return nc::details::make_parameter_constraints_number(minimum, maximum, step); } // Deprecated: use nc::details::make_parameter_constraints_string - inline web::json::value make_nc_parameter_constraints_string(const utility::string_t& default_value, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(default_value, max_characters, pattern); }; - inline web::json::value make_nc_parameter_constraints_string(uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(max_characters, pattern); }; - inline web::json::value make_nc_parameter_constraints_string(uint32_t max_characters) { return nc::details::make_parameter_constraints_string(max_characters); }; - inline web::json::value make_nc_parameter_constraints_string(const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(pattern); }; + inline web::json::value make_nc_parameter_constraints_string(const utility::string_t& default_value, uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(default_value, max_characters, pattern); } + inline web::json::value make_nc_parameter_constraints_string(uint32_t max_characters, const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(max_characters, pattern); } + inline web::json::value make_nc_parameter_constraints_string(uint32_t max_characters) { return nc::details::make_parameter_constraints_string(max_characters); } + inline web::json::value make_nc_parameter_constraints_string(const nc_regex& pattern) { return nc::details::make_parameter_constraints_string(pattern); } // Deprecated: use nc::details::make_touchpoint - inline web::json::value make_nc_touchpoint(const utility::string_t& context_namespace) { return nc::details::make_touchpoint(context_namespace); }; + inline web::json::value make_nc_touchpoint(const utility::string_t& context_namespace) { return nc::details::make_touchpoint(context_namespace); } // Deprecated: use nc::details::make_touchpoint_nmos - inline web::json::value make_nc_touchpoint_nmos(const nc_touchpoint_resource_nmos& resource) { return nc::details::make_touchpoint_nmos(resource); }; + inline web::json::value make_nc_touchpoint_nmos(const nc_touchpoint_resource_nmos& resource) { return nc::details::make_touchpoint_nmos(resource); } // Deprecated: use nc::details::make_touchpoint_nmos_channel_mapping - inline web::json::value make_nc_touchpoint_nmos_channel_mapping(const nc_touchpoint_resource_nmos_channel_mapping& resource) { return nc::details::make_touchpoint_nmos_channel_mapping(resource); }; + inline web::json::value make_nc_touchpoint_nmos_channel_mapping(const nc_touchpoint_resource_nmos_channel_mapping& resource) { return nc::details::make_touchpoint_nmos_channel_mapping(resource); } // Deprecated: use nc::details::make_object - inline web::json::value make_nc_object(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints) { return nc::details::make_object(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints); }; + inline web::json::value make_nc_object(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints) { return nc::details::make_object(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints); } // Deprecated: use nc::details::make_block - inline web::json::value make_nc_block(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members) { return nc::details::make_block(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, members); }; + inline web::json::value make_nc_block(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members) { return nc::details::make_block(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, members); } // Deprecated: use nc::details::make_worker - inline web::json::value make_nc_worker(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled) { return nc::details::make_worker(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled); }; + inline web::json::value make_nc_worker(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled) { return nc::details::make_worker(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled); } // Deprecated: use nc::details::make_manager - inline web::json::value make_nc_manager(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints) { return nc::details::make_manager(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints); }; + inline web::json::value make_nc_manager(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints) { return nc::details::make_manager(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints); } // Deprecated: use nc::details::make_device_manager inline web::json::value make_nc_device_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, const web::json::value& manufacturer, const web::json::value& product, const utility::string_t& serial_number, - const web::json::value& user_inventory_code, const web::json::value& device_name, const web::json::value& device_role, const web::json::value& operational_state, nc_reset_cause::cause reset_cause) { return nc::details::make_device_manager(oid, owner, user_label, description, touchpoints, runtime_property_constraints, manufacturer, product, serial_number, user_inventory_code, device_name, device_role, operational_state, reset_cause); }; + const web::json::value& user_inventory_code, const web::json::value& device_name, const web::json::value& device_role, const web::json::value& operational_state, nc_reset_cause::cause reset_cause) { return nc::details::make_device_manager(oid, owner, user_label, description, touchpoints, runtime_property_constraints, manufacturer, product, serial_number, user_inventory_code, device_name, device_role, operational_state, reset_cause); } // Deprecated: use nc::details::make_class_manager - inline web::json::value make_nc_class_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, const nmos::experimental::control_protocol_state& control_protocol_state) { return nc::details::make_class_manager(oid, owner, user_label, description, touchpoints, runtime_property_constraints, control_protocol_state); }; + inline web::json::value make_nc_class_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, const nmos::experimental::control_protocol_state& control_protocol_state) { return nc::details::make_class_manager(oid, owner, user_label, description, touchpoints, runtime_property_constraints, control_protocol_state); } } // Deprecated: use nc::make_response - inline web::json::value make_control_protocol_response(int32_t handle, const web::json::value& method_result) { return nc::make_response(handle, method_result); }; + inline web::json::value make_control_protocol_response(int32_t handle, const web::json::value& method_result) { return nc::make_response(handle, method_result); } // Deprecated: use nc::make_command_response - inline web::json::value make_control_protocol_command_response(const web::json::value& responses) { return nc::make_command_response(responses); }; + inline web::json::value make_control_protocol_command_response(const web::json::value& responses) { return nc::make_command_response(responses); } // Deprecated: use nc::make_subscription_response - inline web::json::value make_control_protocol_subscription_response(const web::json::value& subscriptions) { return nc::make_subscription_response(subscriptions); }; + inline web::json::value make_control_protocol_subscription_response(const web::json::value& subscriptions) { return nc::make_subscription_response(subscriptions); } // Deprecated: use nc::make_notification - inline web::json::value make_control_protocol_notification(nc_oid oid, const nc_event_id& event_id, const nc_property_changed_event_data& property_changed_event_data) { return nc::make_notification(oid, event_id, property_changed_event_data); }; + inline web::json::value make_control_protocol_notification(nc_oid oid, const nc_event_id& event_id, const nc_property_changed_event_data& property_changed_event_data) { return nc::make_notification(oid, event_id, property_changed_event_data); } // Deprecated: use nc::make_notification_message - inline web::json::value make_control_protocol_notification_message(const web::json::value& notifications) { return nc::make_notification_message(notifications); }; + inline web::json::value make_control_protocol_notification_message(const web::json::value& notifications) { return nc::make_notification_message(notifications); } // Deprecated: use nc::make_property_changed_event - inline web::json::value make_property_changed_event(nc_oid oid, const std::vector& property_changed_event_data_list) { return nc::make_property_changed_event(oid, property_changed_event_data_list); }; + inline web::json::value make_property_changed_event(nc_oid oid, const std::vector& property_changed_event_data_list) { return nc::make_property_changed_event(oid, property_changed_event_data_list); } // Deprecated: use nc::make_error_message - inline web::json::value make_control_protocol_error_message(const nc_method_result& method_result, const utility::string_t& error_message) { return nc::make_error_message(method_result, error_message); }; + inline web::json::value make_control_protocol_error_message(const nc_method_result& method_result, const utility::string_t& error_message) { return nc::make_error_message(method_result, error_message); } // Deprecated: use nc::make_object_class - inline web::json::value make_nc_object_class() { return nc::make_object_class(); }; + inline web::json::value make_nc_object_class() { return nc::make_object_class(); } // Deprecated: use nc::make_block_class - inline web::json::value make_nc_block_class() { return nc::make_block_class(); }; + inline web::json::value make_nc_block_class() { return nc::make_block_class(); } // Deprecated: use nc::make_worker_class - inline web::json::value make_nc_worker_class() { return nc::make_worker_class(); }; + inline web::json::value make_nc_worker_class() { return nc::make_worker_class(); } // Deprecated: use nc::make_manager_class - inline web::json::value make_nc_manager_class() { return nc::make_manager_class(); }; + inline web::json::value make_nc_manager_class() { return nc::make_manager_class(); } // Deprecated: use nc::make_device_manager_class - inline web::json::value make_nc_device_manager_class() { return nc::make_device_manager_class(); }; + inline web::json::value make_nc_device_manager_class() { return nc::make_device_manager_class(); } // Deprecated: use nc::make_class_manager_class - inline web::json::value make_nc_class_manager_class() { return nc::make_class_manager_class(); }; + inline web::json::value make_nc_class_manager_class() { return nc::make_class_manager_class(); } // Deprecated: use nc::make_ident_beacon_class - inline web::json::value make_nc_ident_beacon_class() { return nc::make_ident_beacon_class(); }; + inline web::json::value make_nc_ident_beacon_class() { return nc::make_ident_beacon_class(); } // Deprecated: use nc::make_receiver_monitor_class - inline web::json::value make_nc_receiver_monitor_class() { return nc::make_receiver_monitor_class(); }; + inline web::json::value make_nc_receiver_monitor_class() { return nc::make_receiver_monitor_class(); } // Deprecated: use nc::make_sender_monitor_class - inline web::json::value make_nc_sender_monitor_class() { return nc::make_sender_monitor_class(); }; + inline web::json::value make_nc_sender_monitor_class() { return nc::make_sender_monitor_class(); } } #endif diff --git a/Development/nmos/control_protocol_utils.cpp b/Development/nmos/control_protocol_utils.cpp index a9fd83d24..3cd640a08 100644 --- a/Development/nmos/control_protocol_utils.cpp +++ b/Development/nmos/control_protocol_utils.cpp @@ -502,7 +502,7 @@ namespace nmos // only update pending received time if not already set if (pending_received_time.as_integer() == 0) { - if (!set_property(resources, oid, status_pending_received_time_field_name, now_time, gate)) + if (!set_property(resources, oid, status_pending_received_time_field_name, static_cast(now_time), gate)) { return false; } @@ -797,7 +797,7 @@ namespace nmos { const auto& class_id = nc::details::parse_class_id(nmos::fields::nc::class_id(descriptor)); - if (include_derived) { return !boost::find_first(class_id, class_id_).empty(); } + if (include_derived) { return class_id_.size() <= class_id.size() && std::equal(class_id_.begin(), class_id_.end(), class_id.begin()); } else { return class_id == class_id_; } }; diff --git a/Development/nmos/control_protocol_utils.h b/Development/nmos/control_protocol_utils.h index 7e11c4f2d..ea9c3de6b 100644 --- a/Development/nmos/control_protocol_utils.h +++ b/Development/nmos/control_protocol_utils.h @@ -195,13 +195,13 @@ namespace nmos namespace details { // Deprecated: use nc::details::get_runtime_property_constraints - inline web::json::value get_runtime_property_constraints(const nc_property_id& property_id, const web::json::value& runtime_property_constraints_list) { return nc::details::get_runtime_property_constraints(property_id, runtime_property_constraints_list); }; + inline web::json::value get_runtime_property_constraints(const nc_property_id& property_id, const web::json::value& runtime_property_constraints_list) { return nc::details::get_runtime_property_constraints(property_id, runtime_property_constraints_list); } // Deprecated: use nc::details::get_datatype_descriptor - inline web::json::value get_datatype_descriptor(const web::json::value& type_name, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype) { return nc::details::get_datatype_descriptor(type_name, get_control_protocol_datatype); }; + inline web::json::value get_datatype_descriptor(const web::json::value& type_name, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype) { return nc::details::get_datatype_descriptor(type_name, get_control_protocol_datatype); } // Deprecated: use nc::details::get_datatype_constraints - inline web::json::value get_datatype_constraints(const web::json::value& type_name, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype) { return nc::details::get_datatype_constraints(type_name, get_control_protocol_datatype); }; + inline web::json::value get_datatype_constraints(const web::json::value& type_name, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype) { return nc::details::get_datatype_constraints(type_name, get_control_protocol_datatype); } struct datatype_constraints_validation_parameters { @@ -209,66 +209,66 @@ namespace nmos get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor; }; // Deprecated: use nc::details::constraints_validation - inline void constraints_validation(const web::json::value& value, const web::json::value& runtime_property_constraints, const web::json::value& property_constraints, const datatype_constraints_validation_parameters& params) { return nc::details::constraints_validation(value, runtime_property_constraints, property_constraints, nc::details::datatype_constraints_validation_parameters{params.datatype_descriptor, params.get_control_protocol_datatype_descriptor}); }; + inline void constraints_validation(const web::json::value& value, const web::json::value& runtime_property_constraints, const web::json::value& property_constraints, const datatype_constraints_validation_parameters& params) { return nc::details::constraints_validation(value, runtime_property_constraints, property_constraints, nc::details::datatype_constraints_validation_parameters{params.datatype_descriptor, params.get_control_protocol_datatype_descriptor}); } // Deprecated: use nc::details::method_parameter_constraints_validation - inline void method_parameter_constraints_validation(const web::json::value& data, const web::json::value& property_constraints, const datatype_constraints_validation_parameters& params) { return nc::details::method_parameter_constraints_validation(data, property_constraints, nc::details::datatype_constraints_validation_parameters{params.datatype_descriptor, params.get_control_protocol_datatype_descriptor}); }; + inline void method_parameter_constraints_validation(const web::json::value& data, const web::json::value& property_constraints, const datatype_constraints_validation_parameters& params) { return nc::details::method_parameter_constraints_validation(data, property_constraints, nc::details::datatype_constraints_validation_parameters{params.datatype_descriptor, params.get_control_protocol_datatype_descriptor}); } } // Deprecated: use nc::is_block - inline bool is_nc_block(const nc_class_id& class_id) { return nc::is_block(class_id); }; + inline bool is_nc_block(const nc_class_id& class_id) { return nc::is_block(class_id); } // Deprecated: use nc::is_worker - inline bool is_nc_worker(const nc_class_id& class_id) { return nc::is_worker(class_id); }; + inline bool is_nc_worker(const nc_class_id& class_id) { return nc::is_worker(class_id); } // Deprecated: use nc::is_manager - inline bool is_nc_manager(const nc_class_id& class_id) { return nc::is_manager(class_id); }; + inline bool is_nc_manager(const nc_class_id& class_id) { return nc::is_manager(class_id); } // Deprecated: use nc::is_device_manager - inline bool is_nc_device_manager(const nc_class_id& class_id) { return nc::is_device_manager(class_id); }; + inline bool is_nc_device_manager(const nc_class_id& class_id) { return nc::is_device_manager(class_id); } // Deprecated: use nc::is_class_manager - inline bool is_nc_class_manager(const nc_class_id& class_id) { return nc::is_class_manager(class_id); }; + inline bool is_nc_class_manager(const nc_class_id& class_id) { return nc::is_class_manager(class_id); } // Deprecated: use nc::make_class_id - inline nc_class_id make_nc_class_id(const nc_class_id& prefix, int32_t authority_key, const std::vector& suffix) { return nc::make_class_id(prefix, authority_key, suffix); }; - inline nc_class_id make_nc_class_id(const nc_class_id& prefix, const std::vector& suffix) { return nc::make_class_id(prefix, suffix); }; + inline nc_class_id make_nc_class_id(const nc_class_id& prefix, int32_t authority_key, const std::vector& suffix) { return nc::make_class_id(prefix, authority_key, suffix); } + inline nc_class_id make_nc_class_id(const nc_class_id& prefix, const std::vector& suffix) { return nc::make_class_id(prefix, suffix); } // Deprecated: use nc::find_property_descriptor - inline web::json::value find_property_descriptor(const nc_property_id& property_id, const nc_class_id& class_id, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor) { return nc::find_property_descriptor(property_id, class_id, get_control_protocol_class_descriptor); }; + inline web::json::value find_property_descriptor(const nc_property_id& property_id, const nc_class_id& class_id, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor) { return nc::find_property_descriptor(property_id, class_id, get_control_protocol_class_descriptor); } // Deprecated: use nc::get_member_descriptors - inline void get_member_descriptors(const resources& resources, const resource& resource, bool recurse, web::json::array& descriptors) { return nc::get_member_descriptors(resources, resource, recurse, descriptors); }; + inline void get_member_descriptors(const resources& resources, const resource& resource, bool recurse, web::json::array& descriptors) { return nc::get_member_descriptors(resources, resource, recurse, descriptors); } // Deprecated: use nc::find_members_by_role - inline void find_members_by_role(const resources& resources, const resource& resource, const utility::string_t& role, bool match_whole_string, bool case_sensitive, bool recurse, web::json::array& nc_block_member_descriptors) { return nc::find_members_by_role(resources, resource, role, match_whole_string, case_sensitive, recurse, nc_block_member_descriptors); }; + inline void find_members_by_role(const resources& resources, const resource& resource, const utility::string_t& role, bool match_whole_string, bool case_sensitive, bool recurse, web::json::array& nc_block_member_descriptors) { return nc::find_members_by_role(resources, resource, role, match_whole_string, case_sensitive, recurse, nc_block_member_descriptors); } // Deprecated: use nc::find_members_by_class_id - inline void find_members_by_class_id(const resources& resources, const resource& resource, const nc_class_id& class_id, bool include_derived, bool recurse, web::json::array& descriptors) { return nc::find_members_by_class_id(resources, resource, class_id, include_derived, recurse, descriptors); }; + inline void find_members_by_class_id(const resources& resources, const resource& resource, const nc_class_id& class_id, bool include_derived, bool recurse, web::json::array& descriptors) { return nc::find_members_by_class_id(resources, resource, class_id, include_derived, recurse, descriptors); } // Deprecated: use nc::push_back - inline void push_back(control_protocol_resource& nc_block_resource, const control_protocol_resource& resource) { return nc::push_back(nc_block_resource, resource); }; + inline void push_back(control_protocol_resource& nc_block_resource, const control_protocol_resource& resource) { return nc::push_back(nc_block_resource, resource); } // Deprecated: use nc::insert_resource - inline std::pair insert_control_protocol_resource(resources& resources, resource&& resource) { return nc::insert_resource(resources, std::move(resource)); }; + inline std::pair insert_control_protocol_resource(resources& resources, resource&& resource) { return nc::insert_resource(resources, std::move(resource)); } // Deprecated: use nc::modify_resource - inline bool modify_control_protocol_resource(resources& resources, const id& id, std::function modifier, const web::json::value& notification_event = web::json::value::null()) { return nc::modify_resource(resources, id, modifier, notification_event); }; + inline bool modify_control_protocol_resource(resources& resources, const id& id, std::function modifier, const web::json::value& notification_event = web::json::value::null()) { return nc::modify_resource(resources, id, modifier, notification_event); } // Deprecated: use nc::erase_resource - inline resources::size_type erase_control_protocol_resource(resources& resources, const id& id) { return nc::erase_resource(resources, id); }; + inline resources::size_type erase_control_protocol_resource(resources& resources, const id& id) { return nc::erase_resource(resources, id); } // Deprecated: use nc::find_resource - inline resources::const_iterator find_control_protocol_resource(resources& resources, type type, const id& id) { return nc::find_resource(resources, type, id); }; + inline resources::const_iterator find_control_protocol_resource(resources& resources, type type, const id& id) { return nc::find_resource(resources, type, id); } // Deprecated: use nc::method_parameters_contraints_validation - inline void method_parameters_contraints_validation(const web::json::value& arguments, const web::json::value& nc_method_descriptor, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor) { return nc::method_parameters_contraints_validation(arguments, nc_method_descriptor, get_control_protocol_datatype_descriptor); }; + inline void method_parameters_contraints_validation(const web::json::value& arguments, const web::json::value& nc_method_descriptor, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor) { return nc::method_parameters_contraints_validation(arguments, nc_method_descriptor, get_control_protocol_datatype_descriptor); } // Deprecated: use nc::insert_notification_events - inline void insert_notification_events(resources& resources, const api_version& version, const api_version& downgrade_version, const type& type, const web::json::value& pre, const web::json::value& post, const web::json::value& event) { return nc::insert_notification_events(resources, version, downgrade_version, type, pre, post, event); }; + inline void insert_notification_events(resources& resources, const api_version& version, const api_version& downgrade_version, const type& type, const web::json::value& pre, const web::json::value& post, const web::json::value& event) { return nc::insert_notification_events(resources, version, downgrade_version, type, pre, post, event); } // Deprecated: use nc::get_property - inline web::json::value get_control_protocol_property(const resources& resources, nc_oid oid, const nc_property_id& property_id, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate) { return nc::get_property(resources, oid, property_id, get_control_protocol_class_descriptor, gate); }; + inline web::json::value get_control_protocol_property(const resources& resources, nc_oid oid, const nc_property_id& property_id, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate) { return nc::get_property(resources, oid, property_id, get_control_protocol_class_descriptor, gate); } } -#endif \ No newline at end of file +#endif diff --git a/Development/nmos/node_resources.cpp b/Development/nmos/node_resources.cpp index a97bffc82..6e8a1cba1 100644 --- a/Development/nmos/node_resources.cpp +++ b/Development/nmos/node_resources.cpp @@ -159,7 +159,7 @@ namespace nmos { auto configuration_uri = web::uri_builder() .set_scheme(nmos::http_scheme(settings)) - .set_port(nmos::fields::connection_port(settings)) + .set_port(nmos::fields::configuration_port(settings)) .set_path(U("/x-nmos/configuration/") + make_api_version(version)); auto type = U("urn:x-nmos:control:configuration/") + make_api_version(version); diff --git a/Development/nmos/test/control_protocol_utils_test.cpp b/Development/nmos/test/control_protocol_utils_test.cpp index ffdf7694b..ce547477d 100644 --- a/Development/nmos/test/control_protocol_utils_test.cpp +++ b/Development/nmos/test/control_protocol_utils_test.cpp @@ -6,11 +6,11 @@ #include "nmos/control_protocol_state.h" #include "nmos/control_protocol_typedefs.h" #include "nmos/control_protocol_utils.h" +#include "nmos/is04_versions.h" +#include "nmos/is12_versions.h" #include "nmos/log_gate.h" #include "nmos/slog.h" -#include "nmos/is04_versions.h" - #include "bst/test/test.h" //////////////////////////////////////////////////////////////////////////////////////////// @@ -1177,3 +1177,80 @@ BST_TEST_CASE(testFindTouchpointResources) BST_CHECK_EQUAL(touchpoint, resources.end()); } } + +//////////////////////////////////////////////////////////////////////////////////////////// +BST_TEST_CASE(testFindMembersByClassId) +{ + using web::json::value_of; + using web::json::value; + + auto make_example_block_resource = [](const nmos::nc_class_id& class_id, nmos::nc_oid oid, nmos::nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description) + { + auto data = nmos::nc::details::make_block(class_id, oid, true, owner, role, value::string(user_label), description, value::null(), value::null(), true, value::array()); + + return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_worker, std::move(data), true }; + }; + + auto make_example_worker_resource = [](const nmos::nc_class_id& class_id, nmos::nc_oid oid, nmos::nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description) + { + auto data = nmos::nc::details::make_worker(class_id, oid, true, owner, role, value::string(user_label), description, value::null(), value::null(), true); + + return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_worker, std::move(data), true }; + }; + + nmos::nc_oid oid = nmos::root_block_oid; + + auto root_block = nmos::make_root_block(); + + // { 1, 1, 0, 1 } + const auto example_class_id_1 = nmos::nc::make_class_id(nmos::nc_block_class_id, 0, { 1 }); + // { 1, 2, 0, 1, 1 } + const auto example_class_id_2 = nmos::nc::make_class_id(nmos::nc_worker_class_id, 0, { 1, 1 }); + + auto example_1 = make_example_block_resource(example_class_id_1, ++oid, nmos::root_block_oid, U("example block 1"), U("Example Block 1"), U("Example Block 1")); + auto example_2 = make_example_worker_resource(example_class_id_2, ++oid, nmos::root_block_oid, U("example block 2"), U("Example Block 2"), U("Example Block 2")); + + nmos::nc::push_back(root_block, example_1); + nmos::nc::push_back(root_block, example_2); + + nmos::resources resources; + + // insert root block and all sub control protocol resources to resource list + nmos::nc::insert_root(resources, root_block); + + // get root block + const auto found_root_block = nmos::find_resource_if(resources, nmos::types::nc_block, [&](const nmos::resource& resource) + { + return nmos::root_block_oid == nmos::fields::nc::oid(resource.data); + }); + + // search unknown class_id members + { + auto members = value::array(); + nmos::nc::find_members_by_class_id(resources, *found_root_block, { 1, 0 }, true, true, members.as_array()); + BST_REQUIRE_EQUAL(0, members.size()); + } + + // search all NcObject members + { + auto members = value::array(); + nmos::nc::find_members_by_class_id(resources, *found_root_block, nmos::nc_object_class_id, true, true, members.as_array()); + BST_REQUIRE_EQUAL(2, members.size()); + } + + // search all NcBlock members + { + auto members = value::array(); + nmos::nc::find_members_by_class_id(resources, *found_root_block, nmos::nc_block_class_id, true, true, members.as_array()); + BST_REQUIRE_EQUAL(1, members.size()); + BST_REQUIRE_EQUAL(example_class_id_1, nmos::nc::details::parse_class_id(nmos::fields::nc::class_id(members.at(0)))); + } + + // search NcWorker members + { + auto members = value::array(); + nmos::nc::find_members_by_class_id(resources, *found_root_block, nmos::nc_worker_class_id, true, true, members.as_array()); + BST_REQUIRE_EQUAL(1, members.size()); + BST_REQUIRE_EQUAL(example_class_id_2, nmos::nc::details::parse_class_id(nmos::fields::nc::class_id(members.at(0)))); + } +}