1 //------------------------------------------------------------------------------ 2 // <auto-generated /> 3 // 4 // This file was automatically generated by SWIG (http://www.swig.org). 5 // Version 4.0.2 6 // 7 // Do not make changes to this file unless you know what you are doing--modify 8 // the SWIG interface file instead. 9 //------------------------------------------------------------------------------ 10 11 namespace libsbml { 12 13 using System; 14 using System.Runtime.InteropServices; 15 16 /** 17 * @sbmlpackage{core} 18 * 19 @htmlinclude pkg-marker-core.html An SBML <em>constraint</em>, for stating validity assumptions. 20 * 21 * The Constraint object class was introduced in SBML Level 2 22 * Version 2 as a mechanism for stating the assumptions under which a 23 * model is designed to operate. The <em>constraints</em> are statements 24 * about permissible values of different quantities in a model. 25 * Constraints are not used to compute dynamical values for simulation or 26 * analysis, but rather, they serve an advisory role for 27 * simulation/analysis tools. 28 * 29 * SBML's Constraint object class has one required attribute, 'id', to 30 * give the parameter a unique identifier by which other parts of an SBML 31 * model definition can refer to it. A Constraint object can also have an 32 * optional 'name' attribute of type @c string. Identifiers and names must 33 * be used according to the guidelines described in the SBML specification 34 * (e.g., Section 3.3 in the Level 2 Version 4 specification). 35 * 36 * Constraint has one subelement, 'math', containing a MathML 37 * formula defining the condition of the constraint. This formula will 38 * return a Boolean value of @c true when the model is a <em>valid</em> 39 * state. The formula can be an arbitrary expression referencing the 40 * variables and other entities in an SBML model. The evaluation of 'math' 41 * and behavior of constraints are described in more detail below. 42 * 43 * In SBML Level 2 and SBML Level 3 Version 1, the 'math' 44 * subelement is required, and its formula must be a Boolean value. In 45 * SBML Level 3 Version 2, these restrictions were relaxed: 46 * the 'math' subelement is optional, and numeric values are allowed 47 * in Boolean contexts (a '0' is interpreted as @c false, and all other 48 * values are interpreted as @c true). If a Constraint with no 'math' 49 * is present in a Model, no restriction on the Model's behavior is 50 * implied or enforced. 51 * 52 * A Constraint structure also has an optional subelement called 'message'. 53 * This can contain a message in XHTML format that may be displayed to the 54 * user when the condition of the formula in the 'math' subelement 55 * evaluates to a value of @c false. Software tools are not required to 56 * display the message, but it is recommended that they do so as a matter 57 * of best practice. The XHTML content within a 'message' subelement must 58 * follow the same restrictions as for the 'notes' element on SBase 59 * described in in the SBML Level 2 specification; please consult the 60 * <a target='_blank' href='http://sbml.org/Documents/Specifications'>SBML 61 * specification document</a> corresponding to the SBML Level and Version 62 * of your model for more information about the requirements for 'notes' 63 * content. 64 * 65 * Constraint was introduced in SBML Level 2 Version 2. It is 66 * not available in earlier versions of Level 2 nor in any version of 67 * Level 1. 68 * 69 * @section constraint-semantics Semantics of Constraints 70 * 71 * In the context of a simulation, a Constraint has effect at all times 72 * <em>t >= 0</em>. Each Constraint's 'math' subelement is first 73 * evaluated after any InitialAssignment definitions in a model at <em>t = 74 * 0</em> and can conceivably trigger at that point. (In other words, a 75 * simulation could fail a constraint immediately.) 76 * 77 * Constraint structures <em>cannot and should not</em> be used to compute 78 * the dynamical behavior of a model as part of, for example, simulation. 79 * Constraints may be used as input to non-dynamical analysis, for instance 80 * by expressing flux constraints for flux balance analysis. 81 * 82 * The results of a simulation of a model containing a constraint are 83 * invalid from any simulation time at and after a point when the function 84 * given by the 'math' subelement returns a value of @c false. Invalid 85 * simulation results do not make a prediction of the behavior of the 86 * biochemical reaction network represented by the model. The precise 87 * behavior of simulation tools is left undefined with respect to 88 * constraints. If invalid results are detected with respect to a given 89 * constraint, the 'message' subelement may optionally be displayed to the 90 * user. The simulation tool may also halt the simulation or clearly 91 * delimit in output data the simulation time point at which the simulation 92 * results become invalid. 93 * 94 * SBML does not impose restrictions on duplicate Constraint definitions or 95 * the order of evaluation of Constraint objects in a model. It is 96 * possible for a model to define multiple constraints all with the same 97 * mathematical expression. Since the failure of any constraint indicates 98 * that the model simulation has entered an invalid state, a system is not 99 * required to attempt to detect whether other constraints in the model 100 * have failed once any one constraint has failed. 101 * 102 * 103 * 104 */ 105 106 public class Constraint : SBase { 107 private HandleRef swigCPtr; 108 Constraint(IntPtr cPtr, bool cMemoryOwn)109 internal Constraint(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.Constraint_SWIGUpcast(cPtr), cMemoryOwn) 110 { 111 //super(libsbmlPINVOKE.ConstraintUpcast(cPtr), cMemoryOwn); 112 swigCPtr = new HandleRef(this, cPtr); 113 } 114 getCPtr(Constraint obj)115 internal static HandleRef getCPtr(Constraint obj) 116 { 117 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 118 } 119 getCPtrAndDisown(Constraint obj)120 internal static HandleRef getCPtrAndDisown (Constraint obj) 121 { 122 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 123 124 if (obj != null) 125 { 126 ptr = obj.swigCPtr; 127 obj.swigCMemOwn = false; 128 } 129 130 return ptr; 131 } 132 Dispose(bool disposing)133 protected override void Dispose(bool disposing) { 134 lock(this) { 135 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 136 if (swigCMemOwn) { 137 swigCMemOwn = false; 138 libsbmlPINVOKE.delete_Constraint(swigCPtr); 139 } 140 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 141 } 142 base.Dispose(disposing); 143 } 144 } 145 146 147 /** 148 * Creates a new Constraint using the given SBML @p level and @p version 149 * values. 150 * 151 * @param level a long integer, the SBML Level to assign to this Constraint. 152 * 153 * @param version a long integer, the SBML Version to assign to this 154 * Constraint. 155 * 156 * 157 * @throws SBMLConstructorException 158 * Thrown if the given @p level and @p version combination are invalid 159 * or if this object is incompatible with the given level and version. 160 * 161 * 162 * 163 * 164 * @note Attempting to add an object to an SBMLDocument having a different 165 * combination of SBML Level, Version and XML namespaces than the object 166 * itself will result in an error at the time a caller attempts to make the 167 * addition. A parent object must have compatible Level, Version and XML 168 * namespaces. (Strictly speaking, a parent may also have more XML 169 * namespaces than a child, but the reverse is not permitted.) The 170 * restriction is necessary to ensure that an SBML model has a consistent 171 * overall structure. This requires callers to manage their objects 172 * carefully, but the benefit is increased flexibility in how models can be 173 * created by permitting callers to create objects bottom-up if desired. In 174 * situations where objects are not yet attached to parents (e.g., 175 * SBMLDocument), knowledge of the intented SBML Level and Version help 176 * libSBML determine such things as whether it is valid to assign a 177 * particular value to an attribute. 178 * 179 * 180 */ public Constraint(long level, long version)181 Constraint(long level, long version) : this(libsbmlPINVOKE.new_Constraint__SWIG_0(level, version), true) { 182 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 183 } 184 185 186 /** 187 * Creates a new Constraint using the given SBMLNamespaces object 188 * @p sbmlns. 189 * 190 * 191 * 192 * The SBMLNamespaces object encapsulates SBML Level/Version/namespaces 193 * information. It is used to communicate the SBML Level, Version, and (in 194 * Level 3) packages used in addition to SBML Level 3 Core. A 195 * common approach to using libSBML's SBMLNamespaces facilities is to create an 196 * SBMLNamespaces object somewhere in a program once, then hand that object 197 * as needed to object constructors that accept SBMLNamespaces as arguments. 198 * 199 * 200 * 201 * @param sbmlns an SBMLNamespaces object. 202 * 203 * 204 * @throws SBMLConstructorException 205 * Thrown if the given @p sbmlns is inconsistent or incompatible 206 * with this object. 207 * 208 * 209 * 210 * 211 * @note Attempting to add an object to an SBMLDocument having a different 212 * combination of SBML Level, Version and XML namespaces than the object 213 * itself will result in an error at the time a caller attempts to make the 214 * addition. A parent object must have compatible Level, Version and XML 215 * namespaces. (Strictly speaking, a parent may also have more XML 216 * namespaces than a child, but the reverse is not permitted.) The 217 * restriction is necessary to ensure that an SBML model has a consistent 218 * overall structure. This requires callers to manage their objects 219 * carefully, but the benefit is increased flexibility in how models can be 220 * created by permitting callers to create objects bottom-up if desired. In 221 * situations where objects are not yet attached to parents (e.g., 222 * SBMLDocument), knowledge of the intented SBML Level and Version help 223 * libSBML determine such things as whether it is valid to assign a 224 * particular value to an attribute. 225 * 226 * 227 */ public Constraint(SBMLNamespaces sbmlns)228 Constraint(SBMLNamespaces sbmlns) : this(libsbmlPINVOKE.new_Constraint__SWIG_1(SBMLNamespaces.getCPtr(sbmlns)), true) { 229 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 230 } 231 232 233 /** 234 * Copy constructor; creates a copy of this Constraint. 235 * 236 * @param orig the object to copy. 237 */ public Constraint(Constraint orig)238 Constraint(Constraint orig) : this(libsbmlPINVOKE.new_Constraint__SWIG_2(Constraint.getCPtr(orig)), true) { 239 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 240 } 241 242 243 /** 244 * Creates and returns a deep copy of this Constraint object. 245 * 246 * @return the (deep) copy of this Constraint object. 247 */ public new clone()248 Constraint clone() { 249 global::System.IntPtr cPtr = libsbmlPINVOKE.Constraint_clone(swigCPtr); 250 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, true); 251 return ret; 252 } 253 254 255 /** 256 * Get the message, if any, associated with this Constraint 257 * 258 * @return the message for this Constraint, as an XMLNode. 259 */ public getMessage()260 XMLNode getMessage() { 261 global::System.IntPtr cPtr = libsbmlPINVOKE.Constraint_getMessage(swigCPtr); 262 XMLNode ret = (cPtr == global::System.IntPtr.Zero) ? null : new XMLNode(cPtr, false); 263 return ret; 264 } 265 266 267 /** 268 * Get the message string, if any, associated with this Constraint 269 * 270 * @return the message for this Constraint, as a string. 271 */ public new getMessageString()272 string getMessageString() { 273 string ret = libsbmlPINVOKE.Constraint_getMessageString(swigCPtr); 274 return ret; 275 } 276 277 278 /** 279 * Get the mathematical expression of this Constraint 280 * 281 * @return the math for this Constraint, as an ASTNode, or @c null if the math is not set. 282 */ public new getMath()283 ASTNode getMath() { 284 global::System.IntPtr cPtr = libsbmlPINVOKE.Constraint_getMath(swigCPtr); 285 ASTNode ret = (cPtr == global::System.IntPtr.Zero) ? null : new ASTNode(cPtr, false); 286 return ret; 287 } 288 289 290 /** 291 * Predicate returning @c true if a 292 * message is defined for this Constraint. 293 * 294 * @return @c true if the message of this Constraint is set, 295 * @c false otherwise. 296 */ public isSetMessage()297 bool isSetMessage() { 298 bool ret = libsbmlPINVOKE.Constraint_isSetMessage(swigCPtr); 299 return ret; 300 } 301 302 303 /** 304 * Predicate returning @c true if a 305 * mathematical formula is defined for this Constraint. 306 * 307 * @return @c true if the 'math' subelement for this Constraint is 308 * set, @c false otherwise. 309 */ public isSetMath()310 bool isSetMath() { 311 bool ret = libsbmlPINVOKE.Constraint_isSetMath(swigCPtr); 312 return ret; 313 } 314 315 316 /** 317 * Sets the message of this Constraint. 318 * 319 * The XMLNode tree passed in @p xhtml is copied. 320 * 321 * @param xhtml an XML tree containing XHTML content. 322 * 323 * 324 * @return integer value indicating success/failure of the 325 * function. @if clike The value is drawn from the 326 * enumeration #OperationReturnValues_t. @endif The possible values 327 * returned by this function are: 328 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 329 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 330 */ public setMessage(XMLNode xhtml)331 int setMessage(XMLNode xhtml) { 332 int ret = libsbmlPINVOKE.Constraint_setMessage__SWIG_0(swigCPtr, XMLNode.getCPtr(xhtml)); 333 return ret; 334 } 335 336 337 /** 338 * Sets the message of this Constraint. 339 * 340 * @param message an XML string that is to be used as the content of the 341 * 'message' subelement of this object. 342 * 343 * @param addXHTMLMarkup a boolean indicating whether to wrap the contents 344 * of the @p message argument with XHTML paragraph (<code><p></code>) 345 * tags. This is appropriate when the string in @p message does not already 346 * containg the appropriate XHTML markup. 347 * 348 * 349 * @return integer value indicating success/failure of the 350 * function. @if clike The value is drawn from the 351 * enumeration #OperationReturnValues_t. @endif The possible values 352 * returned by this function are: 353 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 354 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 355 */ public new setMessage(string message, bool addXHTMLMarkup)356 int setMessage(string message, bool addXHTMLMarkup) { 357 int ret = libsbmlPINVOKE.Constraint_setMessage__SWIG_1(swigCPtr, message, addXHTMLMarkup); 358 return ret; 359 } 360 361 362 /** 363 * Sets the message of this Constraint. 364 * 365 * @param message an XML string that is to be used as the content of the 366 * 'message' subelement of this object. 367 * 368 * @param addXHTMLMarkup a boolean indicating whether to wrap the contents 369 * of the @p message argument with XHTML paragraph (<code><p></code>) 370 * tags. This is appropriate when the string in @p message does not already 371 * containg the appropriate XHTML markup. 372 * 373 * 374 * @return integer value indicating success/failure of the 375 * function. @if clike The value is drawn from the 376 * enumeration #OperationReturnValues_t. @endif The possible values 377 * returned by this function are: 378 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 379 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 380 */ public new setMessage(string message)381 int setMessage(string message) { 382 int ret = libsbmlPINVOKE.Constraint_setMessage__SWIG_2(swigCPtr, message); 383 return ret; 384 } 385 386 387 /** 388 * Sets the mathematical expression of this Constraint to a copy of the 389 * AST given as @p math. 390 * 391 * @param math an ASTNode expression to be assigned as the 'math' 392 * subelement of this Constraint. 393 * 394 * 395 * @return integer value indicating success/failure of the 396 * function. @if clike The value is drawn from the 397 * enumeration #OperationReturnValues_t. @endif The possible values 398 * returned by this function are: 399 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 400 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 401 */ public new setMath(ASTNode math)402 int setMath(ASTNode math) { 403 int ret = libsbmlPINVOKE.Constraint_setMath(swigCPtr, ASTNode.getCPtr(math)); 404 return ret; 405 } 406 407 408 /** 409 * Unsets the 'message' subelement of this Constraint. 410 * 411 * 412 * @return integer value indicating success/failure of the 413 * function. @if clike The value is drawn from the 414 * enumeration #OperationReturnValues_t. @endif The possible values 415 * returned by this function are: 416 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 417 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 418 */ public unsetMessage()419 int unsetMessage() { 420 int ret = libsbmlPINVOKE.Constraint_unsetMessage(swigCPtr); 421 return ret; 422 } 423 424 425 /** 426 * 427 * Replaces all uses of a given @c SIdRef type attribute value with another 428 * value. 429 * 430 * 431 * 432 433 * In SBML, object identifiers are of a data type called <code>SId</code>. 434 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 435 * introduced for attribute values that refer to <code>SId</code> values; in 436 * previous Levels of SBML, this data type did not exist and attributes were 437 * simply described to as 'referring to an identifier', but the effective 438 * data type was the same as <code>SIdRef</code> in Level 3. These and 439 * other methods of libSBML refer to the type <code>SIdRef</code> for all 440 * Levels of SBML, even if the corresponding SBML specification did not 441 * explicitly name the data type. 442 * 443 * 444 * 445 * This method works by looking at all attributes and (if appropriate) 446 * mathematical formulas in MathML content, comparing the referenced 447 * identifiers to the value of @p oldid. If any matches are found, the 448 * matching values are replaced with @p newid. The method does @em not 449 * descend into child elements. 450 * 451 * @param oldid the old identifier. 452 * @param newid the new identifier. 453 * 454 * 455 */ public new renameSIdRefs(string oldid, string newid)456 void renameSIdRefs(string oldid, string newid) { 457 libsbmlPINVOKE.Constraint_renameSIdRefs(swigCPtr, oldid, newid); 458 } 459 460 461 /** 462 * 463 * Replaces all uses of a given @c UnitSIdRef type attribute value with 464 * another value. 465 * 466 * 467 * 468 * In SBML, unit definitions have identifiers of type <code>UnitSId</code>. In 469 * SBML Level 3, an explicit data type called <code>UnitSIdRef</code> was 470 * introduced for attribute values that refer to <code>UnitSId</code> values; in 471 * previous Levels of SBML, this data type did not exist and attributes were 472 * simply described to as 'referring to a unit identifier', but the effective 473 * data type was the same as <code>UnitSIdRef</code> in Level 3. These and 474 * other methods of libSBML refer to the type <code>UnitSIdRef</code> for all 475 * Levels of SBML, even if the corresponding SBML specification did not 476 * explicitly name the data type. 477 * 478 * 479 * 480 * This method works by looking at all unit identifier attribute values 481 * (including, if appropriate, inside mathematical formulas), comparing the 482 * referenced unit identifiers to the value of @p oldid. If any matches 483 * are found, the matching values are replaced with @p newid. The method 484 * does @em not descend into child elements. 485 * 486 * @param oldid the old identifier. 487 * @param newid the new identifier. 488 * 489 * 490 */ public new renameUnitSIdRefs(string oldid, string newid)491 void renameUnitSIdRefs(string oldid, string newid) { 492 libsbmlPINVOKE.Constraint_renameUnitSIdRefs(swigCPtr, oldid, newid); 493 } 494 495 496 /** */ /* libsbml-internal */ public new replaceSIDWithFunction(string id, ASTNode function)497 void replaceSIDWithFunction(string id, ASTNode function) { 498 libsbmlPINVOKE.Constraint_replaceSIDWithFunction(swigCPtr, id, ASTNode.getCPtr(function)); 499 } 500 501 502 /** 503 * Returns the libSBML type code for this SBML object. 504 * 505 * 506 * 507 * LibSBML attaches an identifying code to every kind of SBML object. These 508 * are integer constants known as <em>SBML type codes</em>. The names of all 509 * the codes begin with the characters <code>SBML_</code>. 510 * @if clike The set of possible type codes for core elements is defined in 511 * the enumeration #SBMLTypeCode_t, and in addition, libSBML plug-ins for 512 * SBML Level 3 packages define their own extra enumerations of type 513 * codes (e.g., #SBMLLayoutTypeCode_t for the Level 3 Layout 514 * package).@endif@if java In the Java language interface for libSBML, the 515 * type codes are defined as static integer constants in the interface class 516 * {@link libsbmlConstants}. @endif@if python In the Python language 517 * interface for libSBML, the type codes are defined as static integer 518 * constants in the interface class @link libsbml@endlink.@endif@if csharp In 519 * the C# language interface for libSBML, the type codes are defined as 520 * static integer constants in the interface class 521 * @link libsbmlcs.libsbml@endlink.@endif Note that different Level 3 522 * package plug-ins may use overlapping type codes; to identify the package 523 * to which a given object belongs, call the 524 * <code>@if conly SBase_getPackageName() 525 * @else SBase::getPackageName() 526 * @endif</code> 527 * method on the object. 528 * 529 * The exception to this is lists: all SBML-style list elements have the type 530 * @link libsbml#SBML_LIST_OF SBML_LIST_OF@endlink, regardless of what package they 531 * are from. 532 * 533 * 534 * 535 * @return the SBML type code for this object: 536 * @link libsbml#SBML_CONSTRAINT SBML_CONSTRAINT@endlink (default). 537 * 538 * 539 * @warning <span class='warning'>The specific integer values of the possible 540 * type codes may be reused by different libSBML plug-ins for SBML Level 3. 541 * packages, To fully identify the correct code, <strong>it is necessary to 542 * invoke both getPackageName() and getTypeCode()</strong> (or 543 * ListOf::getItemTypeCode()).</span> 544 * 545 * 546 * 547 * @see getElementName() 548 * @see getPackageName() 549 */ public new getTypeCode()550 int getTypeCode() { 551 int ret = libsbmlPINVOKE.Constraint_getTypeCode(swigCPtr); 552 return ret; 553 } 554 555 556 /** 557 * Returns the XML element name of this object, which for Constraint, is 558 * always @c 'constraint'. 559 * 560 * @return the name of this element, i.e., @c 'constraint'. 561 */ public new getElementName()562 string getElementName() { 563 string ret = libsbmlPINVOKE.Constraint_getElementName(swigCPtr); 564 return ret; 565 } 566 567 568 /** 569 * Predicate returning @c true if 570 * all the required elements for this Constraint object 571 * have been set. 572 * 573 * @note The required elements for a Constraint object are: 574 * @li 'math' (through SBML Level 3 Version 1 only; not 575 * required in Level 3 Version 2+.) 576 * 577 * @return a boolean value indicating whether all the required 578 * elements for this object have been defined. 579 */ public new hasRequiredElements()580 bool hasRequiredElements() { 581 bool ret = libsbmlPINVOKE.Constraint_hasRequiredElements(swigCPtr); 582 return ret; 583 } 584 585 } 586 587 } 588