Skip to content

Commit

Permalink
Move functions around
Browse files Browse the repository at this point in the history
  • Loading branch information
lo-simon committed Aug 8, 2023
1 parent eb71ebd commit 212bdf4
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 85 deletions.
130 changes: 65 additions & 65 deletions Development/nmos/control_protocol_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace nmos
{ nmos::fields::nc::message_type, type },
{ nmos::fields::nc::responses, responses }
});
};
}

// error message
// See https://specs.amwa.tv/is-12/branches/v1.0-dev/docs/Protocol_messaging.html#error-messages
Expand All @@ -83,7 +83,7 @@ namespace nmos
{ nmos::fields::nc::status, method_result.status},
{ nmos::fields::nc::error_message, error_message }
});
};
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncclassid
web::json::value make_nc_class_id(const nc_class_id& class_id)
Expand Down Expand Up @@ -390,67 +390,6 @@ namespace nmos
return data;
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncobject
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints)
{
using web::json::value;

const auto id = utility::conversions::details::to_string_t(oid);
// auto data = make_resource_core(id, user_label.is_null() ? U("") : user_label.as_string(), {});
value data;
data[nmos::fields::id] = value::string(id); // required for nmos::resource
data[nmos::fields::nc::class_id] = make_nc_class_id(class_id);
data[nmos::fields::nc::oid] = oid;
data[nmos::fields::nc::constant_oid] = value::boolean(constant_oid);
data[nmos::fields::nc::owner] = owner;
data[nmos::fields::nc::role] = value::string(role);
data[nmos::fields::nc::user_label] = user_label;
data[nmos::fields::nc::touchpoints] = touchpoints;
data[nmos::fields::nc::runtime_property_constraints] = runtime_property_constraints;

return data;
};

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncblock
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members)
{
using web::json::value;

auto data = details::make_nc_object(class_id, oid, constant_oid, owner, role, user_label, touchpoints, runtime_property_constraints);
data[nmos::fields::nc::enabled] = value::boolean(enabled);
data[nmos::fields::nc::members] = members;

return data;
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncmanager
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints)
{
return make_nc_object(class_id, oid, constant_oid, owner, role, user_label, touchpoints, runtime_property_constraints);
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncdevicemanager
web::json::value make_nc_device_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, 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)
{
using web::json::value;

auto data = details::make_nc_manager(nc_device_manager_class_id, oid, true, owner, U("DeviceManager"), user_label, touchpoints, runtime_property_constraints);
data[nmos::fields::nc::nc_version] = value::string(U("v1.0"));
data[nmos::fields::nc::manufacturer] = manufacturer;
data[nmos::fields::nc::product] = product;
data[nmos::fields::nc::serial_number] = value::string(serial_number);
data[nmos::fields::nc::user_inventory_code] = user_inventory_code;
data[nmos::fields::nc::device_name] = device_name;
data[nmos::fields::nc::device_role] = device_role;
data[nmos::fields::nc::operational_state] = operational_state;
data[nmos::fields::nc::reset_cause] = reset_cause;
data[nmos::fields::nc::message] = value::null();

return data;
}

web::json::value make_nc_object_properties()
{
using web::json::value;
Expand Down Expand Up @@ -480,8 +419,8 @@ namespace nmos
}
{
auto parameters = value::array();
web::json::push_back(parameters,make_nc_parameter_descriptor(value::string(U("Property id")), nmos::fields::nc::id, value::string(U("NcPropertyId")), false, false, value::null()));
web::json::push_back(parameters,make_nc_parameter_descriptor(value::string(U("Property value")), nmos::fields::nc::value, value::null(), true, false, value::null()));
web::json::push_back(parameters, make_nc_parameter_descriptor(value::string(U("Property id")), nmos::fields::nc::id, value::string(U("NcPropertyId")), false, false, value::null()));
web::json::push_back(parameters, make_nc_parameter_descriptor(value::string(U("Property value")), nmos::fields::nc::value, value::null(), true, false, value::null()));
web::json::push_back(methods, make_nc_method_descriptor(value::string(U("Set property value")), make_nc_method_id(1, 2), U("Set"), U("NcMethodResult"), parameters, false));
}
{
Expand Down Expand Up @@ -697,6 +636,67 @@ namespace nmos
return value::array();
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncobject
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints)
{
using web::json::value;

const auto id = utility::conversions::details::to_string_t(oid);
// auto data = make_resource_core(id, user_label.is_null() ? U("") : user_label.as_string(), {});
value data;
data[nmos::fields::id] = value::string(id); // required for nmos::resource
data[nmos::fields::nc::class_id] = make_nc_class_id(class_id);
data[nmos::fields::nc::oid] = oid;
data[nmos::fields::nc::constant_oid] = value::boolean(constant_oid);
data[nmos::fields::nc::owner] = owner;
data[nmos::fields::nc::role] = value::string(role);
data[nmos::fields::nc::user_label] = user_label;
data[nmos::fields::nc::touchpoints] = touchpoints;
data[nmos::fields::nc::runtime_property_constraints] = runtime_property_constraints;

return data;
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncblock
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members)
{
using web::json::value;

auto data = details::make_nc_object(class_id, oid, constant_oid, owner, role, user_label, touchpoints, runtime_property_constraints);
data[nmos::fields::nc::enabled] = value::boolean(enabled);
data[nmos::fields::nc::members] = members;

return data;
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncmanager
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints)
{
return make_nc_object(class_id, oid, constant_oid, owner, role, user_label, touchpoints, runtime_property_constraints);
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncdevicemanager
web::json::value make_nc_device_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, 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)
{
using web::json::value;

auto data = details::make_nc_manager(nc_device_manager_class_id, oid, true, owner, U("DeviceManager"), user_label, touchpoints, runtime_property_constraints);
data[nmos::fields::nc::nc_version] = value::string(U("v1.0"));
data[nmos::fields::nc::manufacturer] = manufacturer;
data[nmos::fields::nc::product] = product;
data[nmos::fields::nc::serial_number] = value::string(serial_number);
data[nmos::fields::nc::user_inventory_code] = user_inventory_code;
data[nmos::fields::nc::device_name] = device_name;
data[nmos::fields::nc::device_role] = device_role;
data[nmos::fields::nc::operational_state] = operational_state;
data[nmos::fields::nc::reset_cause] = reset_cause;
data[nmos::fields::nc::message] = value::null();

return data;
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncclassmanager
web::json::value make_nc_class_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label)
{
Expand Down
37 changes: 17 additions & 20 deletions Development/nmos/control_protocol_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ namespace nmos

typedef std::map<web::json::value, utility::string_t> properties;

// typedef std::function<web::json::value(const properties& properties, int32_t handle, int32_t oid, const web::json::value& arguments)> method;
// typedef std::map<web::json::value, method> methods; // method_id vs method handler

typedef std::function<web::json::value(const web::json::array& properties, int32_t handle, int32_t oid, const web::json::value& arguments)> method;
typedef std::map<web::json::value, method> methods; // method_id vs method handler

Expand Down Expand Up @@ -267,23 +264,6 @@ namespace nmos
// constraints can be null
web::json::value make_nc_datatype_typedef(const web::json::value& description, const utility::string_t& name, const web::json::value& constraints, const utility::string_t& parent_type, bool is_sequence);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncobject
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncblock
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncmanager
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 web::json::value& touchpoints = web::json::value::null(), const web::json::value& runtime_property_constraints = web::json::value::null());

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncdevicemanager
web::json::value make_nc_device_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, 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);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncclassmanager
web::json::value make_nc_class_manager(details::nc_oid oid, nc_oid owner, const web::json::value& user_label);

// make the core classes proprties/methods/events
web::json::value make_nc_object_properties();
web::json::value make_nc_object_methods();
Expand All @@ -303,6 +283,23 @@ namespace nmos
web::json::value make_nc_class_manager_properties();
web::json::value make_nc_class_manager_methods();
web::json::value make_nc_class_manager_events();

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncobject
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncblock
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 web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, const web::json::value& members);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncmanager
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 web::json::value& touchpoints = web::json::value::null(), const web::json::value& runtime_property_constraints = web::json::value::null());

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncdevicemanager
web::json::value make_nc_device_manager(nc_oid oid, nc_oid owner, const web::json::value& user_label, 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);

// See https://specs.amwa.tv/ms-05-02/branches/v1.0-dev/docs/Framework.html#ncclassmanager
web::json::value make_nc_class_manager(details::nc_oid oid, nc_oid owner, const web::json::value& user_label);
}
}

Expand Down

0 comments on commit 212bdf4

Please sign in to comment.