001/*****************************************************************************
002 * Copyright by The HDF Group.                                               *
003 * Copyright by the Board of Trustees of the University of Illinois.         *
004 * All rights reserved.                                                      *
005 *                                                                           *
006 * This file is part of the HDF Java Products distribution.                  *
007 * The full copyright notice, including terms governing use, modification,   *
008 * and redistribution, is contained in the files COPYING and Copyright.html. *
009 * COPYING can be found at the root of the source code distribution tree.    *
010 * Or, see https://support.hdfgroup.org/products/licenses.html               *
011 * If you do not have access to either file, you may request a copy from     *
012 * help@hdfgroup.org.                                                        *
013 ****************************************************************************/
014
015package hdf.object;
016
017/**
018 * An interface that provides general operations for data with a Compound
019 * datatype. For example, getting the names, dataspaces or datatypes of the
020 * members of the Compound datatype.
021 *
022 * @see hdf.object.HObject
023 *
024 * @version 1.0 5/3/2018
025 * @author Jordan T. Henderson
026 */
027public interface CompoundDataFormat extends DataFormat
028{
029    /**
030     * Returns the number of members of the compound data object.
031     *
032     * @return the number of members of the compound data object.
033     */
034    int getMemberCount();
035
036    /**
037     * Returns the number of selected members of the compound data object.
038     *
039     * Selected members are the compound fields which are selected for read/write.
040     *
041     * For example, in a compound datatype of {int A, float B, char[] C}, users can
042     * choose to retrieve only {A, C} from the data object. In this case,
043     * getSelectedMemberCount() returns two.
044     *
045     * @return the number of selected members.
046     */
047    int getSelectedMemberCount();
048
049    /**
050     * Returns the names of the members of the compound data object. The names of
051     * compound members are stored in an array of Strings.
052     *
053     * For example, for a compound datatype of {int A, float B, char[] C}
054     * getMemberNames() returns ["A", "B", "C"}.
055     *
056     * @return the names of compound members.
057     */
058    String[] getMemberNames();
059
060    /**
061     * Returns an array of the names of the selected compound members.
062     *
063     * @return an array of the names of the selected compound members.
064     */
065    String[] getSelectedMemberNames();
066
067    /**
068     * Checks if a member of the compound data object is selected for read/write.
069     *
070     * @param idx
071     *            the index of compound member.
072     *
073     * @return true if the i-th memeber is selected; otherwise returns false.
074     */
075    boolean isMemberSelected(int idx);
076
077    /**
078     * Selects the i-th member for read/write.
079     *
080     * @param idx
081     *            the index of compound member.
082     */
083    void selectMember(int idx);
084
085    /**
086     * Selects/deselects all members.
087     *
088     * @param selectAll
089     *            The indicator to select or deselect all members. If true, all
090     *            members are selected for read/write. If false, no member is
091     *            selected for read/write.
092     */
093    void setAllMemberSelection(boolean selectAll);
094
095    /**
096     * Returns array containing the total number of elements of the members of the
097     * compound data object.
098     *
099     * For example, a compound dataset COMP has members of A, B and C as
100     *
101     * <pre>
102     *     COMP {
103     *         int A;
104     *         float B[5];
105     *         double C[2][3];
106     *     }
107     * </pre>
108     *
109     * getMemberOrders() will return an integer array of {1, 5, 6} to indicate that
110     * member A has one element, member B has 5 elements, and member C has 6
111     * elements.
112     *
113     * @return the array containing the total number of elements of the members of
114     *         the compound data object.
115     */
116    int[] getMemberOrders();
117
118    /**
119     * Returns array containing the total number of elements of the selected members
120     * of the compound data object.
121     *
122     * For example, a compound dataset COMP has members of A, B and C as
123     *
124     * <pre>
125     *     COMP {
126     *         int A;
127     *         float B[5];
128     *         double C[2][3];
129     *     }
130     * </pre>
131     *
132     * If A and B are selected, getSelectedMemberOrders() returns an array of {1, 5}
133     *
134     * @return array containing the total number of elements of the selected members
135     *         of the compound data object.
136     */
137    int[] getSelectedMemberOrders();
138
139    /**
140     * Returns the dimension sizes of the i-th member.
141     *
142     * For example, a compound dataset COMP has members of A, B and C as
143     *
144     * <pre>
145     *     COMP {
146     *         int A;
147     *         float B[5];
148     *         double C[2][3];
149     *     }
150     * </pre>
151     *
152     * getMemberDims(2) returns an array of {2, 3}, while getMemberDims(1) returns
153     * an array of {5}, and getMemberDims(0) returns null.
154     *
155     * @param i
156     *            the i-th member
157     *
158     * @return the dimension sizes of the i-th member, null if the compound member
159     *         is not an array.
160     */
161    int[] getMemberDims(int i);
162
163    /**
164     * Returns an array of datatype objects of the compound members.
165     *
166     * Each member of a compound data object has its own datatype. The datatype of a
167     * member can be atomic or other compound datatype (nested compound). The
168     * datatype objects are setup at init().
169     *
170     * @return the array of datatype objects of the compound members.
171     */
172    Datatype[] getMemberTypes();
173
174    /**
175     * Returns an array of datatype objects of the selected compound members.
176     *
177     * @return an array of datatype objects of the selected compound members.
178     */
179    Datatype[] getSelectedMemberTypes();
180
181}