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 “comp” package 014 * extention to the SBMLDocument construct. 015 <p> 016 * The {@link CompSBMLDocumentPlugin} class inherits from the {@link SBMLDocumentPlugin} 017 * class, and codifies the extentions to the {@link SBMLDocument} class defined in 018 * the SBML Level 3 019 * 'Hierarchical Model Composition' 020 * package (“comp”). This extention allows multiple {@link Model} 021 * objects to be defined in a single {@link SBMLDocument}, stored in an optional 022 * child {@link ListOfModelDefinitions} object, as well as define references to {@link Model} 023 * objects in other files, stored in the optional child 024 * {@link ListOfExternalModelDefinitions} object. These model definitions, if 025 * present, allow {@link Submodel} objects to reference other Models to instantiate. 026 <p> 027 * The presence of ModelDefinitions and ExternalModelDefinitions in an 028 * {@link SBMLDocument} does not change the default {@link Model} in the file. If a 029 * {@link SBMLDocument} is submitted somewhere to be simulated, it is still the 030 * <code><model></code> child of the <code><sbml></code> element 031 * that should be simulated. 032 <p> 033 * In addition, as all packages do, the {@link CompSBMLDocumentPlugin} defines a 034 * required flag named <code>required</code>, which indicates whether 035 * “comp” constructs can be used to change the core mathematics of the 036 * <code><model></code> child of the <code><sbml></code> element. 037 * Because they can, this attribute must be set <code>true.</code> 038 */ 039 040public class CompSBMLDocumentPlugin extends SBMLDocumentPlugin { 041 private long swigCPtr; 042 043 protected CompSBMLDocumentPlugin(long cPtr, boolean cMemoryOwn) 044 { 045 super(libsbmlJNI.CompSBMLDocumentPlugin_SWIGUpcast(cPtr), cMemoryOwn); 046 swigCPtr = cPtr; 047 } 048 049 protected static long getCPtr(CompSBMLDocumentPlugin obj) 050 { 051 return (obj == null) ? 0 : obj.swigCPtr; 052 } 053 054 protected static long getCPtrAndDisown (CompSBMLDocumentPlugin obj) 055 { 056 long ptr = 0; 057 058 if (obj != null) 059 { 060 ptr = obj.swigCPtr; 061 obj.swigCMemOwn = false; 062 } 063 064 return ptr; 065 } 066 067 protected void finalize() { 068 delete(); 069 } 070 071 public synchronized void delete() { 072 if (swigCPtr != 0) { 073 if (swigCMemOwn) { 074 swigCMemOwn = false; 075 libsbmlJNI.delete_CompSBMLDocumentPlugin(swigCPtr); 076 } 077 swigCPtr = 0; 078 } 079 super.delete(); 080 } 081 082 083/** 084 * Constructor. 085 */ public 086 CompSBMLDocumentPlugin(String uri, String prefix, CompPkgNamespaces compns) { 087 this(libsbmlJNI.new_CompSBMLDocumentPlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true); 088 } 089 090 091/** 092 * Copy constructor. Creates a copy of this {@link CompSBMLDocumentPlugin} object. 093 */ public 094 CompSBMLDocumentPlugin(CompSBMLDocumentPlugin orig) { 095 this(libsbmlJNI.new_CompSBMLDocumentPlugin__SWIG_1(CompSBMLDocumentPlugin.getCPtr(orig), orig), true); 096 } 097 098 099/** 100 * Creates and returns a deep copy of this {@link CompSBMLDocumentPlugin} object. 101 <p> 102 * @return a (deep) copy of this {@link CompSBMLDocumentPlugin} object 103 */ public 104 SBasePlugin cloneObject() { 105 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_cloneObject(swigCPtr, this); 106 return (cPtr == 0) ? null : new CompSBMLDocumentPlugin(cPtr, true); 107 } 108 109 110/** 111 * Returns the first child element found that has the given <code>id</code> in the 112 * model-wide SId namespace, or <code>null</code> if no such object is found. 113 <p> 114 * @param id string representing the identifier of objects to find 115 <p> 116 * @return a pointer to the {@link SBase} element with the given <code>id</code>. 117 <p> 118 * @note The comp SBML document plugin has multiple model-wide SId 119 * namespaces, so a valid document may well contain multiple elements with 120 * the same SId that reside in separate models. It is not recommended to 121 * ever call this function—instead, call the function on the child 122 * {@link ModelDefinition} objects. 123 */ public 124 SBase getElementBySId(String id) { 125 return libsbml.DowncastSBase(libsbmlJNI.CompSBMLDocumentPlugin_getElementBySId(swigCPtr, this, id), false); 126} 127 128 129/** 130 * Returns the first child element it can find with the given <code>metaid</code>, or 131 * itself if it has the given <code>metaid</code>, or <code>null</code> if no such object is 132 * found. 133 <p> 134 * @param metaid string representing the meta identifier of objects to find 135 <p> 136 * @return a pointer to the {@link SBase} element with the given <code>metaid</code>. 137 */ public 138 SBase getElementByMetaId(String metaid) { 139 return libsbml.DowncastSBase(libsbmlJNI.CompSBMLDocumentPlugin_getElementByMetaId(swigCPtr, this, metaid), false); 140} 141 142 143/** 144 * Create and return an SBML object of this class, if present. 145 <p> 146 * @return the SBML object corresponding to next {@link XMLToken} in the 147 * {@link XMLInputStream} or <code>null</code> if the token was not recognized. 148 * @internal 149 */ public 150 SBase createObject(XMLInputStream stream) { 151 return libsbml.DowncastSBase(libsbmlJNI.CompSBMLDocumentPlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false); 152} 153 154 155/** * @internal */ public 156 boolean isCompFlatteningImplemented() { 157 return libsbmlJNI.CompSBMLDocumentPlugin_isCompFlatteningImplemented(swigCPtr, this); 158 } 159 160 161/** 162 * Check consistency function. 163 * @internal 164 */ public 165 long checkConsistency() { 166 return libsbmlJNI.CompSBMLDocumentPlugin_checkConsistency(swigCPtr, this); 167 } 168 169 170/** 171 * Returns the {@link ListOf} object that holds all ModelDefinitions. 172 <p> 173 * @return the {@link ListOf} object that holds all ModelDefinitions. 174 */ public 175 ListOfModelDefinitions getListOfModelDefinitions() { 176 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getListOfModelDefinitions(swigCPtr, this); 177 return (cPtr == 0) ? null : new ListOfModelDefinitions(cPtr, false); 178 } 179 180 181/** 182 * Returns the {@link ModelDefinition} with the given index. 183 <p> 184 * @param n the index number of the {@link ModelDefinition} to get. 185 <p> 186 * @return the nth {@link ModelDefinition} in the {@link ListOfModelDefinitions}. If the 187 * index is invalid, <code>null</code> is returned. 188 */ public 189 ModelDefinition getModelDefinition(long n) { 190 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getModelDefinition__SWIG_0(swigCPtr, this, n); 191 return (cPtr == 0) ? null : new ModelDefinition(cPtr, false); 192 } 193 194 195/** 196 * Returns the model definition object based on its identifier. 197 <p> 198 * @param sid a string representing the identifier 199 * of the model definition to get. 200 <p> 201 * @return {@link ModelDefinition} in the {@link ListOfModelDefinitions} with the given <code>sid</code> 202 * or <code>null</code> if no such {@link ModelDefinition} exists. 203 <p> 204 * @see #getModelDefinition(long n) 205 * @see #getListOfModelDefinitions() 206 */ public 207 ModelDefinition getModelDefinition(String sid) { 208 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getModelDefinition__SWIG_2(swigCPtr, this, sid); 209 return (cPtr == 0) ? null : new ModelDefinition(cPtr, false); 210 } 211 212 213/** 214 * Adds a copy of the given {@link ModelDefinition} object to the list of 215 * ModelDefinitions. 216 <p> 217 * @param modelDefinition the {@link ModelDefinition} object to be added to the 218 * list of ModelDefinitions. Fails if the added {@link ModelDefinition} is <code>null</code>, 219 * does not match the level/version/package of the parent object, or cannot 220 * be added to the list of replaced elements. 221 <p> 222 * @return integer value indicating success/failure of the 223 * operation. The possible return values are: 224 * <ul> 225 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 226 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 227 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH } 228 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 229 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 230 * </ul> 231 */ public 232 int addModelDefinition(ModelDefinition modelDefinition) { 233 return libsbmlJNI.CompSBMLDocumentPlugin_addModelDefinition(swigCPtr, this, ModelDefinition.getCPtr(modelDefinition), modelDefinition); 234 } 235 236 237/** 238 * Returns the number of ModelDefinitions for this {@link SBMLDocumentPlugin}. 239 <p> 240 * @return the number of ModelDefinitions. 241 */ public 242 long getNumModelDefinitions() { 243 return libsbmlJNI.CompSBMLDocumentPlugin_getNumModelDefinitions(swigCPtr, this); 244 } 245 246 247/** 248 * Creates a {@link ModelDefinition} object, adds it to the end of the 249 * {@link ModelDefinition} objects list and returns a pointer to the newly 250 * created object. 251 <p> 252 * @return a newly created {@link ModelDefinition} object 253 */ public 254 ModelDefinition createModelDefinition() { 255 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_createModelDefinition(swigCPtr, this); 256 return (cPtr == 0) ? null : new ModelDefinition(cPtr, false); 257 } 258 259 260/** 261 * Removes the {@link ModelDefinition} with the given index from the {@link CompSBMLDocumentPlugin}. 262 <p> 263 * A pointer to the {@link ModelDefinition} that was removed is returned. 264 * If no {@link ModelDefinition} has been removed, <code>null</code> is returned. 265 <p> 266 * @param index the index of the {@link ModelDefinition} object to remove 267 <p> 268 * @return the {@link ModelDefinition} object removed. As mentioned above, 269 * the caller owns the returned object. <code>null</code> is returned if 270 * the given index is out of range. 271 */ public 272 ModelDefinition removeModelDefinition(long index) { 273 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_removeModelDefinition__SWIG_0(swigCPtr, this, index); 274 return (cPtr == 0) ? null : new ModelDefinition(cPtr, false); 275 } 276 277 278/** 279 * Removes the {@link ModelDefinition} with the given <code>id</code> from the {@link CompSBMLDocumentPlugin}. 280 <p> 281 * A pointer to the {@link ModelDefinition} that was removed is returned. 282 * If no {@link ModelDefinition} has been removed, <code>null</code> is returned. 283 <p> 284 * @param id the id of the {@link ModelDefinition} object to remove 285 <p> 286 * @return the {@link ModelDefinition} object removed. As mentioned above, 287 * the caller owns the returned object. <code>null</code> is returned if 288 * the given index is out of range. 289 */ public 290 ModelDefinition removeModelDefinition(String id) { 291 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_removeModelDefinition__SWIG_1(swigCPtr, this, id); 292 return (cPtr == 0) ? null : new ModelDefinition(cPtr, false); 293 } 294 295 296/** 297 * Returns the {@link ListOf} object that holds all ExternalModelDefinitions. 298 <p> 299 * @return the {@link ListOf} object that holds all ExternalModelDefinitions. 300 */ public 301 ListOfExternalModelDefinitions getListOfExternalModelDefinitions() { 302 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getListOfExternalModelDefinitions(swigCPtr, this); 303 return (cPtr == 0) ? null : new ListOfExternalModelDefinitions(cPtr, false); 304 } 305 306 307/** 308 * Returns the {@link ExternalModelDefinition} with the given index. 309 <p> 310 * @param n the index number of the {@link ExternalModelDefinition} to get. 311 <p> 312 * @return the nth {@link ExternalModelDefinition} in the 313 * {@link ListOfExternalModelDefinitions}. If the index is invalid, <code>null</code> is 314 * returned. 315 */ public 316 ExternalModelDefinition getExternalModelDefinition(long n) { 317 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getExternalModelDefinition__SWIG_0(swigCPtr, this, n); 318 return (cPtr == 0) ? null : new ExternalModelDefinition(cPtr, false); 319 } 320 321 322/** 323 * Returns the model definition object based on its identifier. 324 <p> 325 * @param sid a string representing the identifier 326 * of the model definition to get. 327 <p> 328 * @return {@link ExternalModelDefinition} in the {@link ListOfExternalModelDefinitions} with the given <code>sid</code> 329 * or <code>null</code> if no such {@link ExternalModelDefinition} exists. 330 <p> 331 * @see #getExternalModelDefinition(long n) 332 * @see #getListOfExternalModelDefinitions() 333 */ public 334 ExternalModelDefinition getExternalModelDefinition(String sid) { 335 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_getExternalModelDefinition__SWIG_2(swigCPtr, this, sid); 336 return (cPtr == 0) ? null : new ExternalModelDefinition(cPtr, false); 337 } 338 339 340/** 341 * Searches the model namespace of the document and returns the {@link Model}, 342 * {@link ModelDefinition}, or ExternalModelDefintion object with the given 343 * identifier. 344 <p> 345 * @param sid a string representing the identifier of the model definition to get. 346 <p> 347 * @return The {@link SBase} corresponding to the given <code>sid</code> or <code>null</code> if no such 348 * model exists. If no such model exists, this will return <code>null.</code> 349 */ public 350 SBase getModel(String sid) { 351 return libsbml.DowncastSBase(libsbmlJNI.CompSBMLDocumentPlugin_getModel__SWIG_0(swigCPtr, this, sid), false); 352} 353 354 355/** 356 <p> 357 * Sets the boolean value of 'required' attribute of corresponding package 358 * in {@link SBMLDocument} element. The only legal value is 'true' for the 359 * Hierarchical {@link Model} Composition package. 360 <p> 361 * @param value the boolean value of 'required' attribute of corresponding 362 * package in {@link SBMLDocument} element. 363 <p> 364 * @return integer value indicating success/failure of the 365 * function. The possible values 366 * returned by this function are: 367 * <ul> 368 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 369 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE } 370 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE } 371 * </ul> 372 */ public 373 int setRequired(boolean value) { 374 return libsbmlJNI.CompSBMLDocumentPlugin_setRequired(swigCPtr, this, value); 375 } 376 377 378/** 379 * Adds a copy of the given {@link ExternalModelDefinition} object to the list of 380 * ExternalModelDefinitions. 381 <p> 382 * @param externalModelDefinition the {@link ExternalModelDefinition} object to be 383 * added to the list of ExternalModelDefinitions. Fails if the added 384 * {@link ExternalModelDefinition} is <code>null</code>, does not match the 385 * level/version/package of the parent object, or cannot be added to the 386 * list of external model definitions. 387 <p> 388 * @return integer value indicating success/failure of the 389 * operation. The possible return values are: 390 * <ul> 391 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 392 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 393 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH } 394 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 395 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 396 * </ul> 397 */ public 398 int addExternalModelDefinition(ExternalModelDefinition externalModelDefinition) { 399 return libsbmlJNI.CompSBMLDocumentPlugin_addExternalModelDefinition(swigCPtr, this, ExternalModelDefinition.getCPtr(externalModelDefinition), externalModelDefinition); 400 } 401 402 403/** 404 * Returns the number of ExternalModelDefinitions for this {@link SBMLDocumentPlugin}. 405 <p> 406 * @return the number of ExternalModelDefinitions for this {@link SBMLDocumentPlugin}. 407 */ public 408 long getNumExternalModelDefinitions() { 409 return libsbmlJNI.CompSBMLDocumentPlugin_getNumExternalModelDefinitions(swigCPtr, this); 410 } 411 412 413/** 414 * Creates a {@link ExternalModelDefinition} object, adds it to the end of the 415 * {@link ExternalModelDefinition} objects list and returns a pointer to the newly 416 * created object. 417 <p> 418 * @return a newly created {@link ExternalModelDefinition} object 419 */ public 420 ExternalModelDefinition createExternalModelDefinition() { 421 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_createExternalModelDefinition(swigCPtr, this); 422 return (cPtr == 0) ? null : new ExternalModelDefinition(cPtr, false); 423 } 424 425 426/** 427 * Removes the {@link ExternalModelDefinition} with the given index. 428 <p> 429 * A pointer to the {@link ExternalModelDefinition} that was removed is returned. 430 * If no {@link ExternalModelDefinition} has been removed, <code>null</code> is returned. 431 <p> 432 * @param index the index of the {@link ExternalModelDefinition} object to remove 433 <p> 434 * @return the {@link ExternalModelDefinition} object removed. As mentioned above, 435 * the caller owns the returned object. <code>null</code> is returned if 436 * the given index is out of range. 437 */ public 438 ExternalModelDefinition removeExternalModelDefinition(long index) { 439 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_removeExternalModelDefinition__SWIG_0(swigCPtr, this, index); 440 return (cPtr == 0) ? null : new ExternalModelDefinition(cPtr, false); 441 } 442 443 444/** 445 * Removes the {@link ExternalModelDefinition} with the given <code>id</code>. 446 <p> 447 * A pointer to the {@link ExternalModelDefinition} that was removed is returned. 448 * If no {@link ExternalModelDefinition} has been removed, <code>null</code> is returned. 449 <p> 450 * @param id the id of the {@link ExternalModelDefinition} object to remove 451 <p> 452 * @return the {@link ExternalModelDefinition} object removed. As mentioned above, 453 * the caller owns the returned object. <code>null</code> is returned if 454 * the given index is out of range. 455 */ public 456 ExternalModelDefinition removeExternalModelDefinition(String id) { 457 long cPtr = libsbmlJNI.CompSBMLDocumentPlugin_removeExternalModelDefinition__SWIG_1(swigCPtr, this, id); 458 return (cPtr == 0) ? null : new ExternalModelDefinition(cPtr, false); 459 } 460 461 462/** 463 * Sets the *parent* of this SBML object to child SBML objects (if any). 464 * (Creates a child-parent relationship by the parent) 465 <p> 466 * @see setSBMLDocument 467 * @see enablePackageInternal 468 * @internal 469 */ public 470 void connectToChild() { 471 libsbmlJNI.CompSBMLDocumentPlugin_connectToChild(swigCPtr, this); 472 } 473 474 475/** 476 * Sets the parent SBML object of this SBML object. 477 * (Creates a child-parent relationship by the child) 478 * This function is called when a child element is 479 * set/added/created by its parent element (e.g. by setXXX, 480 * addXXX, createXXX, and connectToChild functions of the 481 * parent element). 482 <p> 483 * @param parent the SBML object to use 484 * @internal 485 */ public 486 void connectToParent(SBase parent) { 487 libsbmlJNI.CompSBMLDocumentPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent); 488 } 489 490 491/** 492 * Enables/Disables the given package with child elements in this plugin 493 * object (if any). 494 * (This is an internal implementation invoked from 495 * {@link SBase#enablePackageInternal()} function) 496 <p> 497 * @note Subclasses in which one or more {@link SBase} derived elements are 498 * defined must override this function. 499 <p> 500 * @see setSBMLDocument 501 * @see connectToParent 502 * @internal 503 */ public 504 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 505 libsbmlJNI.CompSBMLDocumentPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 506 } 507 508 509/** * @internal */ public 510 boolean getOverrideCompFlattening() { 511 return libsbmlJNI.CompSBMLDocumentPlugin_getOverrideCompFlattening(swigCPtr, this); 512 } 513 514 515/** * @internal */ public 516 void setOverrideCompFlattening(boolean overrideCompFlattening) { 517 libsbmlJNI.CompSBMLDocumentPlugin_setOverrideCompFlattening(swigCPtr, this, overrideCompFlattening); 518 } 519 520}