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-groups"><a href="group__groups.html">groups</a></span>
013 Extension of {@link Model}.
014 <p>
015 * The {@link GroupsModelPlugin} 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#groups'>Groups</a> (&ldquo;groups&rdquo;) package.  This extension
018 * allows a {@link Model} to contain an optional {@link ListOfGroups} object inside a new
019 * element called <code>&lt;listOfGroups&gt;</code>.  This list holds the
020 * definition of optional groups defined in the model.
021 <p>
022 * A 'group' in SBML Level&nbsp;3 provides a mechanism for
023 * indicating that components of an SBML model are related in some way.
024 * Groups may contain either the same or different types of SBML objects, and
025 * groups may be nested if desired. There are no predefined behavioral
026 * semantics associated with groups.  All groups in a given model have to be
027 * defined as {@link Group} objects and included in the {@link ListOfGroups} object attached
028 * to the {@link Model} object containing them.
029 */
030
031public class GroupsModelPlugin extends SBasePlugin {
032   private long swigCPtr;
033
034   protected GroupsModelPlugin(long cPtr, boolean cMemoryOwn)
035   {
036     super(libsbmlJNI.GroupsModelPlugin_SWIGUpcast(cPtr), cMemoryOwn);
037     swigCPtr = cPtr;
038   }
039
040   protected static long getCPtr(GroupsModelPlugin obj)
041   {
042     return (obj == null) ? 0 : obj.swigCPtr;
043   }
044
045   protected static long getCPtrAndDisown (GroupsModelPlugin obj)
046   {
047     long ptr = 0;
048
049     if (obj != null)
050     {
051       ptr             = obj.swigCPtr;
052       obj.swigCMemOwn = false;
053     }
054
055     return ptr;
056   }
057
058  protected void finalize() {
059    delete();
060  }
061
062  public synchronized void delete() {
063    if (swigCPtr != 0) {
064      if (swigCMemOwn) {
065        swigCMemOwn = false;
066        libsbmlJNI.delete_GroupsModelPlugin(swigCPtr);
067      }
068      swigCPtr = 0;
069    }
070    super.delete();
071  }
072
073  
074/**
075   * Creates a new {@link GroupsModelPlugin} using the given URI, prefix and package
076   * namespace.
077   <p>
078   * <p>
079 * In the XML representation of an SBML document, XML namespaces are used to
080 * identify the origin of each XML construct used.  XML namespaces are
081 * identified by their unique resource identifiers (URIs).  The core SBML
082 * specifications stipulate the namespaces that must be used for core SBML
083 * constructs; for example, all XML elements that belong to SBML Level&nbsp;3
084 * Version&nbsp;1 Core must be placed in the XML namespace identified by the URI
085 * <code>'http://www.sbml.org/sbml/level3/version1/core'</code>.  Individual
086 * SBML Level&nbsp;3 packages define their own XML namespaces; for example,
087 * all elements belonging to the SBML Level&nbsp;3 Layout Version&nbsp;1
088 * package must be placed in the XML namespace
089 * <code>'http://www.sbml.org/sbml/level3/version1/layout/version1/'</code>.
090   <p>
091   * <p>
092 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
093 * information.  It is used to communicate the SBML Level, Version, and (in
094 * Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.  A
095 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
096 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object
097 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments.
098   <p>
099   * @param uri the URI of the SBML Level&nbsp;3 package implemented by
100   * this libSBML package extension.
101   <p>
102   * @param prefix the XML namespace prefix being used for the package.
103   <p>
104   * @param groupsns the namespaces object for the package.
105   */ public
106 GroupsModelPlugin(String uri, String prefix, GroupsPkgNamespaces groupsns) {
107    this(libsbmlJNI.new_GroupsModelPlugin__SWIG_0(uri, prefix, GroupsPkgNamespaces.getCPtr(groupsns), groupsns), true);
108  }
109
110  
111/**
112   * Copy constructor for {@link GroupsModelPlugin}.
113   <p>
114   * @param orig the {@link GroupsModelPlugin} instance to copy.
115   */ public
116 GroupsModelPlugin(GroupsModelPlugin orig) {
117    this(libsbmlJNI.new_GroupsModelPlugin__SWIG_1(GroupsModelPlugin.getCPtr(orig), orig), true);
118  }
119
120  
121/**
122   * Creates and returns a deep copy of this {@link GroupsModelPlugin} object.
123   <p>
124   * @return a (deep) copy of this {@link GroupsModelPlugin} object.
125   */ public
126 SBasePlugin cloneObject() {
127    long cPtr = libsbmlJNI.GroupsModelPlugin_cloneObject(swigCPtr, this);
128    return (cPtr == 0) ? null : new GroupsModelPlugin(cPtr, true);
129  }
130
131  
132/**
133   * Returns the {@link ListOfGroups} from this {@link GroupsModelPlugin}.
134   <p>
135   * @return the {@link ListOfGroups} from this {@link GroupsModelPlugin}.
136   <p>
137   * @see #addGroup(Group g)
138   * @see #createGroup()
139   * @see #getGroup(String sid)
140   * @see #getGroup(long n)
141   * @see #getNumGroups()
142   * @see #removeGroup(long n)
143   * @see #removeGroup(String sid)
144   */ public
145 ListOfGroups getListOfGroups() {
146    long cPtr = libsbmlJNI.GroupsModelPlugin_getListOfGroups__SWIG_0(swigCPtr, this);
147    return (cPtr == 0) ? null : new ListOfGroups(cPtr, false);
148  }
149
150  
151/**
152   * Returns the nth {@link Group}.
153   <p>
154   * @param n a long integer representing the index of the {@link Group} to retrieve.
155   <p>
156   * @return the nth {@link Group} in the {@link ListOfGroups} within this {@link GroupsModelPlugin}.
157   <p>
158   * @see #addGroup(Group g)
159   * @see #createGroup()
160   * @see #getGroup(String sid)
161   * @see #getGroup(long n)
162   * @see #getNumGroups()
163   * @see #removeGroup(long n)
164   * @see #removeGroup(String sid)
165   */ public
166 Group getGroup(long n) {
167    long cPtr = libsbmlJNI.GroupsModelPlugin_getGroup__SWIG_0(swigCPtr, this, n);
168    return (cPtr == 0) ? null : new Group(cPtr, false);
169  }
170
171  
172/**
173   * Get a {@link Group} from the {@link GroupsModelPlugin} based on its identifier.
174   <p>
175   * @param sid a string representing the identifier of the {@link Group} to retrieve.
176   <p>
177   * @return the {@link Group} in the {@link ListOfGroups} within this {@link GroupsModelPlugin} with
178   * the given identifier <code>sid</code>, or <code>null</code> if no such {@link Group} exists.
179   <p>
180   * @see #addGroup(Group g)
181   * @see #createGroup()
182   * @see #getGroup(String sid)
183   * @see #getGroup(long n)
184   * @see #getNumGroups()
185   * @see #removeGroup(long n)
186   * @see #removeGroup(String sid)
187   */ public
188 Group getGroup(String sid) {
189    long cPtr = libsbmlJNI.GroupsModelPlugin_getGroup__SWIG_2(swigCPtr, this, sid);
190    return (cPtr == 0) ? null : new Group(cPtr, false);
191  }
192
193  
194/**
195   * Adds a copy of the given {@link Group} to this {@link GroupsModelPlugin}.
196   <p>
197   * @param g the {@link Group} object to add.
198   <p>
199   * <p>
200 * @return integer value indicating success/failure of the
201 * function.   The possible values
202 * returned by this function are:
203   * <ul>
204   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
205   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
206   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
207   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
208   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
209   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
210   * <li> {@link libsbmlConstants#LIBSBML_DUPLICATE_OBJECT_ID LIBSBML_DUPLICATE_OBJECT_ID}
211   *
212   * </ul> <p>
213   * <p>
214 * @note This method should be used with some caution.  The fact that this
215 * method <em>copies</em> the object passed to it means that the caller will be
216 * left holding a physically different object instance than the one contained
217 * inside this object.  Changes made to the original object instance (such as
218 * resetting attribute values) will <em>not affect the instance in this
219 * object</em>.  In addition, the caller should make sure to free the
220 * original object if it is no longer being used, or else a memory leak will
221 * result.  Please see other methods on this class (particularly a
222 * corresponding method whose name begins with the word <code>create</code>)
223 * for alternatives that do not lead to these issues.
224   <p>
225   * @see #createGroup()
226   * @see #getGroup(String sid)
227   * @see #getGroup(long n)
228   * @see #getNumGroups()
229   * @see #removeGroup(long n)
230   * @see #removeGroup(String sid)
231   */ public
232 int addGroup(Group g) {
233    return libsbmlJNI.GroupsModelPlugin_addGroup(swigCPtr, this, Group.getCPtr(g), g);
234  }
235
236  
237/**
238   * Get the number of {@link Group} objects in this {@link GroupsModelPlugin}.
239   <p>
240   * @return the number of {@link Group} objects in this {@link GroupsModelPlugin}.
241   <p>
242   * @see #createGroup()
243   * @see #getGroup(String sid)
244   * @see #getGroup(long n)
245   * @see #removeGroup(long n)
246   * @see #removeGroup(String sid)
247   */ public
248 long getNumGroups() {
249    return libsbmlJNI.GroupsModelPlugin_getNumGroups(swigCPtr, this);
250  }
251
252  
253/**
254   * Creates a new {@link Group} object
255   <p>
256   * This method creates a new {@link Group} object, adds it to this
257   * {@link GroupsModelPlugin} object, and returns the {@link Group} object created.
258   <p>
259   * @return a new {@link Group} object instance.
260   <p>
261   * @see #addGroup(Group g)
262   * @see #getGroup(String sid)
263   * @see #getGroup(long n)
264   * @see #removeGroup(long n)
265   * @see #removeGroup(String sid)
266   */ public
267 Group createGroup() {
268    long cPtr = libsbmlJNI.GroupsModelPlugin_createGroup(swigCPtr, this);
269    return (cPtr == 0) ? null : new Group(cPtr, false);
270  }
271
272  
273/**
274   * Removes the nth {@link Group}.
275   <p>
276   * This removes the nth {@link Group} from this {@link GroupsModelPlugin} object and
277   * returns a pointer to it.
278   <p>
279   * @param n a long integer representing the index of the {@link Group} to remove.
280   <p>
281   * @return a pointer to the nth {@link Group} in this {@link GroupsModelPlugin}.
282   <p>
283   * @note The caller owns the returned object and is responsible for deleting
284   * it.
285   <p>
286   * @see #addGroup(Group g)
287   * @see #createGroup()
288   * @see #getGroup(String sid)
289   * @see #getGroup(long n)
290   * @see #getNumGroups()
291   * @see #removeGroup(String sid)
292   */ public
293 Group removeGroup(long n) {
294    long cPtr = libsbmlJNI.GroupsModelPlugin_removeGroup__SWIG_0(swigCPtr, this, n);
295    return (cPtr == 0) ? null : new Group(cPtr, true);
296  }
297
298  
299/**
300   * Removes the {@link Group} from this {@link GroupsModelPlugin} based on its identifier.
301   <p>
302   * This method removes the {@link Group} from this {@link GroupsModelPlugin} based on its
303   * identifier, and returns a pointer to it.
304   <p>
305   * @param sid a string representing the identifier of the {@link Group} to remove.
306   <p>
307   * @return the {@link Group} in this {@link GroupsModelPlugin} based on the identifier, or
308   * <code>@c</code> null if no such {@link Group} exists.
309   <p>
310   * @note The caller owns the returned object and is responsible for deleting
311   * it.
312   <p>
313   * @see #addGroup(Group g)
314   * @see #createGroup()
315   * @see #getGroup(String sid)
316   * @see #getGroup(long n)
317   * @see #getNumGroups()
318   */ public
319 Group removeGroup(String sid) {
320    long cPtr = libsbmlJNI.GroupsModelPlugin_removeGroup__SWIG_1(swigCPtr, this, sid);
321    return (cPtr == 0) ? null : new Group(cPtr, true);
322  }
323
324  
325/** * @internal */ public
326 void connectToChild() {
327    libsbmlJNI.GroupsModelPlugin_connectToChild(swigCPtr, this);
328  }
329
330  
331/** * @internal */ public
332 void connectToParent(SBase base) {
333    libsbmlJNI.GroupsModelPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(base), base);
334  }
335
336  
337/** * @internal */ public
338 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
339    libsbmlJNI.GroupsModelPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
340  }
341
342  
343/**
344   * Returns the first child element that has the given <code>id</code>
345   <p>
346   * This method searches the model-wide SId namespace for the <code>id</code>.
347   <p>
348   * @param id a string representing the id attribute of the object to
349   * retrieve.
350   <p>
351   * @return a pointer to the {@link SBase} element with the given <code>id</code>.  If no such
352   * object is found, this method returns <code>null.</code>
353   */ public
354 SBase getElementBySId(String id) {
355  return libsbml.DowncastSBase(libsbmlJNI.GroupsModelPlugin_getElementBySId(swigCPtr, this, id), false);
356}
357
358  
359/**
360   * Returns the first child element that has the given <code>metaid</code>.
361   <p>
362   * @param metaid a string representing the metaid attribute of the object to
363   * retrieve.
364   <p>
365   * @return a pointer to the {@link SBase} element with the given <code>metaid</code>.  If
366   * no such object is found, this method returns <code>null.</code>
367   */ public
368 SBase getElementByMetaId(String metaid) {
369  return libsbml.DowncastSBase(libsbmlJNI.GroupsModelPlugin_getElementByMetaId(swigCPtr, this, metaid), false);
370}
371
372  
373/** * @internal */ public
374 int appendFrom(Model model) {
375    return libsbmlJNI.GroupsModelPlugin_appendFrom(swigCPtr, this, Model.getCPtr(model), model);
376  }
377
378  
379/**
380   * For nested groups (Member objects that reference a {@link ListOfMembers} 
381   * object), {@link SBO} terms, Notes, and Annotation from the
382   * parent {@link ListOfMembers} applies to the child.  This function
383   * copies any information from any of those three things to all 
384   * child {@link ListOfMembers}, and if that information is not already 
385   * set.  After calling
386   * this function, it is sufficient to check any {@link ListOfMembers}
387   * to see if its {@link SBO} term, Notes, or Annotation is set, without
388   * further checking to see if that element was nested in another
389   * {@link Group}.
390   */ public
391 void copyInformationToNestedLists() {
392    libsbmlJNI.GroupsModelPlugin_copyInformationToNestedLists(swigCPtr, this);
393  }
394
395}