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