ardupilot/mk/PX4/Tools/gencpp/scripts/srv.h.template

175 lines
5.0 KiB
Plaintext
Raw Normal View History

@###############################################
@#
@# ROS message source code generation for C++
@#
@# EmPy template for generating <msg>.h files
@#
@###############################################
@# Start of Template
@#
@# Context:
@# - file_name_in (String) Source .srv file
@# - spec (msggen.SrvSpec) Parsed specification of the .srv file
@# - md5sum (String) MD5Sum of the .srv specification
@###############################################
/* Software License Agreement (BSD License)
*
* Copyright (c) 2011, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Auto-generated by gensrv_cpp from file @file_name_in
*
*/
@{
cpp_namespace = '::'+spec.package+'::' # TODO handle nested namespace
cpp_class = spec.short_name
cpp_full_name = cpp_namespace+cpp_class
}@
#ifndef @(spec.package.upper())_MESSAGE_@(spec.short_name.upper())_H
#define @(spec.package.upper())_MESSAGE_@(spec.short_name.upper())_H
#include <ros/service_traits.h>
@###############################################
@# Generate Request and Response Messages
@###############################################
#include <@(spec.package)/@(spec.short_name)Request.h>
#include <@(spec.package)/@(spec.short_name)Response.h>
@###############################################
@# Service Struct
@###############################################
namespace @(spec.package)
{
struct @(spec.short_name)
{
typedef @(spec.request.short_name) Request;
typedef @(spec.response.short_name) Response;
Request request;
Response response;
typedef Request RequestType;
typedef Response ResponseType;
}; // struct @(spec.short_name)
} // namespace @(spec.package)
@###############################################
@# Service-Traits
@###############################################
namespace ros
{
namespace service_traits
{
@[for trait_class,trait_value in [['MD5Sum', md5sum], ['DataType', spec.full_name]] ]
template<>
struct @trait_class< @cpp_full_name > {
static const char* value()
{
return "@(trait_value)";
}
static const char* value(const @(cpp_full_name)&) { return value(); }
};
@[end for]
// service_traits::MD5Sum< @(cpp_full_name)Request> should match
// service_traits::MD5Sum< @cpp_full_name >
template<>
struct MD5Sum< @(cpp_full_name)Request>
{
static const char* value()
{
return MD5Sum< @cpp_full_name >::value();
}
static const char* value(const @(cpp_full_name)Request&)
{
return value();
}
};
// service_traits::DataType< @(cpp_full_name)Request> should match
// service_traits::DataType< @cpp_full_name >
template<>
struct DataType< @(cpp_full_name)Request>
{
static const char* value()
{
return DataType< @cpp_full_name >::value();
}
static const char* value(const @(cpp_full_name)Request&)
{
return value();
}
};
// service_traits::MD5Sum< @(cpp_full_name)Response> should match
// service_traits::MD5Sum< @cpp_full_name >
template<>
struct MD5Sum< @(cpp_full_name)Response>
{
static const char* value()
{
return MD5Sum< @cpp_full_name >::value();
}
static const char* value(const @(cpp_full_name)Response&)
{
return value();
}
};
// service_traits::DataType< @(cpp_full_name)Response> should match
// service_traits::DataType< @cpp_full_name >
template<>
struct DataType< @(cpp_full_name)Response>
{
static const char* value()
{
return DataType< @cpp_full_name >::value();
}
static const char* value(const @(cpp_full_name)Response&)
{
return value();
}
};
} // namespace service_traits
} // namespace ros
#endif // @(spec.package.upper())_MESSAGE_@(spec.short_name.upper())_H