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 3 <a href='../../../extensions-summary.html#groups'>Groups</a> (“groups”) package. This extension 018 * allows a {@link Model} to contain an optional {@link ListOfGroups} object inside a new 019 * element called <code><listOfGroups></code>. This list holds the 020 * definition of optional groups defined in the model. 021 <p> 022 * A 'group' in SBML Level 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 * @param uri a string, representing the URI of the package. 079 <p> 080 * @param prefix a string, the prefix to be used. 081 <p> 082 * @param groupsns a pointer to the {@link GroupsPkgNamespaces} object to be used. 083 */ public 084 GroupsModelPlugin(String uri, String prefix, GroupsPkgNamespaces groupsns) { 085 this(libsbmlJNI.new_GroupsModelPlugin__SWIG_0(uri, prefix, GroupsPkgNamespaces.getCPtr(groupsns), groupsns), true); 086 } 087 088 089/** 090 * Copy constructor for {@link GroupsModelPlugin}. 091 <p> 092 * @param orig the {@link GroupsModelPlugin} instance to copy. 093 */ public 094 GroupsModelPlugin(GroupsModelPlugin orig) { 095 this(libsbmlJNI.new_GroupsModelPlugin__SWIG_1(GroupsModelPlugin.getCPtr(orig), orig), true); 096 } 097 098 099/** 100 * Creates and returns a deep copy of this {@link GroupsModelPlugin} object. 101 <p> 102 * @return a (deep) copy of this {@link GroupsModelPlugin} object. 103 */ public 104 SBasePlugin cloneObject() { 105 long cPtr = libsbmlJNI.GroupsModelPlugin_cloneObject(swigCPtr, this); 106 return (cPtr == 0) ? null : new GroupsModelPlugin(cPtr, true); 107 } 108 109 110/** 111 * Returns the {@link ListOfGroups} from this {@link GroupsModelPlugin}. 112 <p> 113 * @return the {@link ListOfGroups} from this {@link GroupsModelPlugin}. 114 <p> 115 * @see #addGroup(Group g) 116 * @see #createGroup() 117 * @see #getGroup(String sid) 118 * @see #getGroup(long n) 119 * @see #getNumGroups() 120 * @see #removeGroup(long n) 121 * @see #removeGroup(String sid) 122 */ public 123 ListOfGroups getListOfGroups() { 124 long cPtr = libsbmlJNI.GroupsModelPlugin_getListOfGroups__SWIG_0(swigCPtr, this); 125 return (cPtr == 0) ? null : new ListOfGroups(cPtr, false); 126 } 127 128 129/** 130 * Returns the nth {@link Group}. 131 <p> 132 * @param n a long integer representing the index of the {@link Group} to retrieve. 133 <p> 134 * @return the nth {@link Group} in the {@link ListOfGroups} within this {@link GroupsModelPlugin}. 135 <p> 136 * @see #addGroup(Group g) 137 * @see #createGroup() 138 * @see #getGroup(String sid) 139 * @see #getGroup(long n) 140 * @see #getNumGroups() 141 * @see #removeGroup(long n) 142 * @see #removeGroup(String sid) 143 */ public 144 Group getGroup(long n) { 145 long cPtr = libsbmlJNI.GroupsModelPlugin_getGroup__SWIG_0(swigCPtr, this, n); 146 return (cPtr == 0) ? null : new Group(cPtr, false); 147 } 148 149 150/** 151 * Get a {@link Group} from the {@link GroupsModelPlugin} based on its identifier. 152 <p> 153 * @param sid a string representing the identifier of the {@link Group} to retrieve. 154 <p> 155 * @return the {@link Group} in the {@link ListOfGroups} within this {@link GroupsModelPlugin} with 156 * the given identifier <code>sid</code>, or <code>null</code> if no such {@link Group} exists. 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(String sid) { 167 long cPtr = libsbmlJNI.GroupsModelPlugin_getGroup__SWIG_2(swigCPtr, this, sid); 168 return (cPtr == 0) ? null : new Group(cPtr, false); 169 } 170 171 172/** 173 * Adds a copy of the given {@link Group} to this {@link GroupsModelPlugin}. 174 <p> 175 * @param g the {@link Group} object to add. 176 <p> 177 * <p> 178 * @return integer value indicating success/failure of the 179 * function. The possible values 180 * returned by this function are: 181 * <ul> 182 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 183 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 184 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 185 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH} 186 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH} 187 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH} 188 * <li> {@link libsbmlConstants#LIBSBML_DUPLICATE_OBJECT_ID LIBSBML_DUPLICATE_OBJECT_ID} 189 * 190 * </ul> <p> 191 * <p> 192 * @note This method should be used with some caution. The fact that this 193 * method <em>copies</em> the object passed to it means that the caller will be 194 * left holding a physically different object instance than the one contained 195 * inside this object. Changes made to the original object instance (such as 196 * resetting attribute values) will <em>not affect the instance in this 197 * object</em>. In addition, the caller should make sure to free the 198 * original object if it is no longer being used, or else a memory leak will 199 * result. Please see other methods on this class (particularly a 200 * corresponding method whose name begins with the word <code>create</code>) 201 * for alternatives that do not lead to these issues. 202 <p> 203 * @see #createGroup() 204 * @see #getGroup(String sid) 205 * @see #getGroup(long n) 206 * @see #getNumGroups() 207 * @see #removeGroup(long n) 208 * @see #removeGroup(String sid) 209 */ public 210 int addGroup(Group g) { 211 return libsbmlJNI.GroupsModelPlugin_addGroup(swigCPtr, this, Group.getCPtr(g), g); 212 } 213 214 215/** 216 * Get the number of {@link Group} objects in this {@link GroupsModelPlugin}. 217 <p> 218 * @return the number of {@link Group} objects in this {@link GroupsModelPlugin}. 219 <p> 220 * @see #createGroup() 221 * @see #getGroup(String sid) 222 * @see #getGroup(long n) 223 * @see #removeGroup(long n) 224 * @see #removeGroup(String sid) 225 */ public 226 long getNumGroups() { 227 return libsbmlJNI.GroupsModelPlugin_getNumGroups(swigCPtr, this); 228 } 229 230 231/** 232 * Creates a new {@link Group} object 233 <p> 234 * This method creates a new {@link Group} object, adds it to this 235 * {@link GroupsModelPlugin} object, and returns the {@link Group} object created. 236 <p> 237 * @return a new {@link Group} object instance. 238 <p> 239 * @see #addGroup(Group g) 240 * @see #getGroup(String sid) 241 * @see #getGroup(long n) 242 * @see #removeGroup(long n) 243 * @see #removeGroup(String sid) 244 */ public 245 Group createGroup() { 246 long cPtr = libsbmlJNI.GroupsModelPlugin_createGroup(swigCPtr, this); 247 return (cPtr == 0) ? null : new Group(cPtr, false); 248 } 249 250 251/** 252 * Removes the nth {@link Group}. 253 <p> 254 * This removes the nth {@link Group} from this {@link GroupsModelPlugin} object and 255 * returns a pointer to it. 256 <p> 257 * @param n a long integer representing the index of the {@link Group} to remove. 258 <p> 259 * @return a pointer to the nth {@link Group} in this {@link GroupsModelPlugin}. 260 <p> 261 * @note The caller owns the returned object and is responsible for deleting 262 * it. 263 <p> 264 * @see #addGroup(Group g) 265 * @see #createGroup() 266 * @see #getGroup(String sid) 267 * @see #getGroup(long n) 268 * @see #getNumGroups() 269 * @see #removeGroup(String sid) 270 */ public 271 Group removeGroup(long n) { 272 long cPtr = libsbmlJNI.GroupsModelPlugin_removeGroup__SWIG_0(swigCPtr, this, n); 273 return (cPtr == 0) ? null : new Group(cPtr, true); 274 } 275 276 277/** 278 * Removes the {@link Group} from this {@link GroupsModelPlugin} based on its identifier. 279 <p> 280 * This method removes the {@link Group} from this {@link GroupsModelPlugin} based on its 281 * identifier, and returns a pointer to it. 282 <p> 283 * @param sid a string representing the identifier of the {@link Group} to remove. 284 <p> 285 * @return the {@link Group} in this {@link GroupsModelPlugin} based on the identifier, or 286 * <code>@c</code> null if no such {@link Group} exists. 287 <p> 288 * @note The caller owns the returned object and is responsible for deleting 289 * it. 290 <p> 291 * @see #addGroup(Group g) 292 * @see #createGroup() 293 * @see #getGroup(String sid) 294 * @see #getGroup(long n) 295 * @see #getNumGroups() 296 */ public 297 Group removeGroup(String sid) { 298 long cPtr = libsbmlJNI.GroupsModelPlugin_removeGroup__SWIG_1(swigCPtr, this, sid); 299 return (cPtr == 0) ? null : new Group(cPtr, true); 300 } 301 302 303/** * @internal */ public 304 void connectToChild() { 305 libsbmlJNI.GroupsModelPlugin_connectToChild(swigCPtr, this); 306 } 307 308 309/** * @internal */ public 310 void connectToParent(SBase base) { 311 libsbmlJNI.GroupsModelPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(base), base); 312 } 313 314 315/** * @internal */ public 316 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 317 libsbmlJNI.GroupsModelPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 318 } 319 320 321/** 322 * Returns the first child element that has the given <code>id</code> 323 <p> 324 * This method searches the model-wide SId namespace for the <code>id</code>. 325 <p> 326 * @param id a string representing the id attribute of the object to 327 * retrieve. 328 <p> 329 * @return a pointer to the {@link SBase} element with the given <code>id</code>. If no such 330 * object is found, this method returns <code>null.</code> 331 */ public 332 SBase getElementBySId(String id) { 333 return libsbml.DowncastSBase(libsbmlJNI.GroupsModelPlugin_getElementBySId(swigCPtr, this, id), false); 334} 335 336 337/** 338 * Returns the first child element that has the given <code>metaid</code>. 339 <p> 340 * @param metaid a string representing the metaid attribute of the object to 341 * retrieve. 342 <p> 343 * @return a pointer to the {@link SBase} element with the given <code>metaid</code>. If 344 * no such object is found, this method returns <code>null.</code> 345 */ public 346 SBase getElementByMetaId(String metaid) { 347 return libsbml.DowncastSBase(libsbmlJNI.GroupsModelPlugin_getElementByMetaId(swigCPtr, this, metaid), false); 348} 349 350 351/** * @internal */ public 352 int appendFrom(Model model) { 353 return libsbmlJNI.GroupsModelPlugin_appendFrom(swigCPtr, this, Model.getCPtr(model), model); 354 } 355 356 357/** 358 * For nested groups (Member objects that reference a {@link ListOfMembers} 359 * object), {@link SBO} terms, Notes, and Annotation from the 360 * parent {@link ListOfMembers} applies to the child. This function 361 * copies any information from any of those three things to all 362 * child {@link ListOfMembers}, and if that information is not already 363 * set. After calling 364 * this function, it is sufficient to check any {@link ListOfMembers} 365 * to see if its {@link SBO} term, Notes, or Annotation is set, without 366 * further checking to see if that element was nested in another 367 * {@link Group}. 368 */ public 369 void copyInformationToNestedLists() { 370 libsbmlJNI.GroupsModelPlugin_copyInformationToNestedLists(swigCPtr, this); 371 } 372 373}