001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.0.12 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span> 013 Implementation of the ListOfSubmodels construct from the 014 * “comp” package. 015 <p> 016 * The {@link ListOfSubmodels} is a container for the extended 017 * {@link Model} that contains {@link Submodel} objects to be instantiated in that {@link Model}. 018 <p> 019 * <p> 020 * The various ListOf___ classes in SBML 021 * are merely containers used for organizing the main components of an SBML 022 * model. In libSBML's implementation, ListOf___ 023 * classes are derived from the 024 * intermediate utility class {@link ListOf}, which 025 * is not defined by the SBML specifications but serves as a useful 026 * programmatic construct. {@link ListOf} is itself is in turn derived from {@link SBase}, 027 * which provides all of the various ListOf___ 028 * classes with common features 029 * defined by the SBML specification, such as 'metaid' attributes and 030 * annotations. 031 <p> 032 * The relationship between the lists and the rest of an SBML model is 033 * illustrated by the following (for SBML Level 2 Version 4): 034 <p> 035 * <figure> 036 <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object> 037</figure> 038 039 <p> 040 * Readers may wonder about the motivations for using the ListOf___ 041 * containers in SBML. A simpler approach in XML might be to place the 042 * components all directly at the top level of the model definition. The 043 * choice made in SBML is to group them within XML elements named after 044 * ListOf<em>Classname</em>, in part because it helps organize the 045 * components. More importantly, the fact that the container classes are 046 * derived from {@link SBase} means that software tools can add information <em>about</em> 047 * the lists themselves into each list container's 'annotation'. 048 <p> 049 * @see ListOfFunctionDefinitions 050 * @see ListOfUnitDefinitions 051 * @see ListOfCompartmentTypes 052 * @see ListOfSpeciesTypes 053 * @see ListOfCompartments 054 * @see ListOfSpecies 055 * @see ListOfParameters 056 * @see ListOfInitialAssignments 057 * @see ListOfRules 058 * @see ListOfConstraints 059 * @see ListOfReactions 060 * @see ListOfEvents 061 <p> 062 * @see Submodel 063 * @see ListOfDeletions 064 * @see ListOfExternalModelDefinitions 065 * @see ListOfModelDefinitions 066 * @see ListOfPorts 067 * @see ListOfReplacedElements 068 */ 069 070public class ListOfSubmodels extends ListOf { 071 private long swigCPtr; 072 073 protected ListOfSubmodels(long cPtr, boolean cMemoryOwn) 074 { 075 super(libsbmlJNI.ListOfSubmodels_SWIGUpcast(cPtr), cMemoryOwn); 076 swigCPtr = cPtr; 077 } 078 079 protected static long getCPtr(ListOfSubmodels obj) 080 { 081 return (obj == null) ? 0 : obj.swigCPtr; 082 } 083 084 protected static long getCPtrAndDisown (ListOfSubmodels obj) 085 { 086 long ptr = 0; 087 088 if (obj != null) 089 { 090 ptr = obj.swigCPtr; 091 obj.swigCMemOwn = false; 092 } 093 094 return ptr; 095 } 096 097 protected void finalize() { 098 delete(); 099 } 100 101 public synchronized void delete() { 102 if (swigCPtr != 0) { 103 if (swigCMemOwn) { 104 swigCMemOwn = false; 105 libsbmlJNI.delete_ListOfSubmodels(swigCPtr); 106 } 107 swigCPtr = 0; 108 } 109 super.delete(); 110 } 111 112 113/** 114 * Creates and returns a deep copy of this {@link ListOfSubmodels} object. 115 <p> 116 * @return a (deep) copy of this {@link ListOfSubmodels}. 117 */ public 118 ListOfSubmodels cloneObject() { 119 long cPtr = libsbmlJNI.ListOfSubmodels_cloneObject(swigCPtr, this); 120 return (cPtr == 0) ? null : new ListOfSubmodels(cPtr, true); 121 } 122 123 124/** 125 * Creates a new {@link ListOfSubmodels} with the given level, version, and package 126 * version. 127 <p> 128 * @param level the SBML Level 129 * @param version the Version within the SBML Level 130 * @param pkgVersion the version of the package 131 */ public 132 ListOfSubmodels(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 133 this(libsbmlJNI.new_ListOfSubmodels__SWIG_0(level, version, pkgVersion), true); 134 } 135 136 137/** 138 * Creates a new {@link ListOfSubmodels} with the given level, version, and package 139 * version. 140 <p> 141 * @param level the SBML Level 142 * @param version the Version within the SBML Level 143 * @param pkgVersion the version of the package 144 */ public 145 ListOfSubmodels(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 146 this(libsbmlJNI.new_ListOfSubmodels__SWIG_1(level, version), true); 147 } 148 149 150/** 151 * Creates a new {@link ListOfSubmodels} with the given level, version, and package 152 * version. 153 <p> 154 * @param level the SBML Level 155 * @param version the Version within the SBML Level 156 * @param pkgVersion the version of the package 157 */ public 158 ListOfSubmodels(long level) throws org.sbml.libsbml.SBMLConstructorException { 159 this(libsbmlJNI.new_ListOfSubmodels__SWIG_2(level), true); 160 } 161 162 163/** 164 * Creates a new {@link ListOfSubmodels} with the given level, version, and package 165 * version. 166 <p> 167 * @param level the SBML Level 168 * @param version the Version within the SBML Level 169 * @param pkgVersion the version of the package 170 */ public 171 ListOfSubmodels() throws org.sbml.libsbml.SBMLConstructorException { 172 this(libsbmlJNI.new_ListOfSubmodels__SWIG_3(), true); 173 } 174 175 176/** 177 * Creates a new {@link ListOfSubmodels} with the given {@link CompPkgNamespaces} object. 178 <p> 179 * @param compns the namespace to use 180 */ public 181 ListOfSubmodels(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException { 182 this(libsbmlJNI.new_ListOfSubmodels__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true); 183 } 184 185 186/** 187 * Get a {@link Submodel} from the {@link ListOfSubmodels}. 188 <p> 189 * @param n the index number of the {@link Submodel} to get. 190 <p> 191 * @return the nth {@link Submodel} in this {@link ListOfSubmodels}. 192 <p> 193 * @see #size() 194 */ public 195 SBase get(long n) { 196 long cPtr = libsbmlJNI.ListOfSubmodels_get__SWIG_0(swigCPtr, this, n); 197 return (cPtr == 0) ? null : new Submodel(cPtr, false); 198 } 199 200 201/** 202 * Get a {@link Model} from the {@link ListOfSubmodels} 203 * based on its identifier. 204 <p> 205 * @param sid a string representing the identifier 206 * of the {@link Model} to get. 207 <p> 208 * @return {@link Model} in this {@link ListOfSubmodels} 209 * with the given <code>sid</code> or <code>null</code> if no such 210 * Member exists. 211 <p> 212 * @see #get(long n) 213 * @see #size() 214 */ public 215 Submodel get(String sid) { 216 long cPtr = libsbmlJNI.ListOfSubmodels_get__SWIG_2(swigCPtr, this, sid); 217 return (cPtr == 0) ? null : new Submodel(cPtr, false); 218 } 219 220 221/** 222 * Removes the nth item from this {@link ListOfSubmodels} items and returns a 223 * pointer to it. 224 <p> 225 * The caller owns the returned item and is responsible for deleting it. 226 <p> 227 * @param n the index of the item to remove 228 <p> 229 * @see #size() 230 */ public 231 SBase remove(long n) { 232 long cPtr = libsbmlJNI.ListOfSubmodels_remove__SWIG_0(swigCPtr, this, n); 233 return (cPtr == 0) ? null : new Submodel(cPtr, true); 234 } 235 236 237/** 238 * Removes an item from this {@link ListOfSubmodels} items based on its identifier 239 * and returns a pointer to it. 240 <p> 241 * The caller owns the returned item and is responsible for deleting it. 242 <p> 243 * @param sid string representing the identifier of the item to remove 244 <p> 245 * @see #size() 246 */ public 247 Submodel remove(String sid) { 248 long cPtr = libsbmlJNI.ListOfSubmodels_remove__SWIG_1(swigCPtr, this, sid); 249 return (cPtr == 0) ? null : new Submodel(cPtr, true); 250 } 251 252 253/** 254 * Returns the libSBML type code for the objects contained in this {@link ListOf} 255 * (i.e., {@link Submodel} objects, if the list is non-empty). 256 <p> 257 * <p> 258 * LibSBML attaches an identifying code to every kind of SBML object. These 259 * are integer constants known as <em>SBML type codes</em>. The names of all 260 * the codes begin with the characters “<code>SBML_</code>”. 261 * In the Java language interface for libSBML, the 262 * type codes are defined as static integer constants in the interface class 263 * {@link libsbmlConstants}. Note that different Level 3 264 * package plug-ins may use overlapping type codes; to identify the package 265 * to which a given object belongs, call the <code>getPackageName()</code> 266 * method on the object. 267 <p> 268 * @return the SBML type code for objects contained in this list: 269 * {@link libsbmlConstants#SBML_COMP_SUBMODEL SBML_COMP_SUBMODEL} (default). 270 <p> 271 * @see #getElementName() 272 * @see #getPackageName() 273 */ public 274 int getItemTypeCode() { 275 return libsbmlJNI.ListOfSubmodels_getItemTypeCode(swigCPtr, this); 276 } 277 278 279/** 280 * Returns the XML element name of 281 * this SBML object. 282 <p> 283 * @return the string of the name of this element. 284 */ public 285 String getElementName() { 286 return libsbmlJNI.ListOfSubmodels_getElementName(swigCPtr, this); 287 } 288 289}