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