001/*
002 * This file is part of OCaml-Java runtime.
003 * Copyright (C) 2007-2013 Xavier Clerc.
004 *
005 * OCaml-Java runtime is free software; you can redistribute it and/or modify
006 * it under the terms of the GNU Lesser General Public License as published by
007 * the Free Software Foundation; either version 3 of the License, or
008 * (at your option) any later version.
009 *
010 * OCaml-Java runtime is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.ocamljava.runtime.wrappers;
020
021import org.ocamljava.runtime.values.Value;
022
023/**
024 * The {@code Wrapper} interface defines the contract for a class
025 * allowing to wrap a {@link org.ocamljava.runtime.values.Value}
026 * (internal type of OCaml values) into a
027 * {@link org.ocamljava.runtime.wrappers} (allowing easy access and
028 * manipulation from Java code).
029 *
030 * @see org.ocamljava.runtime.values.Value
031 * @see org.ocamljava.runtime.wrappers.OCamlValue
032 *
033 * @author <a href="mailto:xclerc@ocamljava.org">Xavier Clerc</a>
034 * @version 2.0
035 * @since 2.0
036 */
037public interface Wrapper<T extends OCamlValue> {
038
039    /**
040     * Wraps an internal value into an OCamlValue.
041     * @param v value to wrap - should not be {@code null}
042     * @return an instance allowing easy access to {@code v}
043     */
044    T wrap(final Value v);
045
046    /**
047     * Returns the wrapper used to wrap {@code Value} elements into
048     * instances of the embedded type at given index.
049     * @param idx index of embedded type
050     * @return the wrapper used to wrap {@code Value} elements into
051     *         instances of the embedded type at given index
052     */
053    Wrapper<? extends OCamlValue> getWrapper(final int idx);
054
055} // end interface 'Wrapper'