Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 package ros.roscpp;
00039
00040 import ros.RosException;
00041 import ros.Subscriber;
00042 import ros.communication.Message;
00043
00044 public class CppSubscriber<M extends Message> implements Subscriber<M> {
00045 private String topic;
00046 private long cppCallback;
00047 private long cppSubscriber;
00048
00049 private CppSubscriber() {}
00050
00051 protected static <M extends Message> CppSubscriber<M> create(long cppHandle, String topic, M messageTemplate, Callback<M> callback, int queueSize) throws RosException {
00052 CppSubscriber<M> that = new CppSubscriber<M>();
00053 that.topic = topic;
00054 that.cppCallback = JNI.createSubCallback(callback, messageTemplate);
00055 if (that.cppCallback == 0) throw new RuntimeException("Could not create callback wrapper.");
00056 that.cppSubscriber = JNI.subscribe(cppHandle, topic, that.cppCallback, queueSize);
00057 if (that.cppSubscriber == 0) {
00058 JNI.deleteSubCallback(that.cppCallback);
00059 throw new RosException("Could not subscribe to topic " + topic);
00060 }
00061 return that;
00062 }
00063
00064 public String getTopic() { return topic; }
00065
00066 public boolean isValid() { return (cppSubscriber != 0) && JNI.isSubscriberValid(cppSubscriber); }
00067
00068 public void shutdown() {
00069 if (!isValid()) return;
00070 JNI.shutdownSubscriber(cppSubscriber);
00071 JNI.deleteSubCallback(cppCallback);
00072
00073 cppSubscriber = 0;
00074 }
00075 }
rosjava_jni
Author(s): Maintained by Gheorghe Lisca (lisca@cs.uni-bremen.de) and developed by Jason Wolfe (jawolfe@willowgarage.com), Nicholas Butko (nbutko@cogsci.ucsd.edu), Lorenz Moesenlechner (moesenle@in.tum.de)
autogenerated on Sun Oct 5 2014 22:54:14