RosCore.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 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;
00018 
00019 import com.google.common.annotations.VisibleForTesting;
00020 
00021 import org.ros.address.AdvertiseAddress;
00022 import org.ros.address.BindAddress;
00023 import org.ros.internal.node.server.master.MasterServer;
00024 
00025 import java.net.URI;
00026 import java.util.concurrent.TimeUnit;
00027 
00028 // TODO(damonkohler): Add /rosout node.
00039 public class RosCore {
00040 
00041   private final MasterServer masterServer;
00042 
00043   public static RosCore newPublic(String host, int port) {
00044     return new RosCore(BindAddress.newPublic(port), new AdvertiseAddress(host));
00045   }
00046 
00047   public static RosCore newPublic(int port) {
00048     return new RosCore(BindAddress.newPublic(port), AdvertiseAddress.newPublic());
00049   }
00050 
00051   public static RosCore newPublic() {
00052     return new RosCore(BindAddress.newPublic(), AdvertiseAddress.newPublic());
00053   }
00054 
00055   public static RosCore newPrivate(int port) {
00056     return new RosCore(BindAddress.newPrivate(port), AdvertiseAddress.newPrivate());
00057   }
00058 
00059   public static RosCore newPrivate() {
00060     return new RosCore(BindAddress.newPrivate(), AdvertiseAddress.newPrivate());
00061   }
00062 
00063   private RosCore(BindAddress bindAddress, AdvertiseAddress advertiseAddress) {
00064     masterServer = new MasterServer(bindAddress, advertiseAddress);
00065   }
00066 
00067   public void start() {
00068     masterServer.start();
00069   }
00070 
00071   public URI getUri() {
00072     return masterServer.getUri();
00073   }
00074 
00075   public void awaitStart() throws InterruptedException {
00076     masterServer.awaitStart();
00077   }
00078 
00079   public boolean awaitStart(long timeout, TimeUnit unit) throws InterruptedException {
00080     return masterServer.awaitStart(timeout, unit);
00081   }
00082 
00083   public void shutdown() {
00084     masterServer.shutdown();
00085   }
00086 
00087   @VisibleForTesting
00088   public MasterServer getMasterServer() {
00089     return masterServer;
00090   }
00091 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49