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