Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
Constraint.cs
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// <auto-generated />
3//
4// This file was automatically generated by SWIG (https://www.swig.org).
5// Version 4.2.1
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
12
13using System;
14using System.Runtime.InteropServices;
15using System.Collections;
16using System.Collections.Generic;
17
18public partial class Constraint : PropagationBaseObject, IConstraintWithStatus {
19 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
21 internal Constraint(global::System.IntPtr cPtr, bool cMemoryOwn) : base(operations_research_constraint_solverPINVOKE.Constraint_SWIGUpcast(cPtr), cMemoryOwn) {
22 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
23 }
24
25 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Constraint obj) {
26 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
27 }
28
29 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(Constraint obj) {
30 if (obj != null) {
31 if (!obj.swigCMemOwn)
32 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
33 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
34 obj.swigCMemOwn = false;
35 obj.Dispose();
36 return ptr;
37 } else {
38 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
39 }
40 }
41
42 protected override void Dispose(bool disposing) {
43 lock(this) {
44 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
45 if (swigCMemOwn) {
46 swigCMemOwn = false;
48 }
49 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
50 }
51 base.Dispose(disposing);
52 }
53 }
54
55 public Constraint(Solver solver) : this(operations_research_constraint_solverPINVOKE.new_Constraint(Solver.getCPtr(solver)), true) {
56 SwigDirectorConnect();
57 }
58
59 public virtual void Post() {
61 }
62
63 public virtual void InitialPropagateWrapper() {
65 }
66
67 public override string ToString() {
68 string ret = (SwigDerivedClassHasMethod("ToString", swigMethodTypes0) ? operations_research_constraint_solverPINVOKE.Constraint_ToStringSwigExplicitConstraint(swigCPtr) : operations_research_constraint_solverPINVOKE.Constraint_ToString(swigCPtr));
69 return ret;
70 }
71
72 public virtual void Accept(ModelVisitor visitor) {
74 }
75
76 public bool IsCastConstraint() {
78 return ret;
79 }
80
81 public virtual IntVar Var() {
82 global::System.IntPtr cPtr = operations_research_constraint_solverPINVOKE.Constraint_Var(swigCPtr);
83 IntVar ret = (cPtr == global::System.IntPtr.Zero) ? null : new IntVar(cPtr, false);
84 return ret;
85 }
86
87 private void SwigDirectorConnect() {
88 if (SwigDerivedClassHasMethod("ToString", swigMethodTypes0))
89 swigDelegate0 = new SwigDelegateConstraint_0(SwigDirectorMethodToString);
90 if (SwigDerivedClassHasMethod("Name", swigMethodTypes1))
91 swigDelegate1 = new SwigDelegateConstraint_1(SwigDirectorMethodName);
92 if (SwigDerivedClassHasMethod("BaseName", swigMethodTypes2))
93 swigDelegate2 = new SwigDelegateConstraint_2(SwigDirectorMethodBaseName);
94 if (SwigDerivedClassHasMethod("Post", swigMethodTypes3))
95 swigDelegate3 = new SwigDelegateConstraint_3(SwigDirectorMethodPost);
96 if (SwigDerivedClassHasMethod("InitialPropagateWrapper", swigMethodTypes4))
97 swigDelegate4 = new SwigDelegateConstraint_4(SwigDirectorMethodInitialPropagateWrapper);
98 operations_research_constraint_solverPINVOKE.Constraint_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4);
99 }
100
101 private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
102 global::System.Reflection.MethodInfo[] methodInfos = this.GetType().GetMethods(
103 global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance);
104 foreach (global::System.Reflection.MethodInfo methodInfo in methodInfos) {
105 if (methodInfo.DeclaringType == null)
106 continue;
107
108 if (methodInfo.Name != methodName)
109 continue;
110
111 var parameters = methodInfo.GetParameters();
112 if (parameters.Length != methodTypes.Length)
113 continue;
114
115 bool parametersMatch = true;
116 for (var i = 0; i < parameters.Length; i++) {
117 if (parameters[i].ParameterType != methodTypes[i]) {
118 parametersMatch = false;
119 break;
120 }
121 }
122
123 if (!parametersMatch)
124 continue;
125
126 if (methodInfo.IsVirtual && (methodInfo.DeclaringType.IsSubclassOf(typeof(Constraint))) &&
127 methodInfo.DeclaringType != methodInfo.GetBaseDefinition().DeclaringType) {
128 return true;
129 }
130 }
131
132 return false;
133 }
134
135 private string SwigDirectorMethodToString() {
136 return ToString();
137 }
138
139 private string SwigDirectorMethodName() {
140 return Name();
141 }
142
143 private string SwigDirectorMethodBaseName() {
144 return BaseName();
145 }
146
147 private void SwigDirectorMethodPost() {
148 Post();
149 }
150
151 private void SwigDirectorMethodInitialPropagateWrapper() {
153 }
154
155 public delegate string SwigDelegateConstraint_0();
156 public delegate string SwigDelegateConstraint_1();
157 public delegate string SwigDelegateConstraint_2();
158 public delegate void SwigDelegateConstraint_3();
159 public delegate void SwigDelegateConstraint_4();
161 private SwigDelegateConstraint_0 swigDelegate0;
162 private SwigDelegateConstraint_1 swigDelegate1;
163 private SwigDelegateConstraint_2 swigDelegate2;
164 private SwigDelegateConstraint_3 swigDelegate3;
165 private SwigDelegateConstraint_4 swigDelegate4;
166
167 private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { };
168 private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { };
169 private static global::System.Type[] swigMethodTypes2 = new global::System.Type[] { };
170 private static global::System.Type[] swigMethodTypes3 = new global::System.Type[] { };
171 private static global::System.Type[] swigMethodTypes4 = new global::System.Type[] { };
172}
173
174}
virtual void Accept(ModelVisitor visitor)
Definition Constraint.cs:74
static void Constraint_Post(global::System.Runtime.InteropServices.HandleRef jarg1)
static void Constraint_Accept(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void delete_Constraint(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Constraint_Var(global::System.Runtime.InteropServices.HandleRef jarg1)
static void Constraint_InitialPropagateWrapper(global::System.Runtime.InteropServices.HandleRef jarg1)
static string Constraint_ToString(global::System.Runtime.InteropServices.HandleRef jarg1)
static string Constraint_ToStringSwigExplicitConstraint(global::System.Runtime.InteropServices.HandleRef jarg1)
static void Constraint_director_connect(global::System.Runtime.InteropServices.HandleRef jarg1, Constraint.SwigDelegateConstraint_0 delegate0, Constraint.SwigDelegateConstraint_1 delegate1, Constraint.SwigDelegateConstraint_2 delegate2, Constraint.SwigDelegateConstraint_3 delegate3, Constraint.SwigDelegateConstraint_4 delegate4)
static bool Constraint_IsCastConstraint(global::System.Runtime.InteropServices.HandleRef jarg1)