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 Converts a model's existing units to SI units.
20  *
21  * @htmlinclude libsbml-facility-only-warning.html
22  *
23  * This SBML converter converts the units in a model to base SI units, that
24  * is, using only the units metre, kilogram, second, ampere, kelvin, mole and
25  * candela.
26  *
27  * Unit conversion will only be performed on models that are fully unit
28  * consistent, meaning that all objects have units associated with them and
29  * there are no literal numbers with unspecified units.  In the case of an
30  * SBML Level&nbsp;3 model involving math expressions, this means that the
31  * @c timeUnits attribute on the Model object must be set, and if there are any
32  * reactions in the model, the @c extentUnits attribute on the Model object
33  * must also be set.
34  *
35  * @section SBMLUnitsConverter-usage Configuration and use of SBMLUnitsConverter
36  *
37  * SBMLUnitsConverter is enabled by creating a ConversionProperties object
38  * with the option @c 'units', and passing this properties object to
39  * SBMLDocument::convert(@if java ConversionProperties@endif).  This
40  * converter takes one optional option:
41  *
42  * @li @c 'removeUnusedUnits': the value of this property should be a
43  * Boolean.  If it is @c true, it tells the unit convert to remove any unused
44  * UnitDefinition objects after conversion is complete.  ('Unused' units are
45  * units that are not referenced by any object in the model.)  If the value
46  * is @c false, unused UnitDefinition objects are not removed from the model.
47  * The default is @c true.
48  *
49  *
50  * @section using-converters General information about the use of SBML converters
51  *
52  * The use of all the converters follows a similar approach.  First, one
53  * creates a ConversionProperties object and calls
54  * ConversionProperties::addOption(@if java ConversionOption@endif)
55  * on this object with one argument: a text string that identifies the desired
56  * converter.  (The text string is specific to each converter; consult the
57  * documentation for a given converter to find out how it should be enabled.)
58  *
59  * Next, for some converters, the caller can optionally set some
60  * converter-specific properties using additional calls to
61  * ConversionProperties::addOption(@if java ConversionOption@endif).
62  * Many converters provide the ability to
63  * configure their behavior to some extent; this is realized through the use
64  * of properties that offer different options.  The default property values
65  * for each converter can be interrogated using the method
66  * SBMLConverter::getDefaultProperties() on the converter class in question .
67  *
68  * Finally, the caller should invoke the method
69  * SBMLDocument::convert(@if java ConversionProperties@endif)
70  * with the ConversionProperties object as an argument.
71  *
72  * @subsection converter-example Example of invoking an SBML converter
73  *
74  * The following code fragment illustrates an example using
75  * SBMLReactionConverter, which is invoked using the option string
76  * @c 'replaceReactions':
77  *
78  * @if cpp
79  * @code{.cpp}
80 ConversionProperties props;
81 props.addOption('replaceReactions');
82 @endcode
83 @endif
84 @if python
85 @code{.py}
86 config = ConversionProperties()
87 if config != None:
88   config.addOption('replaceReactions')
89 @endcode
90 @endif
91 @if java
92 @code{.java}
93 ConversionProperties props = new ConversionProperties();
94 if (props != null) {
95   props.addOption('replaceReactions');
96 } else {
97   // Deal with error.
98 }
99 @endcode
100 @endif
101  *
102  * In the case of SBMLReactionConverter, there are no options to affect
103  * its behavior, so the next step is simply to invoke the converter on
104  * an SBMLDocument object.  Continuing the example code:
105  *
106  * @if cpp
107  * @code{.cpp}
108 // Assume that the variable 'document' has been set to an SBMLDocument object.
109 int status = document->convert(props);
110 if (status != LIBSBML_OPERATION_SUCCESS)
111 {
112   cerr << 'Unable to perform conversion due to the following:' << endl;
113   document->printErrors(cerr);
114 }
115 @endcode
116 @endif
117 @if python
118 @code{.py}
119   # Assume that the variable 'document' has been set to an SBMLDocument object.
120   status = document.convert(config)
121   if status != LIBSBML_OPERATION_SUCCESS:
122     # Handle error somehow.
123     print('Error: conversion failed due to the following:')
124     document.printErrors()
125 @endcode
126 @endif
127 @if java
128 @code{.java}
129   // Assume that the variable 'document' has been set to an SBMLDocument object.
130   status = document.convert(config);
131   if (status != libsbml.LIBSBML_OPERATION_SUCCESS)
132   {
133     // Handle error somehow.
134     System.out.println('Error: conversion failed due to the following:');
135     document.printErrors();
136   }
137 @endcode
138 @endif
139  *
140  * Here is an example of using a converter that offers an option. The
141  * following code invokes SBMLStripPackageConverter to remove the
142  * SBML Level&nbsp;3 @em %Layout package from a model.  It sets the name
143  * of the package to be removed by adding a value for the option named
144  * @c 'package' defined by that converter:
145  *
146  * @if cpp
147  * @code{.cpp}
148 ConversionProperties props;
149 props.addOption('stripPackage');
150 props.addOption('package', 'layout');
151 
152 int status = document->convert(props);
153 if (status != LIBSBML_OPERATION_SUCCESS)
154 {
155     cerr << 'Unable to strip the Layout package from the model';
156     cerr << 'Error returned: ' << status;
157 }
158 @endcode
159 @endif
160 @if python
161 @code{.py}
162 def strip_layout_example(document):
163   config = ConversionProperties()
164   if config != None:
165     config.addOption('stripPackage')
166     config.addOption('package', 'layout')
167     status = document.convert(config)
168     if status != LIBSBML_OPERATION_SUCCESS:
169       # Handle error somehow.
170       print('Error: unable to strip the Layout package.')
171       print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip())
172   else:
173     # Handle error somehow.
174     print('Error: unable to create ConversionProperties object')
175 @endcode
176 @endif
177 @if java
178 @code{.java}
179 ConversionProperties config = new ConversionProperties();
180 if (config != None) {
181   config.addOption('stripPackage');
182   config.addOption('package', 'layout');
183   status = document.convert(config);
184   if (status != LIBSBML_OPERATION_SUCCESS) {
185     // Handle error somehow.
186     System.out.println('Error: unable to strip the Layout package');
187     document.printErrors();
188   }
189 } else {
190   // Handle error somehow.
191   System.out.println('Error: unable to create ConversionProperties object');
192 }
193 @endcode
194 @endif
195  *
196  * @subsection available-converters Available SBML converters in libSBML
197  *
198  * LibSBML provides a number of built-in converters; by convention, their
199  * names end in @em Converter. The following are the built-in converters
200  * provided by libSBML @htmlinclude libsbml-version.html:
201  *
202  * @copydetails doc_list_of_libsbml_converters
203  *
204  *
205  */
206 
207 public class SBMLUnitsConverter : SBMLConverter {
208 	private HandleRef swigCPtr;
209 
SBMLUnitsConverter(IntPtr cPtr, bool cMemoryOwn)210 	internal SBMLUnitsConverter(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.SBMLUnitsConverter_SWIGUpcast(cPtr), cMemoryOwn)
211 	{
212 		//super(libsbmlPINVOKE.SBMLUnitsConverterUpcast(cPtr), cMemoryOwn);
213 		swigCPtr = new HandleRef(this, cPtr);
214 	}
215 
getCPtr(SBMLUnitsConverter obj)216 	internal static HandleRef getCPtr(SBMLUnitsConverter obj)
217 	{
218 		return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
219 	}
220 
getCPtrAndDisown(SBMLUnitsConverter obj)221 	internal static HandleRef getCPtrAndDisown (SBMLUnitsConverter obj)
222 	{
223 		HandleRef ptr = new HandleRef(null, IntPtr.Zero);
224 
225 		if (obj != null)
226 		{
227 			ptr             = obj.swigCPtr;
228 			obj.swigCMemOwn = false;
229 		}
230 
231 		return ptr;
232 	}
233 
Dispose(bool disposing)234   protected override void Dispose(bool disposing) {
235     lock(this) {
236       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
237         if (swigCMemOwn) {
238           swigCMemOwn = false;
239           libsbmlPINVOKE.delete_SBMLUnitsConverter(swigCPtr);
240         }
241         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
242       }
243       base.Dispose(disposing);
244     }
245   }
246 
247 
248 /** */ /* libsbml-internal */ public
init()249  static void init() {
250     libsbmlPINVOKE.SBMLUnitsConverter_init();
251   }
252 
253 
254 /**
255    * Creates a new SBMLUnitsConverter object.
256    */ public
SBMLUnitsConverter()257  SBMLUnitsConverter() : this(libsbmlPINVOKE.new_SBMLUnitsConverter__SWIG_0(), true) {
258   }
259 
260 
261 /**
262    * Copy constructor; creates a copy of an SBMLUnitsConverter
263    * object.
264    *
265    * @param obj the SBMLUnitsConverter object to copy.
266    */ public
SBMLUnitsConverter(SBMLUnitsConverter obj)267  SBMLUnitsConverter(SBMLUnitsConverter obj) : this(libsbmlPINVOKE.new_SBMLUnitsConverter__SWIG_1(SBMLUnitsConverter.getCPtr(obj)), true) {
268     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
269   }
270 
271 
272 /**
273    * Creates and returns a deep copy of this SBMLUnitsConverter
274    * object.
275    *
276    * @return a (deep) copy of this converter.
277    */ public new
clone()278  SBMLConverter clone() {
279     global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLUnitsConverter_clone(swigCPtr);
280     SBMLUnitsConverter ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLUnitsConverter(cPtr, true);
281     return ret;
282   }
283 
284 
285 /**
286    * Returns @c true if this converter object's properties match the given
287    * properties.
288    *
289    * A typical use of this method involves creating a ConversionProperties
290    * object, setting the options desired, and then calling this method on
291    * an SBMLUnitsConverter object to find out if the object's
292    * property values match the given ones.  This method is also used by
293    * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif)
294    * to search across all registered converters for one matching particular
295    * properties.
296    *
297    * @param props the properties to match.
298    *
299    * @return @c true if this converter's properties match, @c false
300    * otherwise.
301    */ public new
matchesProperties(ConversionProperties props)302  bool matchesProperties(ConversionProperties props) {
303     bool ret = libsbmlPINVOKE.SBMLUnitsConverter_matchesProperties(swigCPtr, ConversionProperties.getCPtr(props));
304     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
305     return ret;
306   }
307 
308 
309 /**
310    * Perform the conversion.
311    *
312    * This method causes the converter to do the actual conversion work,
313    * that is, to convert the SBMLDocument object set by
314    * SBMLConverter::setDocument(@if java SBMLDocument@endif) and
315    * with the configuration options set by
316    * SBMLConverter::setProperties(@if java ConversionProperties@endif).
317    *
318    *
319  * @return integer value indicating success/failure of the
320  * function.  @if clike The value is drawn from the
321  * enumeration #OperationReturnValues_t. @endif The possible values
322  * returned by this function are:
323  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
324    * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink
325    * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink
326    * @li @link libsbml#LIBSBML_CONV_CONVERSION_NOT_AVAILABLE LIBSBML_CONV_CONVERSION_NOT_AVAILABLE@endlink
327    * @li @link libsbml#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT@endlink
328    */ public new
convert()329  int convert() {
330     int ret = libsbmlPINVOKE.SBMLUnitsConverter_convert(swigCPtr);
331     return ret;
332   }
333 
334 
335 /**
336    * Returns the default properties of this converter.
337    *
338    * A given converter exposes one or more properties that can be adjusted
339    * in order to influence the behavior of the converter.  This method
340    * returns the @em default property settings for this converter.  It is
341    * meant to be called in order to discover all the settings for the
342    * converter object.
343    *
344    * @return the ConversionProperties object describing the default properties
345    * for this converter.
346    */ public new
getDefaultProperties()347  ConversionProperties getDefaultProperties() {
348     ConversionProperties ret = new ConversionProperties(libsbmlPINVOKE.SBMLUnitsConverter_getDefaultProperties(swigCPtr), true);
349     return ret;
350   }
351 
352 }
353 
354 }
355