Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Preset JAVA_INCLUDE_PATH to user env variable.
[simgrid.git] / org / simgrid / msg / Host.java
index 45af7ff..136f4b2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Bindings to the MSG hosts
  *
- * Copyright 2006,2007,2010 The SimGrid Team           
+ * Copyright 2006-2012 The SimGrid Team           
  * All right reserved. 
  *
  * This program is free software; you can redistribute 
@@ -9,7 +9,7 @@
  *(GNU LGPL) which comes with this package. 
  *
  */  
-package simgrid.msg;
+package org.simgrid.msg;
 
 /**
  * A host object represents a location (any possible place) where a process may run. 
@@ -49,14 +49,20 @@ public class Host {
         *
         * @see                         Host.getByName().
         */ 
-       public long bind;
-
+       private long bind;
+       /**
+        * Host name
+        */
+       private String name;
 
        /**
         * User data.
         */ 
        private Object data;
-       protected Host() {
+    /**
+     *
+     */
+    protected Host() {
                this.bind = 0;
                this.data = null;
        };
@@ -67,34 +73,26 @@ public class Host {
         *
         * @param name          The name of the host to get.
         *
-        * @exception           HostNotFoundException if the name of the host is not valid.
+     * @return
+     * @exception              HostNotFoundException if the name of the host is not valid.
         *                                      NativeException if the native version of this method failed.
         */ 
-       public static Host getByName(String name) 
-       throws HostNotFoundException {
-               if (name==null)
-                       throw new NullPointerException("No host can have a null name");
-               return MsgNative.hostGetByName(name);
-       }
-
+       public native static Host getByName(String name) 
+       throws HostNotFoundException, NullPointerException;
        /**
         * This static method returns the count of the installed hosts.
         *
         * @return                      The count of the installed hosts.
-        *
+        * FIXME: Not implemented.
         */ 
-       public static int getCount() {
-               return MsgNative.hostGetCount();
-       }
+       public native static int getCount();
 
        /**
         * This static method return an instance to the host of the current process.
         *
         * @return                      The host on which the current process is executed.
         */ 
-       public static Host currentHost() {
-               return MsgNative.hostSelf();
-       }
+       public native static Host currentHost();
 
        /**
         * This static method returns all of the hosts of the installed platform.
@@ -102,37 +100,37 @@ public class Host {
         * @return                      An array containing all the hosts installed.
         *
         */ 
-       public static Host[] all()  {
-               return MsgNative.allHosts();
-       }
+       public native static Host[] all();
 
        /**
         * This method returns the name of a host.
-        *
         * @return                      The name of the host.
         *
         */ 
-       public String getName()  {
-               return MsgNative.hostGetName(this);
+       public String getName() {
+               return name;
        }
-
        /**
         * Sets the data of the host.
-        *
-        */ 
+     * @param data
+     */
        public void setData(Object data) {
                this.data = data;
        } 
        /**
-        * Gets the data of the host.
-        */ 
+        * Gets the d   ata of the host.
+     *
+     * @return
+     */
        public Object getData() {
                return this.data;
        }
 
        /**
         * Checks whether a host has data.
-        */ 
+     *
+     * @return
+     */
        public boolean hasData() {
                return null != this.data;
        }
@@ -143,9 +141,7 @@ public class Host {
         *
         * @return                      The number of tasks currently running on a host.
         */ 
-       public int getLoad() {
-               return MsgNative.hostGetLoad(this);
-       }
+       public native int getLoad();
 
        /**
         * This method returns the speed of the processor of a host,
@@ -154,12 +150,25 @@ public class Host {
         * @return                      The speed of the processor of the host in flops.
         *
         */ 
-       public double getSpeed() {
-               return MsgNative.hostGetSpeed(this);
-       }
-
-       /** This method tests if a host is avail. */
-       public boolean isAvail() {
-               return MsgNative.hostIsAvail(this);
-       }
+       public native double getSpeed();
+       /**
+        * @brief Returns the value of a given host property. 
+        */
+       public native String getProperty(String name);
+       /**
+        * @brief Change the value of a given host property. 
+        */
+       public native void setProperty(String name, String value);
+    /** This method tests if a host is avail.
+     * @return
+     */
+       public native boolean isAvail();
+       
+       /**
+        * Class initializer, to initialize various JNI stuff
+        */
+       public static native void nativeInit();
+       static {
+               nativeInit();
+       }       
 }