1
1
openmpi/ompi/mpi/java/java/Info.java
Jeff Squyres e4e3e411fc Next generation of MPI Java bindings.
Includes all MPI functions supported by Open MPI, including MPI-3
functions (as of about 2 weeks ago).  Many changes compared to the
prior generation of Java bindings; not much is left from the prior
generation, actually.  The changes include (but are not limited to):

 * Add support for more than just a subset of MPI-1 functions
 * Use typical Java case for symbol names
 * Support Java Direct buffers (giving darn-near "native C"
   performance)
 * Support "type struct" better than the prior generation
 * Make more of an effort for the Java bindings to be a thin layer
   over the back-end C bindings
 * ...and more

A proper README with more information about what is supported, how to
use these bindings, etc. will be committed shortly.

This commit was SVN r29263.
2013-09-26 21:44:39 +00:00

147 строки
2.9 KiB
Java

package mpi;
/**
* This class represents {@code MPI_Info}.
*/
public final class Info implements Freeable
{
protected long handle;
protected static final long NULL = getNull();
/**
* Java binding of the MPI operation {@code MPI_INFO_CREATE}.
*/
public Info() throws MPIException
{
MPI.check();
handle = create();
}
protected Info(long handle)
{
this.handle = handle;
}
private native long create();
protected static Info newEnv()
{
return new Info(getEnv());
}
private native static long getEnv();
private native static long getNull();
/**
* Java binding of the MPI operation {@code MPI_INFO_SET}.
* @param key key
* @param value value
* @throws MPIException
*/
public void set(String key, String value) throws MPIException
{
MPI.check();
set(handle, key, value);
}
private native void set(long handle, String key, String value)
throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_SET}.
* @param key key
* @return value or {@code null} if key is not defined
* @throws MPIException
*/
public String get(String key) throws MPIException
{
MPI.check();
return get(handle, key);
}
private native String get(long handle, String key) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_SET}.
* @param key key
* @throws MPIException
*/
public void delete(String key) throws MPIException
{
MPI.check();
delete(handle, key);
}
private native void delete(long handle, String key) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_GET_NKEYS}.
* @return number of defined keys
* @throws MPIException
*/
public int size() throws MPIException
{
MPI.check();
return size(handle);
}
private native int size(long handle) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_GET_NTHKEY}.
* @param i key number
* @return key
* @throws MPIException
*/
public String getKey(int i) throws MPIException
{
MPI.check();
return getKey(handle, i);
}
private native String getKey(long handle, int i) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_DUP}.
* @return info object
*/
@Override public Info clone()
{
try
{
MPI.check();
return new Info(clone(handle));
}
catch(MPIException e)
{
throw new RuntimeException(e.getMessage());
}
}
private native long clone(long handle) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_INFO_FREE}.
* @throws MPIException
*/
@Override public void free() throws MPIException
{
MPI.check();
handle = free(handle);
}
private native long free(long handle) throws MPIException;
/**
* Tests if the info object is {@code MPI_INFO_NULL} (has been freed).
* @return true if the info object is {@code MPI_INFO_NULL}, false otherwise.
*/
public boolean isNull()
{
return isNull(handle);
}
private native boolean isNull(long handle);
} // Info