rclnodejs
Version:
ROS2.0 JavaScript client with Node.js
45 lines (36 loc) • 1.31 kB
JavaScript
// Copyright (c) 2025, The Robot Web Tools Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function generateService(data) {
const serviceInfo = data.serviceInfo;
const className = `${serviceInfo.pkgName}__${serviceInfo.subFolder}__${serviceInfo.interfaceName}`;
return `// This file is automatically generated by rclnodejs
//
// *** DO NOT EDIT directly
//
'use strict';
class ${className} {
static get Request() {
return require('./${className}_Request.js');
}
static get Response() {
return require('./${className}_Response.js');
}
static type() {
return {pkgName: '${serviceInfo.pkgName}', subFolder: '${serviceInfo.subFolder}', interfaceName: '${serviceInfo.interfaceName}'};
}
}
module.exports = ${className};
`;
}
module.exports = generateService;