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 &ldquo;comp&rdquo; package
014 * extention to the SBase construct.
015 <p>
016 * The {@link CompSBasePlugin} class inherits from the {@link SBasePlugin} class, 
017 * and codifies the extentions to the {@link SBase} class defined in the
018 *  'Hierarchical Model Composition' 
019 * package (&ldquo;comp&rdquo;).  This extention allows the modeler to define
020 * one or more submodel elements which the parent {@link SBase} object replaces,
021 * and/or a single submodel element which replaces the parent {@link SBase} object.
022<p>
023 * This is accomplished through the addition of an optional {@link ListOfReplacedElements}
024 * child, which may contain one or more {@link ReplacedElement} objects, each of which 
025 * references a submodel object to be replaced by the containing {@link SBase} object, 
026 * and through the addition of a single optional {@link ReplacedBy} child, which 
027 * references a submodel object which is to replace the containing {@link SBase} object.
028<p>
029 * If a single {@link SBase} element both contains a {@link ListOfReplacedElements} and has a {@link ReplacedBy}
030 * child, it and all the referenced {@link ReplacedElement} objects are to be replaced
031 * by the object referenced by the {@link ReplacedBy} element.
032 <p>
033 * @see ReplacedElement
034 * @see ReplacedBy
035 */
036
037public class CompSBasePlugin extends SBasePlugin {
038   private long swigCPtr;
039
040   protected CompSBasePlugin(long cPtr, boolean cMemoryOwn)
041   {
042     super(libsbmlJNI.CompSBasePlugin_SWIGUpcast(cPtr), cMemoryOwn);
043     swigCPtr = cPtr;
044   }
045
046   protected static long getCPtr(CompSBasePlugin obj)
047   {
048     return (obj == null) ? 0 : obj.swigCPtr;
049   }
050
051   protected static long getCPtrAndDisown (CompSBasePlugin obj)
052   {
053     long ptr = 0;
054
055     if (obj != null)
056     {
057       ptr             = obj.swigCPtr;
058       obj.swigCMemOwn = false;
059     }
060
061     return ptr;
062   }
063
064  protected void finalize() {
065    delete();
066  }
067
068  public synchronized void delete() {
069    if (swigCPtr != 0) {
070      if (swigCMemOwn) {
071        swigCMemOwn = false;
072        libsbmlJNI.delete_CompSBasePlugin(swigCPtr);
073      }
074      swigCPtr = 0;
075    }
076    super.delete();
077  }
078
079  
080/**
081   * Constructor.
082   */ public
083 CompSBasePlugin(String uri, String prefix, CompPkgNamespaces compns) {
084    this(libsbmlJNI.new_CompSBasePlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true);
085  }
086
087  
088/**
089   * Copy constructor. Creates a copy of this {@link CompSBasePlugin} object.
090   */ public
091 CompSBasePlugin(CompSBasePlugin orig) {
092    this(libsbmlJNI.new_CompSBasePlugin__SWIG_1(CompSBasePlugin.getCPtr(orig), orig), true);
093  }
094
095  
096/**
097   * Creates and returns a deep copy of this {@link CompSBasePlugin} object.
098   <p>
099   * @return a (deep) copy of this {@link CompSBasePlugin} object
100   */ public
101 SBasePlugin cloneObject() {
102    long cPtr = libsbmlJNI.CompSBasePlugin_cloneObject(swigCPtr, this);
103    return (cPtr == 0) ? null : new CompSBasePlugin(cPtr, true);
104  }
105
106  
107/**
108   * Create and return an SBML object of this class, if present.
109   <p>
110   * @return the SBML object corresponding to next {@link XMLToken} in the
111   * {@link XMLInputStream} or <code>null</code> if the token was not recognized.
112   * @internal
113   */ public
114 SBase createObject(XMLInputStream stream) {
115  return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false);
116}
117
118  
119/**
120   * Returns the first child element found that has the given <code>id</code> in the
121   * model-wide SId namespace, or <code>null</code> if no such object is found.
122   <p>
123   * @param id string representing the id of objects to find
124   <p>
125   * @return a pointer to the {@link SBase} element with the given <code>id</code>.
126   */ public
127 SBase getElementBySId(String id) {
128  return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_getElementBySId(swigCPtr, this, id), false);
129}
130
131  
132/**
133   * Returns the first child element it can find with the given <code>metaid</code>, or
134   * itself if it has the given <code>metaid</code>, or <code>null</code> if no such object is
135   * found.
136   <p>
137   * @param metaid string representing the metaid of objects to find
138   <p>
139   * @return a pointer to the {@link SBase} element with the given <code>metaid</code>.
140   */ public
141 SBase getElementByMetaId(String metaid) {
142  return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_getElementByMetaId(swigCPtr, this, metaid), false);
143}
144
145  
146/**
147   * Returns the {@link ListOf} object that holds all replacedElements.
148   <p>
149   * @return the {@link ListOf} object that holds all replacedElements.
150   */ public
151 ListOfReplacedElements getListOfReplacedElements() {
152    long cPtr = libsbmlJNI.CompSBasePlugin_getListOfReplacedElements(swigCPtr, this);
153    return (cPtr == 0) ? null : new ListOfReplacedElements(cPtr, false);
154  }
155
156  
157/**
158   * Returns the {@link ReplacedElement} with the given index.
159   <p>
160   * @param n the index number of the {@link ReplacedElement} to get.
161   <p>
162   * @return the nth {@link ReplacedElement} in the {@link ListOfReplacedElements}.  If the
163   * index is invalid, <code>null</code> is returned.
164   */ public
165 ReplacedElement getReplacedElement(long n) {
166    long cPtr = libsbmlJNI.CompSBasePlugin_getReplacedElement__SWIG_0(swigCPtr, this, n);
167    return (cPtr == 0) ? null : new ReplacedElement(cPtr, false);
168  }
169
170  
171/**
172   * Adds a copy of the given {@link ReplacedElement} object to the list of ReplacedElements.
173   <p>
174   * @param replacedElement the {@link ReplacedElement} object to be added to the
175   * list of ReplacedElements.  Fails if the added {@link ReplacedElement} is <code>null</code>,
176   * does not match the level/version/package of the parent object, or cannot
177   * be added to the list of replaced elements.
178   <p>
179   * @return integer value indicating success/failure of the
180   * operation. The possible return values are:
181   * <ul>
182   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
183   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
184   * <li> {@link  libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH }
185   * <li> {@link  libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH }
186   * <li> {@link  libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH }
187   * </ul>
188   */ public
189 int addReplacedElement(ReplacedElement replacedElement) {
190    return libsbmlJNI.CompSBasePlugin_addReplacedElement(swigCPtr, this, ReplacedElement.getCPtr(replacedElement), replacedElement);
191  }
192
193  
194/**
195   * Returns the number of ReplacedElements for this {@link CompSBasePlugin}.
196   <p>
197   * @return the number of ReplacedElements for this {@link CompSBasePlugin}.
198   */ public
199 long getNumReplacedElements() {
200    return libsbmlJNI.CompSBasePlugin_getNumReplacedElements(swigCPtr, this);
201  }
202
203  
204/**
205   * Remove all ReplacedElements, if any exist.
206   */ public
207 void clearReplacedElements() {
208    libsbmlJNI.CompSBasePlugin_clearReplacedElements(swigCPtr, this);
209  }
210
211  
212/**
213   * Creates a {@link ReplacedElement} object, adds it to the end of the
214   * {@link ReplacedElement} objects list and returns a pointer to the newly
215   * created object.
216   <p>
217   * @return a newly created {@link ReplacedElement} object
218   */ public
219 ReplacedElement createReplacedElement() {
220    long cPtr = libsbmlJNI.CompSBasePlugin_createReplacedElement(swigCPtr, this);
221    return (cPtr == 0) ? null : new ReplacedElement(cPtr, false);
222  }
223
224  
225/**
226   * Removes the {@link ReplacedElement} with the given index.
227   <p>
228   * A pointer to the {@link ReplacedElement} that was removed is returned.
229   * If no {@link ReplacedElement} has been removed, <code>null</code> is returned.
230   <p>
231   * @param index the index of the {@link ReplacedElement} object to remove
232   <p>
233   * @return the {@link ReplacedElement} object removed.  As mentioned above, 
234   * the caller owns the returned object. <code>null</code> is returned if 
235   * the given index is out of range.
236   */ public
237 ReplacedElement removeReplacedElement(long index) {
238    long cPtr = libsbmlJNI.CompSBasePlugin_removeReplacedElement(swigCPtr, this, index);
239    return (cPtr == 0) ? null : new ReplacedElement(cPtr, false);
240  }
241
242  
243/**
244   * Get the child {@link ReplacedBy} of this {@link SBase}.
245   <p>
246   * @return the const {@link ReplacedBy} child of this {@link SBase}
247   */ public
248 ReplacedBy getReplacedBy() {
249    long cPtr = libsbmlJNI.CompSBasePlugin_getReplacedBy__SWIG_0(swigCPtr, this);
250    return (cPtr == 0) ? null : new ReplacedBy(cPtr, false);
251  }
252
253  
254/**
255   * Predicate for testing whether the {@link ReplacedBy} for this {@link SBase} is set.
256   <p>
257   * @return <code>true</code> if the {@link ReplacedBy} of this {@link SBase} is set, <code>false</code>
258   * otherwise.
259   */ public
260 boolean isSetReplacedBy() {
261    return libsbmlJNI.CompSBasePlugin_isSetReplacedBy(swigCPtr, this);
262  }
263
264  
265/**
266   * Sets the {@link ReplacedBy} definition of this {@link SBase} to a copy of the given
267   * {@link ReplacedBy} object instance.
268   <p>
269   * This method fails if the added {@link ReplacedBy} does not match the
270   * level/version/package of the parent object or if the added {@link ReplacedBy}
271   * cannot be copied.
272   <p>
273   * @param replacedBy the {@link ReplacedBy} object instance to use.
274   <p>
275   * @return integer value indicating success/failure of the
276   * operation. The possible return values are:
277   * <ul>
278   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
279   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
280   * <li> {@link  libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH }
281   * <li> {@link  libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH }
282   * <li> {@link  libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH }
283   * </ul>
284   */ public
285 int setReplacedBy(ReplacedBy replacedBy) {
286    return libsbmlJNI.CompSBasePlugin_setReplacedBy(swigCPtr, this, ReplacedBy.getCPtr(replacedBy), replacedBy);
287  }
288
289  
290/**
291   * Creates a new, empty {@link ReplacedBy}, adds it to this {@link CompSBasePlugin} and 
292   * returns the created {@link ReplacedBy}.
293   <p>
294   * @return the newly created {@link ReplacedBy} object instance
295   */ public
296 ReplacedBy createReplacedBy() {
297    long cPtr = libsbmlJNI.CompSBasePlugin_createReplacedBy(swigCPtr, this);
298    return (cPtr == 0) ? null : new ReplacedBy(cPtr, false);
299  }
300
301  
302/**
303   * Unsets the child {@link ReplacedBy} of this {@link SBase}.
304   <p>
305   * @return integer value indicating success/failure of the
306   * operation. The possible return values are:
307   * <ul>
308   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
309   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
310   * </ul>
311   */ public
312 int unsetReplacedBy() {
313    return libsbmlJNI.CompSBasePlugin_unsetReplacedBy(swigCPtr, this);
314  }
315
316  
317/**
318   * Helper to log a common type of error.
319   */ public
320 void logInvalidId(String attribute, String wrongattribute) {
321    libsbmlJNI.CompSBasePlugin_logInvalidId(swigCPtr, this, attribute, wrongattribute);
322  }
323
324  
325/**
326   * Sets the *parent* of this SBML object to child SBML objects (if any).
327   * (Creates a child-parent relationship by the parent)
328   <p>
329   * @see setSBMLDocument
330   * @see enablePackageInternal
331   * @internal
332   */ public
333 void connectToChild() {
334    libsbmlJNI.CompSBasePlugin_connectToChild(swigCPtr, this);
335  }
336
337  
338/**
339   * Sets the parent SBML object of this SBML object.
340   * (Creates a child-parent relationship by the child)
341   * This function is called when a child element is
342   * set/added/created by its parent element (e.g. by setXXX,
343   * addXXX, createXXX, and connectToChild functions of the
344   * parent element).
345   <p>
346   * @param parent the SBML object to use
347   * @internal
348   */ public
349 void connectToParent(SBase parent) {
350    libsbmlJNI.CompSBasePlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent);
351  }
352
353  
354/**
355   * Enables/Disables the given package with child elements in this plugin
356   * object (if any).
357   * (This is an internal implementation invoked from
358   *  {@link SBase#enablePackageInternal()} function)
359   <p>
360   * @note Subclasses in which one or more {@link SBase} derived elements are
361   * defined must override this function.
362   <p>
363   * @see setSBMLDocument
364   * @see connectToParent
365   * @internal
366   */ public
367 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
368    libsbmlJNI.CompSBasePlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
369  }
370
371}