Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lo-simon committed Jan 12, 2024
1 parent 31321f7 commit 2fd6bdd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
16 changes: 8 additions & 8 deletions Development/nmos-cpp-node/node_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,27 +1008,27 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
nmos::experimental::make_control_class_property(U("Example object sequence property"), { 3, 14 }, object_sequence, U("ExampleDataType"), false, false, true)
};

auto example_method_with_no_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler, slog::base_gate& gate)
auto example_method_with_no_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "Executing the example method with no arguments";

return nmos::make_control_protocol_message_response(handle, { is_deprecated ? nmos::nc_method_status::method_deprecated : nmos::nc_method_status::ok });
};
auto example_method_with_simple_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler, slog::base_gate& gate)
auto example_method_with_simple_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// and the method parameters constriants has already been validated by the outter function
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...
// and the method parameters constriants has already been validated by the outer function

slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "Executing the example method with simple arguments: " << arguments.serialize();

return nmos::make_control_protocol_message_response(handle, { is_deprecated ? nmos::nc_method_status::method_deprecated : nmos::nc_method_status::ok });
};
auto example_method_with_object_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler, slog::base_gate& gate)
auto example_method_with_object_args = [](nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, nmos::get_control_protocol_class_handler get_control_protocol_class, nmos::get_control_protocol_datatype_handler get_control_protocol_datatype, nmos::control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// and the method parameters constriants has already been validated by the outter function
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...
// and the method parameters constriants has already been validated by the outer function

slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "Executing the example method with object argument: " << arguments.serialize();

Expand Down
28 changes: 14 additions & 14 deletions Development/nmos/control_protocol_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace nmos
// Get property value
web::json::value get(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& property_id = nmos::fields::nc::id(arguments);

Expand All @@ -36,7 +36,7 @@ namespace nmos
// Set property value
web::json::value set(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler get_control_protocol_datatype, control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& property_id = nmos::fields::nc::id(arguments);
const auto& val = nmos::fields::nc::value(arguments);
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace nmos
// Get sequence item
web::json::value get_sequence_item(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& property_id = nmos::fields::nc::id(arguments);
const auto& index = nmos::fields::nc::index(arguments);
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace nmos
// Set sequence item
web::json::value set_sequence_item(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler get_control_protocol_datatype, control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& property_id = nmos::fields::nc::id(arguments);
const auto& index = nmos::fields::nc::index(arguments);
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace nmos
// Add item to sequence
web::json::value add_sequence_item(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler get_control_protocol_datatype, control_protocol_property_changed_handler property_changed, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand Down Expand Up @@ -281,7 +281,7 @@ namespace nmos
// Delete sequence item
web::json::value remove_sequence_item(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& property_id = nmos::fields::nc::id(arguments);
const auto& index = nmos::fields::nc::index(arguments);
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace nmos
// Get sequence length
web::json::value get_sequence_length(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler get_control_protocol_class, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand Down Expand Up @@ -384,7 +384,7 @@ namespace nmos
// Gets descriptors of members of the block
web::json::value get_member_descriptors(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand All @@ -401,7 +401,7 @@ namespace nmos
// Finds member(s) by path
web::json::value find_members_by_path(nmos::resources& resources, const nmos::resource& resource_, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand Down Expand Up @@ -461,7 +461,7 @@ namespace nmos
// Finds members with given role name or fragment
web::json::value find_members_by_role(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand All @@ -487,7 +487,7 @@ namespace nmos
// Finds members with given class id
web::json::value find_members_by_class_id(nmos::resources& resources, const nmos::resource& resource, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler, get_control_protocol_datatype_handler, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

Expand All @@ -503,7 +503,7 @@ namespace nmos
return make_control_protocol_error_response(handle, { nc_method_status::parameter_error }, U("empty classId to do FindMembersByClassId"));
}

// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

auto descriptors = value::array();
nmos::find_members_by_class_id(resources, resource, class_id, include_derived, recurse, descriptors.as_array());
Expand All @@ -528,7 +528,7 @@ namespace nmos
return make_control_protocol_error_response(handle, { nc_method_status::parameter_error }, U("empty classId to do GetControlClass"));
}

// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& control_class = get_control_protocol_class(class_id);
if (!control_class.class_id.empty())
Expand Down Expand Up @@ -570,7 +570,7 @@ namespace nmos
// Get a single datatype descriptor
web::json::value get_datatype(nmos::resources&, const nmos::resource&, int32_t handle, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_handler, get_control_protocol_datatype_handler get_control_protocol_datatype, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outter function, so access to control_protocol_resources is OK...
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& name = nmos::fields::nc::name(arguments); // name of datatype
const auto& include_inherited = nmos::fields::nc::include_inherited(arguments); // If set the descriptor would contain all inherited elements
Expand Down
4 changes: 4 additions & 0 deletions Development/nmos/control_protocol_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ namespace nmos
// push a control protocol resource into other control protocol NcBlock resource
void push_back(control_protocol_resource& nc_block_resource, const control_protocol_resource& resource)
{
// note, model write lock should aleady be applied by the outer function, so access to control_protocol_resources is OK...

using web::json::value;

auto& parent = nc_block_resource.data;
Expand All @@ -566,6 +568,8 @@ namespace nmos
// modify a control protocol resource, and insert notification event to all subscriptions
bool modify_control_protocol_resource(resources& resources, const id& id, std::function<void(resource&)> modifier, const web::json::value& notification_event)
{
// note, model write lock should aleady be applied by the outer function, so access to control_protocol_resources is OK...

auto found = resources.find(id);
if (resources.end() == found || !found->has_data()) return false;

Expand Down

0 comments on commit 2fd6bdd

Please sign in to comment.