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 * The priority of execution of an SBML <em>event</em>. 013 <p> 014 * The {@link Priority} object class (which was introduced in SBML Level 3 015 * Version 1), like {@link Delay}, is derived from {@link SBase} and contains a MathML 016 * formula stored in the element 'math'. This formula is used to compute a 017 * dimensionless numerical value that influences the order in which a 018 * simulator is to perform the assignments of two or more events that 019 * happen to be executed simultaneously. The formula may evaluate to any 020 * <code>double</code> value (and thus may be a positive or negative number, or 021 * zero), with positive numbers taken to signifying a higher priority than 022 * zero or negative numbers. If no {@link Priority} object is present on a given 023 * {@link Event} object, no priority is defined for that event. 024 <p> 025 * <h2>The interpretation of priorities on events in a model</h2> 026 <p> 027 * For the purposes of SBML, <em>simultaneous event execution</em> is 028 * defined as the situation in which multiple events have identical 029 * times of execution. The time of execution is calculated as the 030 * sum of the time at which a given event's {@link Trigger} is <em>triggered</em> 031 * plus its {@link Delay} duration, if any. Here, <em>identical times</em> means 032 * <em>mathematically equal</em> instants in time. (In practice, 033 * simulation software adhering to this specification may have to 034 * rely on numerical equality instead of strict mathematical 035 * equality; robust models will ensure that this difference will not 036 * cause significant discrepancies from expected behavior.) 037 <p> 038 * If no {@link Priority} subobjects are defined for two or more {@link Event} objects, 039 * then those events are still executed simultaneously but their order of 040 * execution is <em>undefined by the SBML Level 3 Version 1 041 * specification</em>. A software implementation may choose to execute 042 * such simultaneous events in any order, as long as each event is executed 043 * only once and the requirements of checking the 'persistent' attribute 044 * (and acting accordingly) are satisfied. 045 <p> 046 * If {@link Priority} subobjects are defined for two or more 047 * simultaneously-triggered events, the order in which those particular 048 * events must be executed is dictated by their {@link Priority} objects, 049 * as follows. If the values calculated using the two {@link Priority} 050 * objects' 'math' expressions differ, then the event having 051 * the higher priority value must be executed before the event with 052 * the lower value. If, instead, the two priority values are 053 * mathematically equal, then the two events must be triggered in a 054 * <em>random</em> order. It is important to note that a <em>random 055 * order is not the same as an undefined order</em>: given multiple 056 * runs of the same model with identical conditions, an undefined 057 * ordering would permit a system to execute the events in (for 058 * example) the same order every time (according to whatever scheme 059 * may have been implemented by the system), whereas the explicit 060 * requirement for random ordering means that the order of execution 061 * in different simulation runs depends on random chance. In other 062 * words, given two events <em>A</em> and <em>B</em>, a randomly-determined 063 * order must lead to an equal chance of executing <em>A</em> first or 064 * <em>B</em> first, every time those two events are executed 065 * simultaneously. 066 <p> 067 * A model may contain a mixture of events, some of which have 068 * {@link Priority} subobjects and some do not. Should a combination of 069 * simultaneous events arise in which some events have priorities 070 * defined and others do not, the set of events with defined 071 * priorities must trigger in the order determined by their {@link Priority} 072 * objects, and the set of events without {@link Priority} objects must be 073 * executed in an <em>undefined</em> order with respect to each other 074 * and with respect to the events with {@link Priority} subobjects. (Note 075 * that <em>undefined order</em> does not necessarily mean random 076 * order, although a random ordering would be a valid implementation 077 * of this requirement.) 078 <p> 079 * The following example may help further clarify these points. 080 * Suppose a model contains four events that should be executed 081 * simultaneously, with two of the events having {@link Priority} objects 082 * with the same value and the other two events having {@link Priority} 083 * objects with the same, but different, value. The two events with 084 * the higher priorities must be executed first, in a random order 085 * with respect to each other, and the remaining two events must be 086 * executed after them, again in a random order, for a total of four 087 * possible and equally-likely event executions: A-B-C-D, A-B-D-C, 088 * B-A-C-D, and B-A-D-C. If, instead, the model contains four events 089 * all having the same {@link Priority} values, there are 4! or 24 090 * possible orderings, each of which must be equally likely to be 091 * chosen. Finally, if none of the four events has a {@link Priority} 092 * subobject defined, or even if exactly one of the four events has a 093 * defined {@link Priority}, there are again 24 possible orderings, but the 094 * likelihood of choosing any particular ordering is undefined; the 095 * simulator can choose between events as it wishes. (The SBML 096 * specification only defines the effects of priorities on {@link Event} 097 * objects with respect to <em>other</em> {@link Event} objects with 098 * priorities. Putting a priority on a <em>single</em> {@link Event} object 099 * in a model does not cause it to fall within that scope.) 100 <p> 101 * <h2>Evaluation of {@link Priority} expressions</h2> 102 <p> 103 * An event's {@link Priority} object 'math' expression must be 104 * evaluated at the time the {@link Event} is to be <em>executed</em>. During 105 * a simulation, all simultaneous events have their {@link Priority} values 106 * calculated, and the event with the highest priority is selected for 107 * next execution. Note that it is possible for the execution of one 108 * {@link Event} object to cause the {@link Priority} value of another 109 * simultaneously-executing {@link Event} object to change (as well as to 110 * trigger other events, as already noted). Thus, after executing 111 * one event, and checking whether any other events in the model have 112 * been triggered, all remaining simultaneous events that 113 * <em>either</em> (i) have {@link Trigger} objects with attributes 114 * 'persistent'=<code>false</code> <em>or</em> (ii) have {@link Trigger} 115 * expressions that did not transition from <code>true</code> to 116 * <code>false</code>, must have their {@link Priority} expression reevaluated. 117 * The highest-priority remaining event must then be selected for 118 * execution next. 119 <p> 120 * <h2>Units of {@link Priority} object's mathematical expressions</h2> 121 <p> 122 * The unit associated with the value of a {@link Priority} object's 123 * 'math' expression should be <code>dimensionless.</code> This is 124 * because the priority expression only serves to provide a relative 125 * ordering between different events, and only has meaning with 126 * respect to other {@link Priority} object expressions. The value of 127 * {@link Priority} objects is not comparable to any other kind of object in 128 * an SBML model. 129 <p> 130 * @note The {@link Priority} construct exists only in SBML Level 3; it cannot 131 * be used in SBML Level 2 or Level 1 models. 132 <p> 133 * @see Event 134 * @see Delay 135 * @see EventAssignment 136 */ 137 138public class Priority extends SBase { 139 private long swigCPtr; 140 141 protected Priority(long cPtr, boolean cMemoryOwn) 142 { 143 super(libsbmlJNI.Priority_SWIGUpcast(cPtr), cMemoryOwn); 144 swigCPtr = cPtr; 145 } 146 147 protected static long getCPtr(Priority obj) 148 { 149 return (obj == null) ? 0 : obj.swigCPtr; 150 } 151 152 protected static long getCPtrAndDisown (Priority obj) 153 { 154 long ptr = 0; 155 156 if (obj != null) 157 { 158 ptr = obj.swigCPtr; 159 obj.swigCMemOwn = false; 160 } 161 162 return ptr; 163 } 164 165 protected void finalize() { 166 delete(); 167 } 168 169 public synchronized void delete() { 170 if (swigCPtr != 0) { 171 if (swigCMemOwn) { 172 swigCMemOwn = false; 173 libsbmlJNI.delete_Priority(swigCPtr); 174 } 175 swigCPtr = 0; 176 } 177 super.delete(); 178 } 179 180 181/** 182 * Creates a new {@link Priority} object using the given SBML <code>level</code> and 183 * <code>version</code> values. 184 <p> 185 * @param level a long integer, the SBML Level to assign to this {@link Priority} 186 <p> 187 * @param version a long integer, the SBML Version to assign to this 188 * {@link Priority} 189 <p> 190 * <p> 191 * @throws SBMLConstructorException 192 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 193 * or if this object is incompatible with the given level and version. 194 <p> 195 * <p> 196 * @note Attempting to add an object to an {@link SBMLDocument} having a different 197 * combination of SBML Level, Version and XML namespaces than the object 198 * itself will result in an error at the time a caller attempts to make the 199 * addition. A parent object must have compatible Level, Version and XML 200 * namespaces. (Strictly speaking, a parent may also have more XML 201 * namespaces than a child, but the reverse is not permitted.) The 202 * restriction is necessary to ensure that an SBML model has a consistent 203 * overall structure. This requires callers to manage their objects 204 * carefully, but the benefit is increased flexibility in how models can be 205 * created by permitting callers to create objects bottom-up if desired. In 206 * situations where objects are not yet attached to parents (e.g., 207 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 208 * libSBML determine such things as whether it is valid to assign a 209 * particular value to an attribute. 210 <p> 211 * <p> 212 * @note The {@link Priority} construct exists only in SBML Level 3; it 213 * cannot be used in SBML Level 2 or Level 1 models. 214 */ public 215 Priority(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 216 this(libsbmlJNI.new_Priority__SWIG_0(level, version), true); 217 } 218 219 220/** 221 * Creates a new {@link Priority} object using the given {@link SBMLNamespaces} object 222 * <code>sbmlns</code>. 223 <p> 224 * <p> 225 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 226 * information. It is used to communicate the SBML Level, Version, and (in 227 * Level 3) packages used in addition to SBML Level 3 Core. A 228 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 229 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 230 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 231 <p> 232 * @param sbmlns an {@link SBMLNamespaces} object. 233 <p> 234 * <p> 235 * @throws SBMLConstructorException 236 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 237 * with this object. 238 <p> 239 * <p> 240 * @note Attempting to add an object to an {@link SBMLDocument} having a different 241 * combination of SBML Level, Version and XML namespaces than the object 242 * itself will result in an error at the time a caller attempts to make the 243 * addition. A parent object must have compatible Level, Version and XML 244 * namespaces. (Strictly speaking, a parent may also have more XML 245 * namespaces than a child, but the reverse is not permitted.) The 246 * restriction is necessary to ensure that an SBML model has a consistent 247 * overall structure. This requires callers to manage their objects 248 * carefully, but the benefit is increased flexibility in how models can be 249 * created by permitting callers to create objects bottom-up if desired. In 250 * situations where objects are not yet attached to parents (e.g., 251 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 252 * libSBML determine such things as whether it is valid to assign a 253 * particular value to an attribute. 254 <p> 255 * <p> 256 * @note The {@link Priority} construct exists only in SBML Level 3; it 257 * cannot be used in SBML Level 2 or Level 1 models. 258 */ public 259 Priority(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 260 this(libsbmlJNI.new_Priority__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 261 } 262 263 264/** 265 * Copy constructor; creates a copy of this {@link Priority}. 266 <p> 267 * @param orig the object to copy. 268 */ public 269 Priority(Priority orig) throws org.sbml.libsbml.SBMLConstructorException { 270 this(libsbmlJNI.new_Priority__SWIG_2(Priority.getCPtr(orig), orig), true); 271 } 272 273 274/** 275 * Creates and returns a deep copy of this {@link Priority} object. 276 <p> 277 * @return the (deep) copy of this {@link Priority} object. 278 */ public 279 Priority cloneObject() { 280 long cPtr = libsbmlJNI.Priority_cloneObject(swigCPtr, this); 281 return (cPtr == 0) ? null : new Priority(cPtr, true); 282 } 283 284 285/** 286 * Get the mathematical formula for the priority and return it 287 * as an AST. 288 <p> 289 * @return the math of this {@link Priority}. 290 */ public 291 ASTNode getMath() { 292 long cPtr = libsbmlJNI.Priority_getMath(swigCPtr, this); 293 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 294 } 295 296 297/** 298 * Predicate to test whether the formula for this delay is set. 299 <p> 300 * @return <code>true</code> if the formula (meaning the <code>math</code> subelement) of 301 * this {@link Priority} is set, <code>false</code> otherwise. 302 */ public 303 boolean isSetMath() { 304 return libsbmlJNI.Priority_isSetMath(swigCPtr, this); 305 } 306 307 308/** 309 * Sets the math expression of this {@link Priority} instance to a copy of the given 310 * {@link ASTNode}. 311 <p> 312 * @param math an {@link ASTNode} representing a formula tree. 313 <p> 314 * <p> 315 * @return integer value indicating success/failure of the 316 * function. The possible values 317 * returned by this function are: 318 * <ul> 319 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 320 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 321 * </ul> 322 */ public 323 int setMath(ASTNode math) { 324 return libsbmlJNI.Priority_setMath(swigCPtr, this, ASTNode.getCPtr(math), math); 325 } 326 327 328/** 329 * Returns the libSBML type code of this object instance. 330 <p> 331 * <p> 332 * LibSBML attaches an identifying code to every kind of SBML object. These 333 * are integer constants known as <em>SBML type codes</em>. The names of all 334 * the codes begin with the characters <code>SBML_</code>. 335 * In the Java language interface for libSBML, the 336 * type codes are defined as static integer constants in the interface class 337 * {@link libsbmlConstants}. Note that different Level 3 338 * package plug-ins may use overlapping type codes; to identify the package 339 * to which a given object belongs, call the <code>getPackageName()</code> 340 * method on the object. 341 <p> 342 * @return the SBML type code for this object: 343 * {@link libsbmlConstants#SBML_PRIORITY SBML_PRIORITY} (default). <p> 344 * <p> 345 * @warning <span class='warning'>The specific integer values of the possible 346 * type codes may be reused by different libSBML plug-ins for SBML Level 3. 347 * packages, To fully identify the correct code, <strong>it is necessary to 348 * invoke both getTypeCode() and getPackageName()</strong>.</span> 349 <p> 350 * @see #getElementName() 351 * @see #getPackageName() 352 */ public 353 int getTypeCode() { 354 return libsbmlJNI.Priority_getTypeCode(swigCPtr, this); 355 } 356 357 358/** 359 * Returns the XML element name of this object, which for {@link Priority}, is 360 * always <code>'priority'.</code> 361 <p> 362 * @return the name of this element, i.e., <code>'priority'.</code> 363 <p> 364 * @see #getTypeCode() 365 */ public 366 String getElementName() { 367 return libsbmlJNI.Priority_getElementName(swigCPtr, this); 368 } 369 370 371/** 372 * Predicate returning <code>true</code> if all the required elements for this 373 * {@link Priority} object have been set. 374 <p> 375 * @note The required elements for a {@link Priority} object are: 376 * <ul> 377 * <li> 'math' 378 * 379 * </ul> <p> 380 * @return a boolean value indicating whether all the required 381 * elements for this object have been defined. 382 */ public 383 boolean hasRequiredElements() { 384 return libsbmlJNI.Priority_hasRequiredElements(swigCPtr, this); 385 } 386 387 388/** 389 * Finds this {@link Priority}'s {@link Event} parent and calls unsetPriority() on it, 390 * indirectly deleting itself. 391 <p> 392 * Overridden from the {@link SBase} function since the parent is not a {@link ListOf}. 393 <p> 394 * <p> 395 * @return integer value indicating success/failure of the 396 * function. The possible values 397 * returned by this function are: 398 * <ul> 399 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 400 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 401 * </ul> 402 */ public 403 int removeFromParentAndDelete() { 404 return libsbmlJNI.Priority_removeFromParentAndDelete(swigCPtr, this); 405 } 406 407 408/** 409 * <p> 410 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another 411 * value. 412 <p> 413 * <p> 414 * In SBML, object identifiers are of a data type called <code>SId</code>. 415 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 416 * introduced for attribute values that refer to <code>SId</code> values; in 417 * previous Levels of SBML, this data type did not exist and attributes were 418 * simply described to as 'referring to an identifier', but the effective 419 * data type was the same as <code>SIdRef</code>in Level 3. These and 420 * other methods of libSBML refer to the type <code>SIdRef</code> for all 421 * Levels of SBML, even if the corresponding SBML specification did not 422 * explicitly name the data type. 423 <p> 424 * This method works by looking at all attributes and (if appropriate) 425 * mathematical formulas in MathML content, comparing the referenced 426 * identifiers to the value of <code>oldid</code>. If any matches are found, the 427 * matching values are replaced with <code>newid</code>. The method does <em>not</em> 428 * descend into child elements. 429 <p> 430 * @param oldid the old identifier 431 * @param newid the new identifier 432 */ public 433 void renameSIdRefs(String oldid, String newid) { 434 libsbmlJNI.Priority_renameSIdRefs(swigCPtr, this, oldid, newid); 435 } 436 437 438/** 439 * <p> 440 * Replaces all uses of a given <code>UnitSIdRef</code> type attribute value with 441 * another value. 442 <p> 443 * <p> 444 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>. In 445 * SBML Level 3, an explicit data type called <code>UnitSIdRef</code> was 446 * introduced for attribute values that refer to <code>UnitSId</code> values; in 447 * previous Levels of SBML, this data type did not exist and attributes were 448 * simply described to as 'referring to a unit identifier', but the effective 449 * data type was the same as <code>UnitSIdRef</code> in Level 3. These and 450 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all 451 * Levels of SBML, even if the corresponding SBML specification did not 452 * explicitly name the data type. 453 <p> 454 * This method works by looking at all unit identifier attribute values 455 * (including, if appropriate, inside mathematical formulas), comparing the 456 * referenced unit identifiers to the value of <code>oldid</code>. If any matches 457 * are found, the matching values are replaced with <code>newid</code>. The method 458 * does <em>not</em> descend into child elements. 459 <p> 460 * @param oldid the old identifier 461 * @param newid the new identifier 462 */ public 463 void renameUnitSIdRefs(String oldid, String newid) { 464 libsbmlJNI.Priority_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 465 } 466 467 468/** * @internal */ public 469 void replaceSIDWithFunction(String id, ASTNode function) { 470 libsbmlJNI.Priority_replaceSIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 471 } 472 473}