001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.0.11 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 * 013 * Representation of a plug-in object of SBML's package extension. 014 * <p> 015 * Additional attributes and/or elements of a package extension which are directly 016 * contained by some pre-defined element are contained/accessed by <a href='#{@link SBasePlugin}'> 017 * {@link SBasePlugin} </a> class which is extended by package developers for each extension point. 018 * The extension point, which represents an element to be extended, is identified by a 019 * combination of a Package name and a typecode of the element, and is represented by 020 * {@link SBaseExtensionPoint} class. 021 * </p> 022 * <p> 023 * <p> 024 * For example, the layout extension defines <em><listOfLayouts></em> element which is 025 * directly contained in <em><model></em> element of the core package. 026 * In the layout package (provided as one of example packages in libSBML-5), the additional 027 * element for the model element is implemented as ListOfLayouts class (an {@link SBase} derived class) and 028 * the object is contained/accessed by a LayoutModelPlugin class (an {@link SBasePlugin} derived class). 029 * </p> 030 * <p> 031 * <p> 032 * {@link SBasePlugin} class defines basic virtual functions for reading/writing/checking 033 * additional attributes and/or top-level elements which should or must be overridden by 034 * subclasses like {@link SBase} class and its derived classes. 035 * </p> 036 * <p> 037 * <p> 038 * Package developers must implement an {@link SBasePlugin} exntended class for 039 * each element to be extended (e.g. {@link SBMLDocument}, {@link Model}, ...) in which additional 040 * attributes and/or top-level elements of the package extension are directly contained. 041 *</p> 042 * <p> 043 * To implement reading/writing functions for attributes and/or top-level 044 * elements of the SBsaePlugin extended class, package developers should or must 045 * override the corresponding virtual functions below provided in the {@link SBasePlugin} class: 046 * <p> 047 * <ul> 048 * <li> <p>reading elements : </p> 049 * <ol> 050 * <li> <code>virtual {@link SBase} createObject (XMLInputStream& stream) </code> 051 * <p>This function must be overridden if one or more additional elements are defined.</p> 052 * </li> 053 * <li> <code>virtual bool readOtherXML (SBase parentObject, XMLInputStream& stream)</code> 054 * <p>This function should be overridden if elements of annotation, notes, MathML, etc. need 055 * to be directly parsed from the given XMLInputStream object instead of the 056 * {@link SBase#readAnnotation(XMLInputStream& stream)} 057 * and/or {@link SBase#readNotes(XMLInputStream& stream)} functions. 058 * </p> 059 * </li> 060 * </ol> 061 * </li> 062 * <li> <p>reading attributes (must be overridden if additional attributes are defined) :</p> 063 * <ol> 064 * <li><code>virtual void addExpectedAttributes(ExpectedAttributes& attributes) </code></li> 065 * <li><code>virtual void readAttributes (XMLAttributes attributes, const ExpectedAttributes& expectedAttributes)</code></li> 066 * </ol> 067 * </li> 068 * <li> <p>writing elements (must be overridden if additional elements are defined) :</p> 069 * <ol> 070 * <li><code>virtual void writeElements (XMLOutputStream& stream) const </code></li> 071 * </ol> 072 * </li> 073 * <li> <p>writing attributes : </p> 074 * <ol> 075 * <li><code>virtual void writeAttributes (XMLOutputStream& stream) const </code> 076 * <p>This function must be overridden if one or more additional attributes are defined.</p> 077 * </li> 078 * <li><code>virtual void writeXMLNS (XMLOutputStream& stream) const </code> 079 * <p>This function must be overridden if one or more additional xmlns attributes are defined.</p> 080 * </li> 081 * </ol> 082 * </li> 083 * <p> 084 * <li> <p>checking elements (should be overridden) :</p> 085 * <ol> 086 * <li><code>virtual bool hasRequiredElements() const </code></li> 087 * </ol> 088 * </li> 089 * <p> 090 * <li> <p>checking attributes (should be overridden) :</p> 091 * <ol> 092 * <li><code>virtual bool hasRequiredAttributes() const </code></li> 093 * </ol> 094 * </li> 095 * </ul> 096 * <p> 097 *<p> 098 * To implement package-specific creating/getting/manipulating functions of the 099 * {@link SBasePlugin} derived class (e.g., getListOfLayouts(), createLyout(), getLayout(), 100 * and etc are implemented in LayoutModelPlugin class of the layout package), package 101 * developers must newly implement such functions (as they like) in the derived class. 102 *</p> 103 * <p> 104 *<p> 105 * {@link SBasePlugin} class defines other virtual functions of internal implementations 106 * such as: 107 * <p> 108 * <ul> 109 * <li><code> virtual void setSBMLDocument(SBMLDocument d) </code> 110 * <li><code> virtual void connectToParent(SBase sbase) </code> 111 * <li><code> virtual void enablePackageInternal(String pkgURI, String pkgPrefix, bool flag) </code> 112 * </ul> 113 * <p> 114 * These functions must be overridden by subclasses in which one or more top-level elements are defined. 115 *</p> 116 * <p> 117 *<p> 118 * For example, the following three {@link SBasePlugin} extended classes are implemented in 119 * the layout extension: 120 *</p> 121 * <p> 122 *<ol> 123 * <p> 124 * <li> <p><a href='class_s_b_m_l_document_plugin.html'> {@link SBMLDocumentPlugin} </a> class for {@link SBMLDocument} element</p> 125 * <p> 126 * <ul> 127 * <li> <em> required </em> attribute is added to {@link SBMLDocument} object. 128 * </li> 129 * </ul> 130 * <p> 131 *<p> 132 *(<a href='class_s_b_m_l_document_plugin.html'> {@link SBMLDocumentPlugin} </a> class is a common {@link SBasePlugin} 133 *extended class for {@link SBMLDocument} class. Package developers can use this class as-is if no additional 134 *elements/attributes (except for <em> required </em> attribute) is needed for the {@link SBMLDocument} class 135 *in their packages, otherwise package developers must implement a new {@link SBMLDocumentPlugin} derived class.) 136 *</p> 137 * <p> 138 * <li> <p>LayoutModelPlugin class for {@link Model} element</p> 139 * <ul> 140 * <li> <listOfLayouts> element is added to {@link Model} object. 141 * </li> 142 * <p> 143 * <li> <p> 144 * The following virtual functions for reading/writing/checking 145 * are overridden: (type of arguments and return values are omitted) 146 * </p> 147 * <ul> 148 * <li> <code> createObject() </code> : (read elements) 149 * </li> 150 * <li> <code> readOtherXML() </code> : (read elements in annotation of SBML L2) 151 * </li> 152 * <li> <code> writeElements() </code> : (write elements) 153 * </li> 154 * </ul> 155 * </li> 156 * <p> 157 * <li> <p> 158 * The following virtual functions of internal implementations 159 * are overridden: (type of arguments and return values are omitted) 160 * </p> 161 * <ul> 162 * <li> <code> setSBMLDocument() </code> 163 * </li> 164 * <li> <code> connectToParent() </code> 165 * </li> 166 * <li> <code> enablePackageInternal() </code> 167 * </li> 168 * </ul> 169 * </li> 170 * <p> 171 * <p> 172 * <li> <p> 173 * The following creating/getting/manipulating functions are newly 174 * implemented: (type of arguments and return values are omitted) 175 * </p> 176 * <ul> 177 * <li> <code> getListOfLayouts() </code> 178 * </li> 179 * <li> <code> getLayout () </code> 180 * </li> 181 * <li> <code> addLayout() </code> 182 * </li> 183 * <li> <code> createLayout() </code> 184 * </li> 185 * <li> <code> removeLayout() </code> 186 * </li> 187 * <li> <code> getNumLayouts() </code> 188 * </li> 189 * </ul> 190 * </li> 191 * <p> 192 * </ul> 193 * </li> 194 * <p> 195 * <li> <p>LayoutSpeciesReferencePlugin class for {@link SpeciesReference} element (used only for SBML L2V1) </p> 196 * <p> 197 * <ul> 198 * <li> 199 * <em> id </em> attribute is internally added to {@link SpeciesReference} object 200 * only for SBML L2V1 201 * </li> 202 * <p> 203 * <li> 204 * The following virtual functions for reading/writing/checking 205 * are overridden: (type of arguments and return values are omitted) 206 * </li> 207 * <p> 208 * <ul> 209 * <li> 210 * <code> readOtherXML() </code> 211 * </li> 212 * <li> 213 * <code> writeAttributes() </code> 214 * </li> 215 * </ul> 216 * </ul> 217 * </li> 218 * <p> 219 * </ol> 220 */ 221 222public class SBasePlugin { 223 private long swigCPtr; 224 protected boolean swigCMemOwn; 225 226 protected SBasePlugin(long cPtr, boolean cMemoryOwn) 227 { 228 swigCMemOwn = cMemoryOwn; 229 swigCPtr = cPtr; 230 } 231 232 protected static long getCPtr(SBasePlugin obj) 233 { 234 return (obj == null) ? 0 : obj.swigCPtr; 235 } 236 237 protected static long getCPtrAndDisown (SBasePlugin obj) 238 { 239 long ptr = 0; 240 241 if (obj != null) 242 { 243 ptr = obj.swigCPtr; 244 obj.swigCMemOwn = false; 245 } 246 247 return ptr; 248 } 249 250 protected void finalize() { 251 delete(); 252 } 253 254 public synchronized void delete() { 255 if (swigCPtr != 0) { 256 if (swigCMemOwn) { 257 swigCMemOwn = false; 258 libsbmlJNI.delete_SBasePlugin(swigCPtr); 259 } 260 swigCPtr = 0; 261 } 262 } 263 264 265/** 266 * Returns the XML namespace (URI) of the package extension 267 * of this plugin object. 268 * <p> 269 * @return the URI of the package extension of this plugin object. 270 */ public 271 String getElementNamespace() { 272 return libsbmlJNI.SBasePlugin_getElementNamespace(swigCPtr, this); 273 } 274 275 276/** 277 * Returns the prefix of the package extension of this plugin object. 278 * <p> 279 * @return the prefix of the package extension of this plugin object. 280 */ public 281 String getPrefix() { 282 return libsbmlJNI.SBasePlugin_getPrefix(swigCPtr, this); 283 } 284 285 286/** 287 * Returns the package name of this plugin object. 288 * <p> 289 * @return the package name of this plugin object. 290 */ public 291 String getPackageName() { 292 return libsbmlJNI.SBasePlugin_getPackageName(swigCPtr, this); 293 } 294 295 296/** 297 * Creates and returns a deep copy of this {@link SBasePlugin} object. 298 * <p> 299 * @return a (deep) copy of this {@link SBase} object 300 */ public 301 SBasePlugin cloneObject() { 302 return libsbml.DowncastSBasePlugin(libsbmlJNI.SBasePlugin_cloneObject(swigCPtr, this), true); 303} 304 305 306/** 307 * Returns the first child element found that has the given <code>id</code> in the model-wide SId namespace, or <code>null</code> if no such object is found. 308 * <p> 309 * @param id string representing the id of objects to find 310 * <p> 311 * @return pointer to the first element found with the given <code>id</code>. 312 */ public 313 SBase getElementBySId(String id) { 314 return libsbml.DowncastSBase(libsbmlJNI.SBasePlugin_getElementBySId(swigCPtr, this, id), false); 315} 316 317 318/** 319 * Returns the first child element it can find with the given <code>metaid</code>, or <code>null</code> if no such object is found. 320 * <p> 321 * @param metaid string representing the metaid of objects to find 322 * <p> 323 * @return pointer to the first element found with the given <code>metaid</code>. 324 */ public 325 SBase getElementByMetaId(String metaid) { 326 return libsbml.DowncastSBase(libsbmlJNI.SBasePlugin_getElementByMetaId(swigCPtr, this, metaid), false); 327} 328 329 330/** 331 * Sets the parent SBML object of this plugin object to 332 * this object and child elements (if any). 333 * (Creates a child-parent relationship by this plugin object) 334 * <p> 335 * This function is called when this object is created by 336 * the parent element. 337 * Subclasses must override this this function if they have one 338 * or more child elements. Also, {@link SBasePlugin#connectToParent(SBase sbase)} 339 * must be called in the overridden function. 340 * <p> 341 * @param sbase the {@link SBase} object to use 342 * <p> 343 * @see setSBMLDocument 344 * @see enablePackageInternal 345 * @internal 346 */ public 347 void connectToParent(SBase sbase) { 348 libsbmlJNI.SBasePlugin_connectToParent(swigCPtr, this, SBase.getCPtr(sbase), sbase); 349 } 350 351 352/** 353 * Enables/Disables the given package with child elements in this plugin 354 * object (if any). 355 * (This is an internal implementation invoked from 356 * {@link SBase#enablePackageInternal()} function) 357 * <p> 358 * Subclasses which contain one or more {@link SBase} derived elements should 359 * override this function if elements defined in them can be extended by 360 * some other package extension. 361 * <p> 362 * @see setSBMLDocument 363 * @see connectToParent 364 * @internal 365 */ public 366 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 367 libsbmlJNI.SBasePlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 368 } 369 370 371/** 372 * Enables/Disables the given package with child elements in this plugin 373 * object (if any). 374 * (This is an internal implementation invoked from 375 * {@link SBase#enablePackageInternal()} function) 376 * <p> 377 * Subclasses which contain one or more {@link SBase} derived elements should 378 * override this function if elements defined in them can be extended by 379 * some other package extension. 380 * <p> 381 * @see setSBMLDocument 382 * @see connectToParent 383 * @internal 384 */ public 385 boolean stripPackage(String pkgPrefix, boolean flag) { 386 return libsbmlJNI.SBasePlugin_stripPackage(swigCPtr, this, pkgPrefix, flag); 387 } 388 389 390/** 391 * Returns the parent {@link SBMLDocument} of this plugin object. 392 * <p> 393 * @return the parent {@link SBMLDocument} object of this plugin object. 394 */ public 395 SBMLDocument getSBMLDocument() { 396 long cPtr = libsbmlJNI.SBasePlugin_getSBMLDocument__SWIG_0(swigCPtr, this); 397 return (cPtr == 0) ? null : new SBMLDocument(cPtr, false); 398 } 399 400 401/** 402 * Gets the URI to which this element belongs to. 403 * For example, all elements that belong to SBML Level 3 Version 1 Core 404 * must would have the URI 'http://www.sbml.org/sbml/level3/version1/core'; 405 * all elements that belong to Layout Extension Version 1 for SBML Level 3 406 * Version 1 Core must would have the URI 407 * 'http://www.sbml.org/sbml/level3/version1/layout/version1/' 408 * <p> 409 * Unlike getElementNamespace, this function first returns the URI for this 410 * element by looking into the {@link SBMLNamespaces} object of the document with 411 * the its package name. if not found it will return the result of 412 * getElementNamespace 413 * <p> 414 * @return the URI this elements 415 * <p> 416 * @see getPackageName 417 * @see getElementNamespace 418 * @see SBMLDocument#getSBMLNamespaces 419 * @see getSBMLDocument 420 */ public 421 String getURI() { 422 return libsbmlJNI.SBasePlugin_getURI(swigCPtr, this); 423 } 424 425 426/** 427 * Returns the parent {@link SBase} object to which this plugin 428 * object connected. 429 * <p> 430 * @return the parent {@link SBase} object to which this plugin 431 * object connected. 432 */ public 433 SBase getParentSBMLObject() { 434 return libsbml.DowncastSBase(libsbmlJNI.SBasePlugin_getParentSBMLObject__SWIG_0(swigCPtr, this), false); 435} 436 437 438/** 439 * Sets the XML namespace to which this element belongs to. 440 * For example, all elements that belong to SBML Level 3 Version 1 Core 441 * must set the namespace to 'http://www.sbml.org/sbml/level3/version1/core'; 442 * all elements that belong to Layout Extension Version 1 for SBML Level 3 443 * Version 1 Core must set the namespace to 444 * 'http://www.sbml.org/sbml/level3/version1/layout/version1/' 445 * <p> 446 * @return integer value indicating success/failure of the 447 * function. The possible values 448 * returned by this function are: 449 * <ul> 450 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 451 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE } 452 * </ul> 453 */ public 454 int setElementNamespace(String uri) { 455 return libsbmlJNI.SBasePlugin_setElementNamespace(swigCPtr, this, uri); 456 } 457 458 459/** 460 * Returns the SBML level of the package extension of 461 * this plugin object. 462 * <p> 463 * @return the SBML level of the package extension of 464 * this plugin object. 465 */ public 466 long getLevel() { 467 return libsbmlJNI.SBasePlugin_getLevel(swigCPtr, this); 468 } 469 470 471/** 472 * Returns the SBML version of the package extension of 473 * this plugin object. 474 * <p> 475 * @return the SBML version of the package extension of 476 * this plugin object. 477 */ public 478 long getVersion() { 479 return libsbmlJNI.SBasePlugin_getVersion(swigCPtr, this); 480 } 481 482 483/** 484 * Returns the package version of the package extension of 485 * this plugin object. 486 * <p> 487 * @return the package version of the package extension of 488 * this plugin object. 489 */ public 490 long getPackageVersion() { 491 return libsbmlJNI.SBasePlugin_getPackageVersion(swigCPtr, this); 492 } 493 494 495/** 496 * If this object has a child 'math' object (or anything with ASTNodes in general), replace all nodes with the name 'id' with the provided function. 497 * <p> 498 * @note This function does nothing itself--subclasses with {@link ASTNode} subelements must override this function. 499 * @internal 500 */ public 501 void replaceSIDWithFunction(String id, ASTNode function) { 502 libsbmlJNI.SBasePlugin_replaceSIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 503 } 504 505 506/** 507 * If the function of this object is to assign a value has a child 'math' object (or anything with ASTNodes in general), replace the 'math' object with the function (existing/function). 508 * <p> 509 * @note This function does nothing itself--subclasses with {@link ASTNode} subelements must override this function. 510 * @internal 511 */ public 512 void divideAssignmentsToSIdByFunction(String id, ASTNode function) { 513 libsbmlJNI.SBasePlugin_divideAssignmentsToSIdByFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 514 } 515 516 517/** 518 * If this assignment assigns a value to the 'id' element, replace the 'math' object with the function (existing*function). 519 * @internal 520 */ public 521 void multiplyAssignmentsToSIdByFunction(String id, ASTNode function) { 522 libsbmlJNI.SBasePlugin_multiplyAssignmentsToSIdByFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 523 } 524 525 526/** 527 * Check to see if the given prefix is used by any of the IDs defined by extension elements. A package that defines its own 'id' attribute for a core element would check that attribute here. 528 * @internal 529 */ public 530 boolean hasIdentifierBeginningWith(String prefix) { 531 return libsbmlJNI.SBasePlugin_hasIdentifierBeginningWith(swigCPtr, this, prefix); 532 } 533 534 535/** 536 * Add the given string to all identifiers in the object. If the string is added to anything other than an id or a metaid, this code is responsible for tracking down and renaming all *idRefs in the package extention that identifier comes from. 537 * @internal 538 */ public 539 int prependStringToAllIdentifiers(String prefix) { 540 return libsbmlJNI.SBasePlugin_prependStringToAllIdentifiers(swigCPtr, this, prefix); 541 } 542 543 544/** 545 * Returns the line number on which this object first appears in the XML 546 * representation of the SBML document. 547 * <p> 548 * @return the line number of the underlying SBML object. 549 * <p> 550 * @note The line number for each construct in an SBML model is set upon 551 * reading the model. The accuracy of the line number depends on the 552 * correctness of the XML representation of the model, and on the 553 * particular XML parser library being used. The former limitation 554 * relates to the following problem: if the model is actually invalid 555 * XML, then the parser may not be able to interpret the data correctly 556 * and consequently may not be able to establish the real line number. 557 * The latter limitation is simply that different parsers seem to have 558 * their own accuracy limitations, and out of all the parsers supported 559 * by libSBML, none have been 100% accurate in all situations. (At this 560 * time, libSBML supports the use of <a target='_blank' 561 * href='http://xmlsoft.org'>libxml2</a>, <a target='_blank' 562 * href='http://expat.sourceforge.net/'>Expat</a> and <a target='_blank' 563 * href='http://xerces.apache.org/xerces-c/'>Xerces</a>.) 564 * <p> 565 * @see #getColumn() 566 * @internal 567 */ public 568 long getLine() { 569 return libsbmlJNI.SBasePlugin_getLine(swigCPtr, this); 570 } 571 572 573/** 574 * Returns the column number on which this object first appears in the XML 575 * representation of the SBML document. 576 * <p> 577 * @return the column number of the underlying SBML object. 578 * <p> 579 * @note The column number for each construct in an SBML model is set 580 * upon reading the model. The accuracy of the column number depends on 581 * the correctness of the XML representation of the model, and on the 582 * particular XML parser library being used. The former limitation 583 * relates to the following problem: if the model is actually invalid 584 * XML, then the parser may not be able to interpret the data correctly 585 * and consequently may not be able to establish the real column number. 586 * The latter limitation is simply that different parsers seem to have 587 * their own accuracy limitations, and out of all the parsers supported 588 * by libSBML, none have been 100% accurate in all situations. (At this 589 * time, libSBML supports the use of <a target='_blank' 590 * href='http://xmlsoft.org'>libxml2</a>, <a target='_blank' 591 * href='http://expat.sourceforge.net/'>Expat</a> and <a target='_blank' 592 * href='http://xerces.apache.org/xerces-c/'>Xerces</a>.) 593 * <p> 594 * @see #getLine() 595 * @internal 596 */ public 597 long getColumn() { 598 return libsbmlJNI.SBasePlugin_getColumn(swigCPtr, this); 599 } 600 601 602/** 603 * Returns the column number on which this object first appears in the XML 604 * representation of the SBML document. 605 * <p> 606 * @return the column number of the underlying SBML object. 607 * <p> 608 * @note The column number for each construct in an SBML model is set 609 * upon reading the model. The accuracy of the column number depends on 610 * the correctness of the XML representation of the model, and on the 611 * particular XML parser library being used. The former limitation 612 * relates to the following problem: if the model is actually invalid 613 * XML, then the parser may not be able to interpret the data correctly 614 * and consequently may not be able to establish the real column number. 615 * The latter limitation is simply that different parsers seem to have 616 * their own accuracy limitations, and out of all the parsers supported 617 * by libSBML, none have been 100% accurate in all situations. (At this 618 * time, libSBML supports the use of <a target='_blank' 619 * href='http://xmlsoft.org'>libxml2</a>, <a target='_blank' 620 * href='http://expat.sourceforge.net/'>Expat</a> and <a target='_blank' 621 * href='http://xerces.apache.org/xerces-c/'>Xerces</a>.) 622 * <p> 623 * @see #getLine() 624 * @internal 625 */ public 626 SBMLNamespaces getSBMLNamespaces() { 627 return libsbml.DowncastSBMLNamespaces(libsbmlJNI.SBasePlugin_getSBMLNamespaces(swigCPtr, this), false); 628} 629 630 631/** 632 * Helper to log a common type of error for elements. 633 * @internal 634 */ public 635 void logUnknownElement(String element, long sbmlLevel, long sbmlVersion, long pkgVersion) { 636 libsbmlJNI.SBasePlugin_logUnknownElement(swigCPtr, this, element, sbmlLevel, sbmlVersion, pkgVersion); 637 } 638 639 public SBaseList getListOfAllElements() { 640 long cPtr = libsbmlJNI.SBasePlugin_getListOfAllElements(swigCPtr, this); 641 return (cPtr == 0) ? null : new SBaseList(cPtr, false); 642 } 643 644}