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 Model construct. 015 <p> 016 * The {@link CompModelPlugin} class inherits from the SBMLSBasePlugin class, and 017 * codifies the extentions to the {@link Model} class defined in the SBML 018 * Level 3 'Hierarchical Model Composition' 019 * package (“comp”). This extention allows a {@link Model} to define 020 * Submodels (other Models that are instantiated as new parts of the parent 021 * {@link Model}), and Ports, a defined interface for including the given {@link Model} as a 022 * {@link Submodel} of a different {@link Model}. 023 <p> 024 * Submodels are stored in an optional child {@link ListOfSubmodels} object, which, 025 * if present, must contain one or more {@link Submodel} objects. All of the Submodels 026 * present in the {@link ListOfSubmodels} are defined to be instantiated in the 027 * 'complete' {@link Model}. 028 <p> 029 * Ports are stored in an optional child {@link ListOfPorts} object, which, 030 * if present, must contain one or more {@link Port} objects. All of the Ports 031 * present in the {@link ListOfPorts} collectively define the 'port interface' 032 * of the {@link Model}. 033 */ 034 035public class CompModelPlugin extends CompSBasePlugin { 036 private long swigCPtr; 037 038 protected CompModelPlugin(long cPtr, boolean cMemoryOwn) 039 { 040 super(libsbmlJNI.CompModelPlugin_SWIGUpcast(cPtr), cMemoryOwn); 041 swigCPtr = cPtr; 042 } 043 044 protected static long getCPtr(CompModelPlugin obj) 045 { 046 return (obj == null) ? 0 : obj.swigCPtr; 047 } 048 049 protected static long getCPtrAndDisown (CompModelPlugin obj) 050 { 051 long ptr = 0; 052 053 if (obj != null) 054 { 055 ptr = obj.swigCPtr; 056 obj.swigCMemOwn = false; 057 } 058 059 return ptr; 060 } 061 062 protected void finalize() { 063 delete(); 064 } 065 066 public synchronized void delete() { 067 if (swigCPtr != 0) { 068 if (swigCMemOwn) { 069 swigCMemOwn = false; 070 libsbmlJNI.delete_CompModelPlugin(swigCPtr); 071 } 072 swigCPtr = 0; 073 } 074 super.delete(); 075 } 076 077 078/** 079 * Constructor. 080 */ public 081 CompModelPlugin(String uri, String prefix, CompPkgNamespaces compns) { 082 this(libsbmlJNI.new_CompModelPlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true); 083 } 084 085 086/** 087 * Copy constructor. Creates a copy of this {@link CompModelPlugin} object. 088 */ public 089 CompModelPlugin(CompModelPlugin orig) { 090 this(libsbmlJNI.new_CompModelPlugin__SWIG_1(CompModelPlugin.getCPtr(orig), orig), true); 091 } 092 093 094/** 095 * Creates and returns a deep copy of this {@link CompModelPlugin} object. 096 <p> 097 * @return a (deep) copy of this {@link CompModelPlugin} object 098 */ public 099 SBasePlugin cloneObject() { 100 long cPtr = libsbmlJNI.CompModelPlugin_cloneObject(swigCPtr, this); 101 return (cPtr == 0) ? null : new CompModelPlugin(cPtr, true); 102 } 103 104 105/** 106 * Create and return an SBML object of this class, if present. 107 <p> 108 * @return the SBML object corresponding to next {@link XMLToken} in the 109 * {@link XMLInputStream} or null if the token was not recognized. 110 * @internal 111 */ public 112 SBase createObject(XMLInputStream stream) { 113 return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false); 114} 115 116 117/** 118 * Returns the first child element found that has the given <code>id</code> in the 119 * model-wide SId namespace, or <code>null</code> if no such object is found. 120 <p> 121 * @param id a string representing the id of objects to find. 122 <p> 123 * @return a pointer to the {@link SBase} element with the given <code>id</code>. 124 */ public 125 SBase getElementBySId(String id) { 126 return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementBySId(swigCPtr, this, id), false); 127} 128 129 130/** 131 * Returns the first child element it can find with the given meta 132 * identifier, or itself if it has the given <code>metaid</code>, or <code>null</code> if no 133 * such object is found. 134 <p> 135 * @param metaid a string representing the metaid of objects to find. 136 <p> 137 * @return a pointer to the {@link SBase} element with the given <code>metaid</code>. 138 */ public 139 SBase getElementByMetaId(String metaid) { 140 return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementByMetaId(swigCPtr, this, metaid), false); 141} 142 143 144/** 145 * Returns the {@link ListOf} object that holds all submodels. 146 <p> 147 * @return the {@link ListOf} object that holds all submodels. 148 */ public 149 ListOfSubmodels getListOfSubmodels() { 150 long cPtr = libsbmlJNI.CompModelPlugin_getListOfSubmodels(swigCPtr, this); 151 return (cPtr == 0) ? null : new ListOfSubmodels(cPtr, false); 152 } 153 154 155/** 156 * Returns the submodel with the given index. 157 * If the index is invalid, <code>null</code> is returned. 158 <p> 159 * @param n the index number of the {@link Submodel} to get. 160 <p> 161 * @return the nth {@link Submodel} in the {@link ListOfSubmodels}. 162 */ public 163 Submodel getSubmodel(long n) { 164 long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_0(swigCPtr, this, n); 165 return (cPtr == 0) ? null : new Submodel(cPtr, false); 166 } 167 168 169/** 170 * Returns the submodel with the given identifier. 171 <p> 172 * @param id the identifier of the {@link Submodel} to get. 173 <p> 174 * @return the {@link Submodel} in the {@link ListOfSubmodels} with the given identifier. 175 * If no such submodel with identifier <code>id</code> exists, <code>null</code> is returned. 176 */ public 177 Submodel getSubmodel(String id) { 178 long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_2(swigCPtr, this, id); 179 return (cPtr == 0) ? null : new Submodel(cPtr, false); 180 } 181 182 183/** 184 * Adds a copy of the given {@link Submodel} object to the list of submodels. 185 <p> 186 * Fails if the added submodel is <code>null</code>, does not match the 187 * level/version/package of the parent object, or cannot be added to the 188 * list of submodels. 189 <p> 190 * @param submodel the {@link Submodel} object to be added to the list of 191 * submodels. 192 <p> 193 * @return integer value indicating success/failure of the 194 * operation. The possible return values are: 195 * <ul> 196 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 197 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 198 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH } 199 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 200 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 201 * </ul> 202 */ public 203 int addSubmodel(Submodel submodel) { 204 return libsbmlJNI.CompModelPlugin_addSubmodel(swigCPtr, this, Submodel.getCPtr(submodel), submodel); 205 } 206 207 208/** 209 * Returns the number of submodels for this {@link CompModelPlugin}. 210 <p> 211 * @return the number of submodels for this {@link CompModelPlugin}. 212 */ public 213 long getNumSubmodels() { 214 return libsbmlJNI.CompModelPlugin_getNumSubmodels(swigCPtr, this); 215 } 216 217 218/** 219 * Creates a {@link Submodel} object, adds it to the end of the 220 * submodel objects list and returns a pointer to the newly 221 * created object. 222 <p> 223 * @return a newly created {@link Submodel} object 224 */ public 225 Submodel createSubmodel() { 226 long cPtr = libsbmlJNI.CompModelPlugin_createSubmodel(swigCPtr, this); 227 return (cPtr == 0) ? null : new Submodel(cPtr, false); 228 } 229 230 231/** 232 * Removes the submodel with the given index. 233 * A pointer to the submodel that was removed is returned. 234 <p> 235 * @param index the index of the {@link Submodel} object to remove 236 <p> 237 * @return the {@link Submodel} object removed. As mentioned above, the caller 238 * owns the returned object. <code>null</code> is returned if the given <code>index</code> is 239 * out of range and no submodel has been removed, <code>null</code> is returned. 240 */ public 241 Submodel removeSubmodel(long index) { 242 long cPtr = libsbmlJNI.CompModelPlugin_removeSubmodel(swigCPtr, this, index); 243 return (cPtr == 0) ? null : new Submodel(cPtr, false); 244 } 245 246 247/** 248 * Returns the {@link ListOf} object that holds all ports. 249 <p> 250 * @return the {@link ListOf} object that holds all ports. 251 */ public 252 ListOfPorts getListOfPorts() { 253 long cPtr = libsbmlJNI.CompModelPlugin_getListOfPorts(swigCPtr, this); 254 return (cPtr == 0) ? null : new ListOfPorts(cPtr, false); 255 } 256 257 258/** 259 * Returns the port with the given index. 260 <p> 261 * @param n the index number of the {@link Port} to get. 262 <p> 263 * @return the nth {@link Port} in the {@link ListOfPorts}. If the index <code>n</code> is invalid, 264 * <code>null</code> is returned. 265 */ public 266 Port getPort(long n) { 267 long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_0(swigCPtr, this, n); 268 return (cPtr == 0) ? null : new Port(cPtr, false); 269 } 270 271 272/** 273 * Returns the port with the given identifier. 274 <p> 275 * @param id the id of the {@link Port} to get. 276 <p> 277 * @return the {@link Port} in the {@link ListOfPorts} with the given identifier. If the 278 * identifier is invalid, <code>null</code> is returned. 279 */ public 280 Port getPort(String id) { 281 long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_2(swigCPtr, this, id); 282 return (cPtr == 0) ? null : new Port(cPtr, false); 283 } 284 285 286/** 287 * Adds a copy of the given {@link Port} object to the list of ports. 288 <p> 289 * @param port the {@link Port} object to be added to the list of ports. Fails if 290 * the added port is <code>null</code>, does not match the level/version/package of the 291 * parent object, or cannot be added to the list of ports. 292 <p> 293 * @return integer value indicating success/failure of the 294 * operation. The possible return values: 295 * <ul> 296 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 297 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 298 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH } 299 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 300 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH } 301 * </ul> 302 */ public 303 int addPort(Port port) { 304 return libsbmlJNI.CompModelPlugin_addPort(swigCPtr, this, Port.getCPtr(port), port); 305 } 306 307 308/** 309 * Returns the number of ports for this {@link CompModelPlugin}. 310 <p> 311 * @return the number of ports for this {@link CompModelPlugin}. 312 */ public 313 long getNumPorts() { 314 return libsbmlJNI.CompModelPlugin_getNumPorts(swigCPtr, this); 315 } 316 317 318/** 319 * Creates a {@link Port} object, adds it to the end of the 320 * port objects list and returns a pointer to the newly 321 * created object. 322 <p> 323 * @return a newly created {@link Port} object 324 */ public 325 Port createPort() { 326 long cPtr = libsbmlJNI.CompModelPlugin_createPort(swigCPtr, this); 327 return (cPtr == 0) ? null : new Port(cPtr, false); 328 } 329 330 331/** 332 * Removes the port with the given index. 333 <p> 334 * @param index the index of the {@link Port} object to remove 335 <p> 336 * @return the {@link Port} object removed. As mentioned above, 337 * the caller owns the returned object. <code>null</code> is returned if 338 * the given index is out of range. 339 */ public 340 Port removePort(long index) { 341 long cPtr = libsbmlJNI.CompModelPlugin_removePort(swigCPtr, this, index); 342 return (cPtr == 0) ? null : new Port(cPtr, false); 343 } 344 345 346/** 347 * Set the string used as the divider between names when renaming and 348 * flattening models. 349 <p> 350 * The divider string consists of two underscore characters 351 * ("<code>__</code>") by default. This method will fail if called 352 * with an empty <code>divider</code>, or a <code>divider</code> that cannot be used internally as part 353 * of a valid SBML SId. 354 <p> 355 * @return integer value indicating success/failure of the 356 * operation. The possible return values are: 357 * <ul> 358 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 359 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 360 * </ul> 361 */ public 362 int setDivider(String divider) { 363 return libsbmlJNI.CompModelPlugin_setDivider(swigCPtr, this, divider); 364 } 365 366 367/** 368 * Get the string used as the divider between names when renaming and 369 * flattening models. 370 <p> 371 * The divider string consists of two underscore characters 372 * ("<code>__</code>") by default, and can be overridden 373 * with the setDivider() function. 374 <p> 375 * @see #setDivider(String divider) 376 */ public 377 String getDivider() { 378 return libsbmlJNI.CompModelPlugin_getDivider(swigCPtr, this); 379 } 380 381 382/** 383 * Sets the *parent* of this SBML object to child SBML objects (if any). 384 * (Creates a child-parent relationship by the parent) 385 <p> 386 * @see setSBMLDocument 387 * @see enablePackageInternal 388 * @internal 389 */ public 390 void connectToChild() { 391 libsbmlJNI.CompModelPlugin_connectToChild(swigCPtr, this); 392 } 393 394 395/** 396 * Sets the parent SBML object of this SBML object. 397 * (Creates a child-parent relationship by the child) 398 * This function is called when a child element is 399 * set/added/created by its parent element (e.g. by setXXX, 400 * addXXX, createXXX, and connectToChild functions of the 401 * parent element). 402 <p> 403 * @param parent the SBML object to use 404 * @internal 405 */ public 406 void connectToParent(SBase parent) { 407 libsbmlJNI.CompModelPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent); 408 } 409 410 411/** 412 * Enables/Disables the given package with child elements in this plugin 413 * object (if any). 414 * (This is an internal implementation invoked from 415 * {@link SBase#enablePackageInternal()} function) 416 <p> 417 * @note Subclasses in which one or more {@link SBase} derived elements are 418 * defined must override this function. 419 <p> 420 * @see setSBMLDocument 421 * @see connectToParent 422 * @internal 423 */ public 424 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 425 libsbmlJNI.CompModelPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 426 } 427 428 429/** 430 * Sets the custom transformer that is to be used, instead of the standard 431 * prefixing with the given divider. This makes it possible to finely control 432 * how elements are altered. 433 <p> 434 * If not set, only ids and meta ids will be prefixed. 435 <p> 436 * NOTE: the model plugin only holds the pointer to the element it does not 437 * take ownership of it. Thus the calling program is responsible of 438 * freeing the transformer when no longer needed (i.e after the 439 * SBML document has been deleted) 440 */ public 441 void setTransformer(SWIGTYPE_p_PrefixTransformer transformer) { 442 libsbmlJNI.CompModelPlugin_setTransformer(swigCPtr, this, SWIGTYPE_p_PrefixTransformer.getCPtr(transformer)); 443 } 444 445 446/** 447 * @return any custom transformer set for prefix operations, will be null by default. 448 */ public 449 SWIGTYPE_p_PrefixTransformer getTransformer() { 450 long cPtr = libsbmlJNI.CompModelPlugin_getTransformer(swigCPtr, this); 451 return (cPtr == 0) ? null : new SWIGTYPE_p_PrefixTransformer(cPtr, false); 452 } 453 454 455/** 456 * @return an indicator, whether a custom transformer has been set. 457 */ public 458 boolean isSetTransformer() { 459 return libsbmlJNI.CompModelPlugin_isSetTransformer(swigCPtr, this); 460 } 461 462 463/** 464 * Unsets any custom prefix transformers. 465 */ public 466 void unsetTransformer() { 467 libsbmlJNI.CompModelPlugin_unsetTransformer(swigCPtr, this); 468 } 469 470}