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