diff --git a/message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java b/message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java index 4d3b23e2180f7e1e64443e89030faf45731d8dfb..1a53d13e8de0b9522d2d6fb37bccd52526451458 100644 --- a/message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java +++ b/message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java @@ -24,6 +24,9 @@ import org.ros.exception.RosMessageRuntimeException; import org.ros.internal.message.definition.MessageDefinitionProviderChain; import org.ros.internal.message.definition.MessageDefinitionTupleParser; import org.ros.internal.message.action.ActionDefinitionFileProvider; +import org.ros.internal.message.action.ActionGoalGenerationTemplate; +import org.ros.internal.message.action.ActionFeedbackGenerationTemplate; +import org.ros.internal.message.action.ActionResultGenerationTemplate; import org.ros.internal.message.service.ServiceDefinitionFileProvider; import org.ros.internal.message.topic.TopicDefinitionFileProvider; import org.ros.message.MessageDeclaration; @@ -46,6 +49,10 @@ public class GenerateInterfaces { private final ActionDefinitionFileProvider actionDefinitionFileProvider; private final MessageDefinitionProviderChain messageDefinitionProviderChain; private final MessageFactory messageFactory; + private final ActionGoalGenerationTemplate actionGoalGenerationTemplate = new ActionGoalGenerationTemplate(); + private final ActionFeedbackGenerationTemplate actionFeedbackGenerationTemplate = new ActionFeedbackGenerationTemplate(); + private final ActionResultGenerationTemplate actionResultGenerationTemplate = new ActionResultGenerationTemplate(); + static private final String ROS_PACKAGE_PATH = "ROS_PACKAGE_PATH"; public GenerateInterfaces() { @@ -153,12 +160,18 @@ public class GenerateInterfaces { writeInterface(actionDeclaration, outputDirectory, false); List<String> goalResultAndFeedback = MessageDefinitionTupleParser.parse(definition, 3); - MessageDeclaration goalDeclaration = - MessageDeclaration.of(actionType.getType() + "Goal", goalResultAndFeedback.get(0)); - MessageDeclaration resultDeclaration = - MessageDeclaration.of(actionType.getType() + "Result", goalResultAndFeedback.get(1)); - MessageDeclaration feedbackDeclaration = - MessageDeclaration.of(actionType.getType() + "Feedback", goalResultAndFeedback.get(2)); + MessageDeclaration goalDeclaration = MessageDeclaration.of( + actionType.getType() + "Goal", + actionGoalGenerationTemplate.applyTemplate(goalResultAndFeedback.get(0)) + ); + MessageDeclaration resultDeclaration = MessageDeclaration.of( + actionType.getType() + "Result", + actionResultGenerationTemplate.applyTemplate(goalResultAndFeedback.get(1)) + ); + MessageDeclaration feedbackDeclaration = MessageDeclaration.of( + actionType.getType() + "Feedback", + actionFeedbackGenerationTemplate.applyTemplate(goalResultAndFeedback.get(2)) + ); writeInterface(goalDeclaration, outputDirectory, true); writeInterface(resultDeclaration, outputDirectory, true); diff --git a/message_generation/src/main/java/org/ros/internal/message/MessageGenerationTemplate.java b/message_generation/src/main/java/org/ros/internal/message/MessageGenerationTemplate.java new file mode 100644 index 0000000000000000000000000000000000000000..ba1ed921d80edc7f250bf68eaa9d5c8720ca2d81 --- /dev/null +++ b/message_generation/src/main/java/org/ros/internal/message/MessageGenerationTemplate.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2012 Google Inc. + * + * 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. + */ + +package org.ros.internal.message; + +/** + * @author arne.peters@tum.de (Arne Peters) + */ +public interface MessageGenerationTemplate { + + /** + * @return returns this {@link Message} as a {@link RawMessage} + */ + public String applyTemplate(String messageSource); +} diff --git a/message_generation/src/main/java/org/ros/internal/message/action/ActionFeedbackGenerationTemplate.java b/message_generation/src/main/java/org/ros/internal/message/action/ActionFeedbackGenerationTemplate.java new file mode 100644 index 0000000000000000000000000000000000000000..2091eef6bf54d353cb86426dd121aee3a5df1460 --- /dev/null +++ b/message_generation/src/main/java/org/ros/internal/message/action/ActionFeedbackGenerationTemplate.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Google Inc. + * + * 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. + */ + +package org.ros.internal.message.action; + +/** + * @author arne.peters@tum.de (Arne Peters) + */ +public class ActionFeedbackGenerationTemplate { + + /** + * @return returns this {@link Message} as a {@link RawMessage} + */ + public String applyTemplate(String messageSource) { + return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" + + "\n" + + "Header header\n" + + "actionlib_msgs/GoalStatus status\n" + + messageSource; + } +} diff --git a/message_generation/src/main/java/org/ros/internal/message/action/ActionGoalGenerationTemplate.java b/message_generation/src/main/java/org/ros/internal/message/action/ActionGoalGenerationTemplate.java new file mode 100644 index 0000000000000000000000000000000000000000..87e9b3646bf858f80b011226d93a9e2b18a87e06 --- /dev/null +++ b/message_generation/src/main/java/org/ros/internal/message/action/ActionGoalGenerationTemplate.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Google Inc. + * + * 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. + */ + +package org.ros.internal.message.action; + +/** + * @author arne.peters@tum.de (Arne Peters) + */ +public class ActionGoalGenerationTemplate { + + /** + * @return returns this {@link Message} as a {@link RawMessage} + */ + public String applyTemplate(String messageSource) { + return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" + + "\n" + + "Header header\n" + + "actionlib_msgs/GoalID goal_id\n" + + messageSource; + } +} diff --git a/message_generation/src/main/java/org/ros/internal/message/action/ActionResultGenerationTemplate.java b/message_generation/src/main/java/org/ros/internal/message/action/ActionResultGenerationTemplate.java new file mode 100644 index 0000000000000000000000000000000000000000..2db93a733bfa221fce56ac474d50e5c030d9331f --- /dev/null +++ b/message_generation/src/main/java/org/ros/internal/message/action/ActionResultGenerationTemplate.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Google Inc. + * + * 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. + */ + +package org.ros.internal.message.action; + +/** + * @author arne.peters@tum.de (Arne Peters) + */ +public class ActionResultGenerationTemplate { + + /** + * @return returns this {@link Message} as a {@link RawMessage} + */ + public String applyTemplate(String messageSource) { + return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" + + "\n" + + "Header header\n" + + "actionlib_msgs/GoalStatus status\n" + + messageSource; + } +}