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