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 filter functions.
20  *
21  * @htmlinclude libsbml-facility-only-warning.html
22  *
23  * Some libSBML objects provide the ability to return lists of components.
24  * To provide callers with greater control over exactly what is
25  * returned, these methods take optional arguments in the form of filters.
26  * The ElementFilter class is the parent class for these filters.
27  */
28 
29 public class ElementFilter : global::System.IDisposable {
30 	private HandleRef swigCPtr;
31 	protected bool swigCMemOwn;
32 
ElementFilter(IntPtr cPtr, bool cMemoryOwn)33 	internal ElementFilter(IntPtr cPtr, bool cMemoryOwn)
34 	{
35 		swigCMemOwn = cMemoryOwn;
36 		swigCPtr    = new HandleRef(this, cPtr);
37 	}
38 
getCPtr(ElementFilter obj)39 	internal static HandleRef getCPtr(ElementFilter obj)
40 	{
41 		return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
42 	}
43 
getCPtrAndDisown(ElementFilter obj)44 	internal static HandleRef getCPtrAndDisown (ElementFilter obj)
45 	{
46 		HandleRef ptr = new HandleRef(null, IntPtr.Zero);
47 
48 		if (obj != null)
49 		{
50 			ptr             = obj.swigCPtr;
51 			obj.swigCMemOwn = false;
52 		}
53 
54 		return ptr;
55 	}
56 
~ElementFilter()57   ~ElementFilter() {
58     Dispose(false);
59   }
60 
Dispose()61   public void Dispose() {
62     Dispose(true);
63     global::System.GC.SuppressFinalize(this);
64   }
65 
Dispose(bool disposing)66   protected virtual void Dispose(bool disposing) {
67     lock(this) {
68       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
69         if (swigCMemOwn) {
70           swigCMemOwn = false;
71           libsbmlPINVOKE.delete_ElementFilter(swigCPtr);
72         }
73         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74       }
75     }
76   }
77 
78 
79 /**
80    * Creates a new ElementFilter object.
81    */ public
ElementFilter()82  ElementFilter() : this(libsbmlPINVOKE.new_ElementFilter(), true) {
83     SwigDirectorConnect();
84   }
85 
86 
87 /**
88    * Predicate to test elements.
89    *
90    * This is the central predicate of the ElementFilter class.  In subclasses
91    * of ElementFilter, callers should implement this method such that it
92    * returns @c true for @p element arguments that are 'desirable' and
93    * @c false for those that are 'undesirable' in whatever filtering context the
94    * ElementFilter subclass is designed to be used.
95    *
96    * @param element the element to be tested.
97    *
98    * @return @c true if the @p element is desirable or should be kept,
99    * @c false otherwise.
100    */ public virtual
filter(SBase element)101  bool filter(SBase element) {
102     bool ret = (SwigDerivedClassHasMethod("filter", swigMethodTypes0) ? libsbmlPINVOKE.ElementFilter_filterSwigExplicitElementFilter(swigCPtr, SBase.getCPtr(element)) : libsbmlPINVOKE.ElementFilter_filter(swigCPtr, SBase.getCPtr(element)));
103     return ret;
104   }
105 
SwigDirectorConnect()106   private void SwigDirectorConnect() {
107     if (SwigDerivedClassHasMethod("filter", swigMethodTypes0))
108       swigDelegate0 = new SwigDelegateElementFilter_0(SwigDirectorMethodfilter);
109     libsbmlPINVOKE.ElementFilter_director_connect(swigCPtr, swigDelegate0);
110   }
111 
SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)112   private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
113     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);
114     bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(ElementFilter));
115     return hasDerivedMethod;
116   }
117 
SwigDirectorMethodfilter(global::System.IntPtr element)118   private bool SwigDirectorMethodfilter(global::System.IntPtr element) {
119     return filter((element == global::System.IntPtr.Zero) ? null : new SBase(element, false));
120   }
121 
SwigDelegateElementFilter_0(global::System.IntPtr element)122   public delegate bool SwigDelegateElementFilter_0(global::System.IntPtr element);
123 
124   private SwigDelegateElementFilter_0 swigDelegate0;
125 
126   private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { typeof(SBase) };
127 }
128 
129 }
130