001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.10
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 A list of {@link ModelDefinition} objects.
014 <p>
015 * The {@link ListOfModelDefinitions} is a container for the extended 
016 * {@link SBMLDocument} that allows one to define multiple Models in a single file
017 * for use in {@link Submodel} objects.
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&nbsp;2 Version&nbsp;4):
034 <p>
035 * <figure>
036  <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object>
037</figure>
038
039 <p>
040 * SBML Level&nbsp;3 Version&nbsp;1 has essentially the same structure as 
041 * Level&nbsp;2 Version&nbsp;4, depicted above, but SBML Level&nbsp;3 
042 * Version&nbsp;2 allows
043 * containers to contain zero or more of the relevant object, instead of 
044 * requiring at least one.  As such, libsbml will write out an 
045 * otherwise-empty ListOf___ element that has any optional attribute set 
046 * (such as 'id' or 'metaid'), that has an optional child (such 
047 * as a 'notes' or 'annotation'), or that has attributes or children set
048 * from any SBML Level&nbsp;3 package, whether or not the ListOf___ has 
049 * any other children.
050 <p>
051 * Readers may wonder about the motivations for using the ListOf___
052 * containers in SBML.  A simpler approach in XML might be to place the
053 * components all directly at the top level of the model definition.  The
054 * choice made in SBML is to group them within XML elements named after
055 * ListOf<em>Classname</em>, in part because it helps organize the
056 * components.  More importantly, the fact that the container classes are
057 * derived from {@link SBase} means that software tools can add information <em>about</em>
058 * the lists themselves into each list container's 'annotation'.
059 <p>
060 * @see ListOfFunctionDefinitions
061 * @see ListOfUnitDefinitions
062 * @see ListOfCompartmentTypes
063 * @see ListOfSpeciesTypes
064 * @see ListOfCompartments
065 * @see ListOfSpecies
066 * @see ListOfParameters
067 * @see ListOfInitialAssignments
068 * @see ListOfRules
069 * @see ListOfConstraints
070 * @see ListOfReactions
071 * @see ListOfEvents
072 <p>
073 * @see ModelDefinition
074 * @see ListOfDeletions
075 * @see ListOfExternalModelDefinitions
076 * @see ListOfPorts
077 * @see ListOfReplacedElements
078 * @see ListOfSubmodels
079 */
080
081public class ListOfModelDefinitions extends ListOf {
082   private long swigCPtr;
083
084   protected ListOfModelDefinitions(long cPtr, boolean cMemoryOwn)
085   {
086     super(libsbmlJNI.ListOfModelDefinitions_SWIGUpcast(cPtr), cMemoryOwn);
087     swigCPtr = cPtr;
088   }
089
090   protected static long getCPtr(ListOfModelDefinitions obj)
091   {
092     return (obj == null) ? 0 : obj.swigCPtr;
093   }
094
095   protected static long getCPtrAndDisown (ListOfModelDefinitions obj)
096   {
097     long ptr = 0;
098
099     if (obj != null)
100     {
101       ptr             = obj.swigCPtr;
102       obj.swigCMemOwn = false;
103     }
104
105     return ptr;
106   }
107
108  protected void finalize() {
109    delete();
110  }
111
112  public synchronized void delete() {
113    if (swigCPtr != 0) {
114      if (swigCMemOwn) {
115        swigCMemOwn = false;
116        libsbmlJNI.delete_ListOfModelDefinitions(swigCPtr);
117      }
118      swigCPtr = 0;
119    }
120    super.delete();
121  }
122
123  
124/**
125   * Creates and returns a deep copy of this {@link ListOfModelDefinitions} object.
126   <p>
127   * @return a (deep) copy of this {@link ListOfModelDefinitions}.
128   */ public
129 ListOfModelDefinitions cloneObject() {
130    long cPtr = libsbmlJNI.ListOfModelDefinitions_cloneObject(swigCPtr, this);
131    return (cPtr == 0) ? null : new ListOfModelDefinitions(cPtr, true);
132  }
133
134  
135/**
136   * Creates a new {@link ListOfModelDefinitions} with the given level, version, and
137   * package version.
138   <p>
139   * @param level the SBML Level.
140   * @param version the Version within the SBML Level.
141   * @param pkgVersion the version of the package.
142   <p>
143   * <p>
144 * @note Attempting to add an object to an {@link SBMLDocument} having a different
145 * combination of SBML Level, Version and XML namespaces than the object
146 * itself will result in an error at the time a caller attempts to make the
147 * addition.  A parent object must have compatible Level, Version and XML
148 * namespaces.  (Strictly speaking, a parent may also have more XML
149 * namespaces than a child, but the reverse is not permitted.)  The
150 * restriction is necessary to ensure that an SBML model has a consistent
151 * overall structure.  This requires callers to manage their objects
152 * carefully, but the benefit is increased flexibility in how models can be
153 * created by permitting callers to create objects bottom-up if desired.  In
154 * situations where objects are not yet attached to parents (e.g.,
155 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
156 * libSBML determine such things as whether it is valid to assign a
157 * particular value to an attribute.  For packages, this means that the 
158 * parent object to which this package element is being added must have
159 * been created with the package namespace, or that the package namespace
160 * was added to it, even if that parent is not a package object itself.
161   */ public
162 ListOfModelDefinitions(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
163    this(libsbmlJNI.new_ListOfModelDefinitions__SWIG_0(level, version, pkgVersion), true);
164  }
165
166  
167/**
168   * Creates a new {@link ListOfModelDefinitions} with the given level, version, and
169   * package version.
170   <p>
171   * @param level the SBML Level.
172   * @param version the Version within the SBML Level.
173   * @param pkgVersion the version of the package.
174   <p>
175   * <p>
176 * @note Attempting to add an object to an {@link SBMLDocument} having a different
177 * combination of SBML Level, Version and XML namespaces than the object
178 * itself will result in an error at the time a caller attempts to make the
179 * addition.  A parent object must have compatible Level, Version and XML
180 * namespaces.  (Strictly speaking, a parent may also have more XML
181 * namespaces than a child, but the reverse is not permitted.)  The
182 * restriction is necessary to ensure that an SBML model has a consistent
183 * overall structure.  This requires callers to manage their objects
184 * carefully, but the benefit is increased flexibility in how models can be
185 * created by permitting callers to create objects bottom-up if desired.  In
186 * situations where objects are not yet attached to parents (e.g.,
187 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
188 * libSBML determine such things as whether it is valid to assign a
189 * particular value to an attribute.  For packages, this means that the 
190 * parent object to which this package element is being added must have
191 * been created with the package namespace, or that the package namespace
192 * was added to it, even if that parent is not a package object itself.
193   */ public
194 ListOfModelDefinitions(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
195    this(libsbmlJNI.new_ListOfModelDefinitions__SWIG_1(level, version), true);
196  }
197
198  
199/**
200   * Creates a new {@link ListOfModelDefinitions} with the given level, version, and
201   * package version.
202   <p>
203   * @param level the SBML Level.
204   * @param version the Version within the SBML Level.
205   * @param pkgVersion the version of the package.
206   <p>
207   * <p>
208 * @note Attempting to add an object to an {@link SBMLDocument} having a different
209 * combination of SBML Level, Version and XML namespaces than the object
210 * itself will result in an error at the time a caller attempts to make the
211 * addition.  A parent object must have compatible Level, Version and XML
212 * namespaces.  (Strictly speaking, a parent may also have more XML
213 * namespaces than a child, but the reverse is not permitted.)  The
214 * restriction is necessary to ensure that an SBML model has a consistent
215 * overall structure.  This requires callers to manage their objects
216 * carefully, but the benefit is increased flexibility in how models can be
217 * created by permitting callers to create objects bottom-up if desired.  In
218 * situations where objects are not yet attached to parents (e.g.,
219 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
220 * libSBML determine such things as whether it is valid to assign a
221 * particular value to an attribute.  For packages, this means that the 
222 * parent object to which this package element is being added must have
223 * been created with the package namespace, or that the package namespace
224 * was added to it, even if that parent is not a package object itself.
225   */ public
226 ListOfModelDefinitions(long level) throws org.sbml.libsbml.SBMLConstructorException {
227    this(libsbmlJNI.new_ListOfModelDefinitions__SWIG_2(level), true);
228  }
229
230  
231/**
232   * Creates a new {@link ListOfModelDefinitions} with the given level, version, and
233   * package version.
234   <p>
235   * @param level the SBML Level.
236   * @param version the Version within the SBML Level.
237   * @param pkgVersion the version of the package.
238   <p>
239   * <p>
240 * @note Attempting to add an object to an {@link SBMLDocument} having a different
241 * combination of SBML Level, Version and XML namespaces than the object
242 * itself will result in an error at the time a caller attempts to make the
243 * addition.  A parent object must have compatible Level, Version and XML
244 * namespaces.  (Strictly speaking, a parent may also have more XML
245 * namespaces than a child, but the reverse is not permitted.)  The
246 * restriction is necessary to ensure that an SBML model has a consistent
247 * overall structure.  This requires callers to manage their objects
248 * carefully, but the benefit is increased flexibility in how models can be
249 * created by permitting callers to create objects bottom-up if desired.  In
250 * situations where objects are not yet attached to parents (e.g.,
251 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
252 * libSBML determine such things as whether it is valid to assign a
253 * particular value to an attribute.  For packages, this means that the 
254 * parent object to which this package element is being added must have
255 * been created with the package namespace, or that the package namespace
256 * was added to it, even if that parent is not a package object itself.
257   */ public
258 ListOfModelDefinitions() throws org.sbml.libsbml.SBMLConstructorException {
259    this(libsbmlJNI.new_ListOfModelDefinitions__SWIG_3(), true);
260  }
261
262  
263/**
264   * Creates a new {@link ListOfModelDefinitions} with the given {@link CompPkgNamespaces}
265   * object.
266   <p>
267   * <p>
268 * The package namespaces object used in this constructor is derived from a
269 * {@link SBMLNamespaces} object, which encapsulates SBML Level/Version/namespaces
270 * information.  It is used to communicate the SBML Level, Version, and 
271 * package version and name information used in addition to SBML Level&nbsp;3 Core.  A
272 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
273 * package namespace object somewhere in a program once, then hand that object
274 * as needed to object constructors of that package that accept it as and
275 * argument, such as this one.
276   <p>
277   * @param compns the {@link CompPkgNamespaces} object.
278   <p>
279   * <p>
280 * @note Attempting to add an object to an {@link SBMLDocument} having a different
281 * combination of SBML Level, Version and XML namespaces than the object
282 * itself will result in an error at the time a caller attempts to make the
283 * addition.  A parent object must have compatible Level, Version and XML
284 * namespaces.  (Strictly speaking, a parent may also have more XML
285 * namespaces than a child, but the reverse is not permitted.)  The
286 * restriction is necessary to ensure that an SBML model has a consistent
287 * overall structure.  This requires callers to manage their objects
288 * carefully, but the benefit is increased flexibility in how models can be
289 * created by permitting callers to create objects bottom-up if desired.  In
290 * situations where objects are not yet attached to parents (e.g.,
291 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
292 * libSBML determine such things as whether it is valid to assign a
293 * particular value to an attribute.  For packages, this means that the 
294 * parent object to which this package element is being added must have
295 * been created with the package namespace, or that the package namespace
296 * was added to it, even if that parent is not a package object itself.
297   */ public
298 ListOfModelDefinitions(CompPkgNamespaces compns) throws org.sbml.libsbml.SBMLConstructorException {
299    this(libsbmlJNI.new_ListOfModelDefinitions__SWIG_4(CompPkgNamespaces.getCPtr(compns), compns), true);
300  }
301
302  
303/**
304   * Get a {@link ModelDefinition} from the {@link ListOfModelDefinitions}.
305   <p>
306   * @param n the index number of the {@link ModelDefinition} to get.
307   <p>
308   * @return the nth {@link ModelDefinition} in this {@link ListOfModelDefinitions}.
309   <p>
310   * @see #size()
311   */ public
312 SBase get(long n) {
313    long cPtr = libsbmlJNI.ListOfModelDefinitions_get__SWIG_0(swigCPtr, this, n);
314    return (cPtr == 0) ? null : new ModelDefinition(cPtr, false);
315  }
316
317  
318/**
319   * Get a {@link Model} from the {@link ListOfModelDefinitions}
320   * based on its identifier.
321   <p>
322   * @param sid a string representing the identifier 
323   * of the {@link Model} to get.
324   <p>
325   * @return {@link Model} in this {@link ListOfModelDefinitions}
326   * with the given <code>sid</code> or <code>null</code> if no such
327   * {@link Member} exists.
328   <p>
329   * @see #get(long n)
330   * @see #size()
331   */ public
332 ModelDefinition get(String sid) {
333    long cPtr = libsbmlJNI.ListOfModelDefinitions_get__SWIG_2(swigCPtr, this, sid);
334    return (cPtr == 0) ? null : new ModelDefinition(cPtr, false);
335  }
336
337  
338/**
339   * Removes the nth item from this {@link ListOfModelDefinitions} items and returns
340   * a pointer to it.
341   <p>
342   * The caller owns the returned item and is responsible for deleting it.
343   <p>
344   * @param n the index of the item to remove.
345   <p>
346   * @see #size()
347   */ public
348 SBase remove(long n) {
349    long cPtr = libsbmlJNI.ListOfModelDefinitions_remove__SWIG_0(swigCPtr, this, n);
350    return (cPtr == 0) ? null : new ModelDefinition(cPtr, true);
351  }
352
353  
354/**
355   * Removes the item with given identifer from this {@link ListOfModelDefinitions}
356   * items and returns a pointer to it.
357   <p>
358   * The caller owns the returned item and is responsible for deleting it.
359   <p>
360   * @param sid the id of the item to remove.
361   <p>
362   * @see #size()
363   */ public
364 ModelDefinition remove(String sid) {
365    long cPtr = libsbmlJNI.ListOfModelDefinitions_remove__SWIG_1(swigCPtr, this, sid);
366    return (cPtr == 0) ? null : new ModelDefinition(cPtr, true);
367  }
368
369  
370/**
371   * Returns the libSBML type code for the objects contained in this {@link ListOf}
372   * (i.e., {@link ModelDefinition} objects, if the list is non-empty).
373   <p>
374   * <p>
375 * LibSBML attaches an identifying code to every kind of SBML object.  These
376 * are integer constants known as <em>SBML type codes</em>.  The names of all
377 * the codes begin with the characters <code>SBML_</code>.
378 * In the Java language interface for libSBML, the
379 * type codes are defined as static integer constants in the interface class
380 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
381 * package plug-ins may use overlapping type codes; to identify the package
382 * to which a given object belongs, call the <code>getPackageName()</code>
383 * method on the object.
384   <p>
385   * @return the SBML type code for objects contained in this list:
386   * {@link libsbmlConstants#SBML_COMP_MODELDEFINITION SBML_COMP_MODELDEFINITION} (default).
387   <p>
388   * @see #getElementName()
389   * @see #getPackageName()
390   */ public
391 int getItemTypeCode() {
392    return libsbmlJNI.ListOfModelDefinitions_getItemTypeCode(swigCPtr, this);
393  }
394
395  
396/**
397   * Returns the XML element name of
398   * this SBML object.
399   <p>
400   * @return the name of this element, as a text string.
401   */ public
402 String getElementName() {
403    return libsbmlJNI.ListOfModelDefinitions_getElementName(swigCPtr, this);
404  }
405
406}