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