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 Base class for SBML validators. 20 * 21 * @htmlinclude not-sbml-warning.html 22 * 23 * LibSBML implements facilities for verifying that a given SBML document 24 * is valid according to the SBML specifications; it also exposes the 25 * validation interface so that user programs and SBML Level 3 package 26 * authors may use the facilities to implement new validators. There are 27 * two main interfaces to libSBML's validation facilities, based on the 28 * classes Validator and SBMLValidator. 29 * 30 * The Validator class is the basis of the system for validating an SBML 31 * document against the validation rules defined in the SBML 32 * specifications. The scheme used by Validator relies is compact and uses 33 * the @em visitor programming pattern, but it relies on C/C++ features and 34 * is not directly accessible from language bindings. SBMLValidator offers 35 * a framework for straightforward class-based extensibility, so that user 36 * code can subclass SBMLValidator to implement new validation systems, 37 * different validators can be introduced or turned off at run-time, and 38 * interfaces can be provided in the libSBML language bindings. 39 * SBMLValidator can call Validator functionality internally (as is the 40 * case in the current implementation of SBMLInternalValidator) or use 41 * entirely different implementation approaches, as necessary. 42 * 43 * Users of libSBML may already be familiar with the facilities encompassed 44 * by the validation system, in the form of the consistency-checking methods 45 * defined on SBMLDocument. The methods SBMLDocument::setConsistencyChecks(@if java int, boolean@endif), 46 * SBMLDocument::checkConsistency(), SBMLDocument::checkInternalConsistency() 47 * and other method of that sort are in fact implemented via SBMLValidator, 48 * specifically as methods on the class SBMLInternalValidator. 49 * 50 * Authors may use SBMLValidator as the base class for their own validator 51 * extensions to libSBML. The class SBMLInternalValidator may serve as a 52 * code example for how to implement such things. 53 */ 54 55 public class SBMLValidator : global::System.IDisposable { 56 private HandleRef swigCPtr; 57 protected bool swigCMemOwn; 58 SBMLValidator(IntPtr cPtr, bool cMemoryOwn)59 internal SBMLValidator(IntPtr cPtr, bool cMemoryOwn) 60 { 61 swigCMemOwn = cMemoryOwn; 62 swigCPtr = new HandleRef(this, cPtr); 63 } 64 getCPtr(SBMLValidator obj)65 internal static HandleRef getCPtr(SBMLValidator obj) 66 { 67 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 68 } 69 getCPtrAndDisown(SBMLValidator obj)70 internal static HandleRef getCPtrAndDisown (SBMLValidator obj) 71 { 72 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 73 74 if (obj != null) 75 { 76 ptr = obj.swigCPtr; 77 obj.swigCMemOwn = false; 78 } 79 80 return ptr; 81 } 82 ~SBMLValidator()83 ~SBMLValidator() { 84 Dispose(false); 85 } 86 Dispose()87 public void Dispose() { 88 Dispose(true); 89 global::System.GC.SuppressFinalize(this); 90 } 91 Dispose(bool disposing)92 protected virtual void Dispose(bool disposing) { 93 lock(this) { 94 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 95 if (swigCMemOwn) { 96 swigCMemOwn = false; 97 libsbmlPINVOKE.delete_SBMLValidator(swigCPtr); 98 } 99 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 100 } 101 } 102 } 103 104 105 /** 106 * Creates a new SBMLValidator. 107 */ public SBMLValidator()108 SBMLValidator() : this(libsbmlPINVOKE.new_SBMLValidator__SWIG_0(), true) { 109 SwigDirectorConnect(); 110 } 111 112 113 /** 114 * Copy constructor; creates a copy of an SBMLValidator object. 115 * 116 * @param orig the object to copy. 117 */ public SBMLValidator(SBMLValidator orig)118 SBMLValidator(SBMLValidator orig) : this(libsbmlPINVOKE.new_SBMLValidator__SWIG_1(SBMLValidator.getCPtr(orig)), true) { 119 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 120 SwigDirectorConnect(); 121 } 122 123 124 /** 125 * Creates and returns a deep copy of this SBMLValidator object. 126 * 127 * @return the (deep) copy of this SBMLValidator object. 128 */ public virtual clone()129 SBMLValidator clone() { 130 global::System.IntPtr cPtr = (SwigDerivedClassHasMethod("clone", swigMethodTypes0) ? libsbmlPINVOKE.SBMLValidator_cloneSwigExplicitSBMLValidator(swigCPtr) : libsbmlPINVOKE.SBMLValidator_clone(swigCPtr)); 131 SBMLValidator ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLValidator(cPtr, true); 132 return ret; 133 } 134 135 136 /** 137 * Returns the current SBML document in use by this validator. 138 * 139 * @return the current SBML document. 140 * 141 * @see setDocument(@if java SBMLDocument@endif) 142 */ public virtual getDocument()143 SBMLDocument getDocument() { 144 global::System.IntPtr cPtr = (SwigDerivedClassHasMethod("getDocument", swigMethodTypes1) ? libsbmlPINVOKE.SBMLValidator_getDocumentSwigExplicitSBMLValidator__SWIG_0(swigCPtr) : libsbmlPINVOKE.SBMLValidator_getDocument__SWIG_0(swigCPtr)); 145 SBMLDocument ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLDocument(cPtr, false); 146 return ret; 147 } 148 149 150 /** 151 * Sets the current SBML document to the given SBMLDocument object. 152 * 153 * @param doc the document to use for this validation. 154 * 155 * 156 * @return integer value indicating success/failure of the 157 * function. @if clike The value is drawn from the 158 * enumeration #OperationReturnValues_t. @endif This particular 159 * function only does one thing irrespective of user input or 160 * object state, and thus will only return a single value: 161 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 162 * 163 * @see getDocument() 164 */ public virtual setDocument(SBMLDocument doc)165 int setDocument(SBMLDocument doc) { 166 int ret = (SwigDerivedClassHasMethod("setDocument", swigMethodTypes3) ? libsbmlPINVOKE.SBMLValidator_setDocumentSwigExplicitSBMLValidator(swigCPtr, SBMLDocument.getCPtr(doc)) : libsbmlPINVOKE.SBMLValidator_setDocument(swigCPtr, SBMLDocument.getCPtr(doc))); 167 return ret; 168 } 169 170 171 /** 172 * Runs this validator on the current SBML document. 173 * 174 * @return an integer value indicating the success/failure of the 175 * validation. @if clike The value is drawn from the enumeration 176 * #OperationReturnValues_t. @endif The possible values returned by this 177 * function are determined by the specific subclasses of this class. 178 */ public virtual validate()179 long validate() { return (long)(SwigDerivedClassHasMethod("validate", swigMethodTypes4) ? libsbmlPINVOKE.SBMLValidator_validateSwigExplicitSBMLValidator__SWIG_0(swigCPtr) : libsbmlPINVOKE.SBMLValidator_validate__SWIG_0(swigCPtr)); } 180 181 182 /** 183 * Clears this validator's list of failures. 184 * 185 * If you are validating multiple SBML documents with the same validator, 186 * call this method after you have processed the list of failures from 187 * the last validation run and before validating the next document. 188 * 189 * @if clike @see getFailures() @endif 190 */ public virtual clearFailures()191 void clearFailures() { 192 if (SwigDerivedClassHasMethod("clearFailures", swigMethodTypes5)) libsbmlPINVOKE.SBMLValidator_clearFailuresSwigExplicitSBMLValidator(swigCPtr); else libsbmlPINVOKE.SBMLValidator_clearFailures(swigCPtr); 193 } 194 195 196 /** 197 * Adds the given failure to this list of Validators failures. 198 * 199 * @param err an SBMLError object representing an error or warning. 200 * 201 * @if clike @see getFailures() @endif 202 */ public logFailure(SBMLError err)203 void logFailure(SBMLError err) { 204 libsbmlPINVOKE.SBMLValidator_logFailure(swigCPtr, SBMLError.getCPtr(err)); 205 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 206 } 207 208 209 /** 210 * Validates the given SBMLDocument object. 211 * 212 * This is identical to calling setDocument(@if java SBMLDocument @endif) 213 * followed by validate(). 214 * 215 * @param d the SBML document to validate. 216 * 217 * @return the number of validation failures that occurred. The objects 218 * describing the actual failures can be retrieved using getFailures(). 219 */ public virtual validate(SBMLDocument d)220 long validate(SBMLDocument d) { return (long)libsbmlPINVOKE.SBMLValidator_validate__SWIG_1(swigCPtr, SBMLDocument.getCPtr(d)); } 221 222 223 /** 224 * Validates the SBML document located at the given @p filename. 225 * 226 * This is a convenience method that saves callers the trouble of 227 * using SBMLReader to read the document first. 228 * 229 * @param filename the path to the file to be read and validated. 230 * 231 * @return the number of validation failures that occurred. The objects 232 * describing the actual failures can be retrieved using getFailures(). 233 */ public virtual validate(string filename)234 long validate(string filename) { return (long)libsbmlPINVOKE.SBMLValidator_validate__SWIG_2(swigCPtr, filename); } 235 236 237 /** 238 * Returns the list of errors or warnings logged during parsing, 239 * consistency checking, or attempted translation of this model. 240 * 241 * Note that this refers to the SBMLDocument object's error log (i.e., 242 * the list returned by SBMLDocument::getErrorLog()). @em That list of 243 * errors and warnings is @em separate from the validation failures 244 * tracked by this validator (i.e., the list returned by getFailures()). 245 * 246 * @return the SBMLErrorLog used for the SBMLDocument. 247 * 248 * @if clike @see getFailures() @endif 249 */ public getErrorLog()250 SBMLErrorLog getErrorLog() { 251 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLValidator_getErrorLog(swigCPtr); 252 SBMLErrorLog ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLErrorLog(cPtr, false); 253 return ret; 254 } 255 256 257 /** 258 * Returns the Model object stored in the SBMLDocument. 259 * 260 * It is important to note that this method <em>does not create</em> a 261 * Model instance. The model in the SBMLDocument must have been created 262 * at some prior time, for example using SBMLDocument::createModel() 263 * or SBMLDocument::setModel(@if java Model@endif). 264 * This method returns @c null if a model does not yet exist. 265 * 266 * @return the Model contained in this validator's SBMLDocument object. 267 * 268 * @see SBMLDocument::setModel(@if java Model@endif) 269 * @see SBMLDocument::createModel() 270 */ public getModel()271 Model getModel() { 272 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLValidator_getModel__SWIG_0(swigCPtr); 273 Model ret = (cPtr == global::System.IntPtr.Zero) ? null : new Model(cPtr, false); 274 return ret; 275 } 276 277 278 /** 279 * Returns the number of failures encountered in the last validation run. 280 * 281 * This method returns the number of failures logged by this validator. 282 * This number only reflects @em this validator's actions; the number may 283 * not be the same as the number of errors and warnings logged on the 284 * SBMLDocument object's error log (i.e., the object returned by 285 * SBMLDocument::getErrorLog()), because other parts of libSBML may log 286 * errors and warnings beyond those found by this validator. 287 * 288 * @return the number of errors logged by this validator. 289 */ public getNumFailures()290 long getNumFailures() { return (long)libsbmlPINVOKE.SBMLValidator_getNumFailures(swigCPtr); } 291 292 293 /** 294 * Returns the failure object at index n in this validator's list of 295 * failures logged during the last run. 296 * 297 * Callers should use getNumFailures() first, to find out the number 298 * of entries in this validator's list of failures. 299 * 300 * @param n an integer indicating the index of the object to return from 301 * the failures list; index values start at 0. 302 * 303 * @return the failure at the given index number. 304 * 305 * @see getNumFailures() 306 */ public getFailure(long n)307 SBMLError getFailure(long n) { 308 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLValidator_getFailure(swigCPtr, n); 309 SBMLError ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLError(cPtr, false); 310 return ret; 311 } 312 SwigDirectorConnect()313 private void SwigDirectorConnect() { 314 if (SwigDerivedClassHasMethod("clone", swigMethodTypes0)) 315 swigDelegate0 = new SwigDelegateSBMLValidator_0(SwigDirectorMethodclone); 316 if (SwigDerivedClassHasMethod("getDocument", swigMethodTypes1)) 317 swigDelegate1 = new SwigDelegateSBMLValidator_1(SwigDirectorMethodgetDocument__SWIG_0); 318 if (SwigDerivedClassHasMethod("getDocument", swigMethodTypes2)) 319 swigDelegate2 = new SwigDelegateSBMLValidator_2(SwigDirectorMethodgetDocument__SWIG_1); 320 if (SwigDerivedClassHasMethod("setDocument", swigMethodTypes3)) 321 swigDelegate3 = new SwigDelegateSBMLValidator_3(SwigDirectorMethodsetDocument); 322 if (SwigDerivedClassHasMethod("validate", swigMethodTypes4)) 323 swigDelegate4 = new SwigDelegateSBMLValidator_4(SwigDirectorMethodvalidate__SWIG_0); 324 if (SwigDerivedClassHasMethod("clearFailures", swigMethodTypes5)) 325 swigDelegate5 = new SwigDelegateSBMLValidator_5(SwigDirectorMethodclearFailures); 326 libsbmlPINVOKE.SBMLValidator_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4, swigDelegate5); 327 } 328 SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)329 private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) { 330 global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null); 331 bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(SBMLValidator)); 332 return hasDerivedMethod; 333 } 334 SwigDirectorMethodclone()335 private global::System.IntPtr SwigDirectorMethodclone() { 336 return SBMLValidator.getCPtr(clone()).Handle; 337 } 338 SwigDirectorMethodgetDocument__SWIG_0()339 private global::System.IntPtr SwigDirectorMethodgetDocument__SWIG_0() { 340 return SBMLDocument.getCPtr(getDocument()).Handle; 341 } 342 SwigDirectorMethodgetDocument__SWIG_1()343 private global::System.IntPtr SwigDirectorMethodgetDocument__SWIG_1() { 344 return SBMLDocument.getCPtr(getDocument()).Handle; 345 } 346 SwigDirectorMethodsetDocument(global::System.IntPtr doc)347 private int SwigDirectorMethodsetDocument(global::System.IntPtr doc) { 348 return setDocument((doc == global::System.IntPtr.Zero) ? null : new SBMLDocument(doc, false)); 349 } 350 SwigDirectorMethodvalidate__SWIG_0()351 private uint SwigDirectorMethodvalidate__SWIG_0() { 352 return (uint)validate(); 353 } 354 SwigDirectorMethodclearFailures()355 private void SwigDirectorMethodclearFailures() { 356 clearFailures(); 357 } 358 SwigDelegateSBMLValidator_0()359 public delegate global::System.IntPtr SwigDelegateSBMLValidator_0(); SwigDelegateSBMLValidator_1()360 public delegate global::System.IntPtr SwigDelegateSBMLValidator_1(); SwigDelegateSBMLValidator_2()361 public delegate global::System.IntPtr SwigDelegateSBMLValidator_2(); SwigDelegateSBMLValidator_3(global::System.IntPtr doc)362 public delegate int SwigDelegateSBMLValidator_3(global::System.IntPtr doc); SwigDelegateSBMLValidator_4()363 public delegate uint SwigDelegateSBMLValidator_4(); SwigDelegateSBMLValidator_5()364 public delegate void SwigDelegateSBMLValidator_5(); 365 366 private SwigDelegateSBMLValidator_0 swigDelegate0; 367 private SwigDelegateSBMLValidator_1 swigDelegate1; 368 private SwigDelegateSBMLValidator_2 swigDelegate2; 369 private SwigDelegateSBMLValidator_3 swigDelegate3; 370 private SwigDelegateSBMLValidator_4 swigDelegate4; 371 private SwigDelegateSBMLValidator_5 swigDelegate5; 372 373 private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { }; 374 private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { }; 375 private static global::System.Type[] swigMethodTypes2 = new global::System.Type[] { }; 376 private static global::System.Type[] swigMethodTypes3 = new global::System.Type[] { typeof(SBMLDocument) }; 377 private static global::System.Type[] swigMethodTypes4 = new global::System.Type[] { }; 378 private static global::System.Type[] swigMethodTypes5 = new global::System.Type[] { }; 379 } 380 381 } 382