00001 /* 00002 * Copyright (C) 2012 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 00005 * use this file except in compliance with the License. You may obtain a copy of 00006 * the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 00013 * License for the specific language governing permissions and limitations under 00014 * the License. 00015 */ 00016 00017 package org.ros.master.client; 00018 00019 import org.ros.internal.node.client.MasterClient; 00020 import org.ros.internal.node.response.Response; 00021 import org.ros.internal.node.server.master.MasterServer; 00022 import org.ros.internal.node.topic.TopicDeclaration; 00023 import org.ros.node.Node; 00024 import org.ros.node.service.ServiceServer; 00025 00026 import java.net.URI; 00027 import java.util.List; 00028 00034 public class MasterStateClient { 00035 00039 private final Node caller; 00040 00044 private final MasterClient masterClient; 00045 00046 public MasterStateClient(Node caller, URI masterUri) { 00047 this.caller = caller; 00048 masterClient = new MasterClient(masterUri); 00049 } 00050 00056 public URI lookupNode(String nodeName) { 00057 Response<URI> response = masterClient.lookupNode(caller.getName(), nodeName); 00058 return response.getResult(); 00059 } 00060 00064 public URI getUri() { 00065 Response<URI> response = masterClient.getUri(caller.getName()); 00066 return response.getResult(); 00067 } 00068 00074 public URI lookupService(String serviceName) { 00075 Response<URI> result = masterClient.lookupService(caller.getName(), serviceName); 00076 return result.getResult(); 00077 } 00078 00084 public List<TopicDeclaration> getPublishedTopics(String subgraph) { 00085 // TODO(keith): Figure out what to turn the topic definition into. 00086 throw new UnsupportedOperationException(); 00087 } 00088 00092 public List<TopicType> getTopicTypes() { 00093 Response<List<TopicType>> result = masterClient.getTopicTypes(caller.getName()); 00094 return result.getResult(); 00095 } 00096 00100 public SystemState getSystemState() { 00101 Response<SystemState> result = masterClient.getSystemState(caller.getName()); 00102 return result.getResult(); 00103 } 00104 }