001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.7
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 Extension of {@link Model}.
014 <p>
015 * The {@link CompModelPlugin} class inherits from the SBMLSBasePlugin class, and
016 * codifies the extentions to the {@link Model} class defined in the SBML
017 * Level&nbsp;3  'Hierarchical Model Composition' 
018 * package (&ldquo;comp&rdquo;).  This extention allows a {@link Model} to define
019 * Submodels (other Models that are instantiated as new parts of the parent
020 * {@link Model}), and Ports, a defined interface for including the given {@link Model} as a
021 * {@link Submodel} of a different {@link Model}.
022 <p>
023 * Submodels are stored in an optional child {@link ListOfSubmodels} object, which, 
024 * if present, must contain one or more {@link Submodel} objects.  All of the Submodels
025 * present in the {@link ListOfSubmodels} are defined to be instantiated in the
026 * 'complete' {@link Model}.
027 <p>
028 * Ports are stored in an optional child {@link ListOfPorts} object, which, 
029 * if present, must contain one or more {@link Port} objects.  All of the Ports
030 * present in the {@link ListOfPorts} collectively define the 'port interface'
031 * of the {@link Model}.
032 */
033
034public class CompModelPlugin extends CompSBasePlugin {
035   private long swigCPtr;
036
037   protected CompModelPlugin(long cPtr, boolean cMemoryOwn)
038   {
039     super(libsbmlJNI.CompModelPlugin_SWIGUpcast(cPtr), cMemoryOwn);
040     swigCPtr = cPtr;
041   }
042
043   protected static long getCPtr(CompModelPlugin obj)
044   {
045     return (obj == null) ? 0 : obj.swigCPtr;
046   }
047
048   protected static long getCPtrAndDisown (CompModelPlugin obj)
049   {
050     long ptr = 0;
051
052     if (obj != null)
053     {
054       ptr             = obj.swigCPtr;
055       obj.swigCMemOwn = false;
056     }
057
058     return ptr;
059   }
060
061  protected void finalize() {
062    delete();
063  }
064
065  public synchronized void delete() {
066    if (swigCPtr != 0) {
067      if (swigCMemOwn) {
068        swigCMemOwn = false;
069        libsbmlJNI.delete_CompModelPlugin(swigCPtr);
070      }
071      swigCPtr = 0;
072    }
073    super.delete();
074  }
075
076  
077/**
078   * Constructor.
079   */ public
080 CompModelPlugin(String uri, String prefix, CompPkgNamespaces compns) {
081    this(libsbmlJNI.new_CompModelPlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true);
082  }
083
084  
085/**
086   * Copy constructor. Creates a copy of this {@link CompModelPlugin} object.
087   */ public
088 CompModelPlugin(CompModelPlugin orig) {
089    this(libsbmlJNI.new_CompModelPlugin__SWIG_1(CompModelPlugin.getCPtr(orig), orig), true);
090  }
091
092  
093/**
094   * Creates and returns a deep copy of this {@link CompModelPlugin} object.
095   <p>
096   * @return a (deep) copy of this {@link CompModelPlugin} object
097   */ public
098 SBasePlugin cloneObject() {
099    long cPtr = libsbmlJNI.CompModelPlugin_cloneObject(swigCPtr, this);
100    return (cPtr == 0) ? null : new CompModelPlugin(cPtr, true);
101  }
102
103  
104/** * @internal */ public
105 SBase createObject(XMLInputStream stream) {
106  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false);
107}
108
109  
110/**
111   * Returns the first child element found that has the given <code>id</code> in the
112   * model-wide SId namespace, or <code>null</code> if no such object is found.
113   <p>
114   * @param id a string representing the id of objects to find.
115   <p>
116   * @return a pointer to the {@link SBase} element with the given <code>id</code>.
117   */ public
118 SBase getElementBySId(String id) {
119  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementBySId(swigCPtr, this, id), false);
120}
121
122  
123/**
124   * Returns the first child element it can find with the given meta
125   * identifier, or itself if it has the given <code>metaid</code>, or <code>null</code> if no
126   * such object is found.
127   <p>
128   * @param metaid a string representing the metaid of objects to find.
129   <p>
130   * @return a pointer to the {@link SBase} element with the given <code>metaid</code>.
131   */ public
132 SBase getElementByMetaId(String metaid) {
133  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementByMetaId(swigCPtr, this, metaid), false);
134}
135
136  
137/**
138   * Returns the {@link ListOf} object that holds all submodels.
139   <p>
140   * @return the {@link ListOf} object that holds all submodels.
141   */ public
142 ListOfSubmodels getListOfSubmodels() {
143    long cPtr = libsbmlJNI.CompModelPlugin_getListOfSubmodels(swigCPtr, this);
144    return (cPtr == 0) ? null : new ListOfSubmodels(cPtr, false);
145  }
146
147  
148/**
149   * Returns the submodel with the given index.
150   * If the index is invalid, <code>null</code> is returned.
151   <p>
152   * @param n the index number of the {@link Submodel} to get.
153   <p>
154   * @return the nth {@link Submodel} in the {@link ListOfSubmodels}.
155   */ public
156 Submodel getSubmodel(long n) {
157    long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_0(swigCPtr, this, n);
158    return (cPtr == 0) ? null : new Submodel(cPtr, false);
159  }
160
161  
162/**
163   * Returns the submodel with the given identifier.
164   <p>
165   * @param id the identifier of the {@link Submodel} to get.
166   <p>
167   * @return the {@link Submodel} in the {@link ListOfSubmodels} with the given identifier.
168   * If no such submodel with identifier <code>id</code> exists, <code>null</code> is returned.
169   */ public
170 Submodel getSubmodel(String id) {
171    long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_2(swigCPtr, this, id);
172    return (cPtr == 0) ? null : new Submodel(cPtr, false);
173  }
174
175  
176/**
177   * Adds a copy of the given {@link Submodel} object to the list of submodels.
178   <p>
179   * Fails if the added submodel is <code>null</code>, does not match the
180   * level/version/package of the parent object, or cannot be added to the
181   * list of submodels.
182   <p>
183   * @param submodel the {@link Submodel} object to be added to the list of
184   * submodels.
185   <p>
186   * <p>
187 * @return integer value indicating success/failure of the
188 * function.   The possible values
189 * returned by this function are:
190   * <ul>
191   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
192   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
193   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
194   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
195   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
196   * </ul>
197   */ public
198 int addSubmodel(Submodel submodel) {
199    return libsbmlJNI.CompModelPlugin_addSubmodel(swigCPtr, this, Submodel.getCPtr(submodel), submodel);
200  }
201
202  
203/**
204   * Returns the number of submodels for this {@link CompModelPlugin}.
205   <p>
206   * @return the number of submodels for this {@link CompModelPlugin}.
207   */ public
208 long getNumSubmodels() {
209    return libsbmlJNI.CompModelPlugin_getNumSubmodels(swigCPtr, this);
210  }
211
212  
213/**
214   * Creates a {@link Submodel} object, adds it to the end of the
215   * submodel objects list and returns a pointer to the newly
216   * created object.
217   <p>
218   * @return a newly created {@link Submodel} object
219   */ public
220 Submodel createSubmodel() {
221    long cPtr = libsbmlJNI.CompModelPlugin_createSubmodel(swigCPtr, this);
222    return (cPtr == 0) ? null : new Submodel(cPtr, false);
223  }
224
225  
226/**
227   * Removes the submodel with the given index.
228   * A pointer to the submodel that was removed is returned.
229   <p>
230   * @param index the index of the {@link Submodel} object to remove
231   <p>
232   * @return the {@link Submodel} object removed.  As mentioned above, the caller
233   * owns the returned object. <code>null</code> is returned if the given <code>index</code> is
234   * out of range and no submodel has been removed, <code>null</code> is returned.
235   */ public
236 Submodel removeSubmodel(long index) {
237    long cPtr = libsbmlJNI.CompModelPlugin_removeSubmodel(swigCPtr, this, index);
238    return (cPtr == 0) ? null : new Submodel(cPtr, false);
239  }
240
241  
242/**
243   * Returns the {@link ListOf} object that holds all ports.
244   <p>
245   * @return the {@link ListOf} object that holds all ports.
246   */ public
247 ListOfPorts getListOfPorts() {
248    long cPtr = libsbmlJNI.CompModelPlugin_getListOfPorts(swigCPtr, this);
249    return (cPtr == 0) ? null : new ListOfPorts(cPtr, false);
250  }
251
252  
253/**
254   * Returns the port with the given index.
255   <p>
256   * @param n the index number of the {@link Port} to get.
257   <p>
258   * @return the nth {@link Port} in the {@link ListOfPorts}.  If the index <code>n</code> is invalid,
259   * <code>null</code> is returned.
260   */ public
261 Port getPort(long n) {
262    long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_0(swigCPtr, this, n);
263    return (cPtr == 0) ? null : new Port(cPtr, false);
264  }
265
266  
267/**
268   * Returns the port with the given identifier.
269   <p>
270   * @param id the id of the {@link Port} to get.
271   <p>
272   * @return the {@link Port} in the {@link ListOfPorts} with the given identifier.  If the
273   * identifier is invalid, <code>null</code> is returned.
274   */ public
275 Port getPort(String id) {
276    long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_2(swigCPtr, this, id);
277    return (cPtr == 0) ? null : new Port(cPtr, false);
278  }
279
280  
281/**
282   * Adds a copy of the given {@link Port} object to the list of ports.
283   <p>
284   * @param port the {@link Port} object to be added to the list of ports.  Fails if
285   * the added port is <code>null</code>, does not match the level/version/package of the
286   * parent object, or cannot be added to the list of ports.
287   <p>
288   * <p>
289 * @return integer value indicating success/failure of the
290 * function.   The possible values
291 * returned by this function are:
292   * <ul>
293   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
294   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
295   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
296   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
297   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
298   * </ul>
299   */ public
300 int addPort(Port port) {
301    return libsbmlJNI.CompModelPlugin_addPort(swigCPtr, this, Port.getCPtr(port), port);
302  }
303
304  
305/**
306   * Returns the number of ports for this {@link CompModelPlugin}.
307   <p>
308   * @return the number of ports for this {@link CompModelPlugin}.
309   */ public
310 long getNumPorts() {
311    return libsbmlJNI.CompModelPlugin_getNumPorts(swigCPtr, this);
312  }
313
314  
315/**
316   * Creates a {@link Port} object, adds it to the end of the
317   * port objects list and returns a pointer to the newly
318   * created object.
319   <p>
320   * @return a newly created {@link Port} object
321   */ public
322 Port createPort() {
323    long cPtr = libsbmlJNI.CompModelPlugin_createPort(swigCPtr, this);
324    return (cPtr == 0) ? null : new Port(cPtr, false);
325  }
326
327  
328/**
329   * Removes the port with the given index.
330   <p>
331   * @param index the index of the {@link Port} object to remove
332   <p>
333   * @return the {@link Port} object removed.  As mentioned above, 
334   * the caller owns the returned object. <code>null</code> is returned if 
335   * the given index is out of range.
336   */ public
337 Port removePort(long index) {
338    long cPtr = libsbmlJNI.CompModelPlugin_removePort(swigCPtr, this, index);
339    return (cPtr == 0) ? null : new Port(cPtr, false);
340  }
341
342  
343/**
344   * Set the string used as the divider between names when renaming and
345   * flattening models.
346   <p>
347   * The divider string consists of two underscore characters
348   * (&quot;<code>__</code>&quot;) by default.  This method will fail if called
349   * with an empty <code>divider</code>, or a <code>divider</code> that cannot be used internally as part
350   * of a valid SBML SId.
351   <p>
352   * <p>
353 * @return integer value indicating success/failure of the
354 * function.   The possible values
355 * returned by this function are:
356   * <ul>
357   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
358   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
359   * </ul>
360   */ public
361 int setDivider(String divider) {
362    return libsbmlJNI.CompModelPlugin_setDivider(swigCPtr, this, divider);
363  }
364
365  
366/**
367   * Get the string used as the divider between names when renaming and
368   * flattening models.
369   <p>
370   * The divider string consists of two underscore characters
371   * (&quot;<code>__</code>&quot;) by default, and can be overridden
372   * with the setDivider() function.
373   <p>
374   * @see #setDivider(String divider)
375   */ public
376 String getDivider() {
377    return libsbmlJNI.CompModelPlugin_getDivider(swigCPtr, this);
378  }
379
380  
381/** * @internal */ public
382 void connectToChild() {
383    libsbmlJNI.CompModelPlugin_connectToChild(swigCPtr, this);
384  }
385
386  
387/** * @internal */ public
388 void connectToParent(SBase parent) {
389    libsbmlJNI.CompModelPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent);
390  }
391
392  
393/** * @internal */ public
394 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
395    libsbmlJNI.CompModelPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
396  }
397
398  
399/**
400   * Sets the custom transformer that is to be used, instead of the standard
401   * prefixing with the given divider. This makes it possible to finely control
402   * how elements are altered. 
403   <p>
404   * If not set, only ids and meta ids will be prefixed. 
405   <p>
406   * NOTE: the model plugin only holds the pointer to the element it does not 
407   *       take ownership of it. Thus the calling program is responsible of 
408   *       freeing the transformer when no longer needed (i.e after the 
409   *       SBML document has been deleted)
410   */ public
411 void setTransformer(SWIGTYPE_p_PrefixTransformer transformer) {
412    libsbmlJNI.CompModelPlugin_setTransformer(swigCPtr, this, SWIGTYPE_p_PrefixTransformer.getCPtr(transformer));
413  }
414
415  
416/**
417   * @return any custom transformer set for prefix operations, will be null by default.
418   */ public
419 SWIGTYPE_p_PrefixTransformer getTransformer() {
420    long cPtr = libsbmlJNI.CompModelPlugin_getTransformer(swigCPtr, this);
421    return (cPtr == 0) ? null : new SWIGTYPE_p_PrefixTransformer(cPtr, false);
422  }
423
424  
425/**
426   * @return an indicator, whether a custom transformer has been set. 
427   */ public
428 boolean isSetTransformer() {
429    return libsbmlJNI.CompModelPlugin_isSetTransformer(swigCPtr, this);
430  }
431
432  
433/**
434   * Unsets any custom prefix transformers. 
435   */ public
436 void unsetTransformer() {
437    libsbmlJNI.CompModelPlugin_unsetTransformer(swigCPtr, this);
438  }
439
440}