You are here: Start » AVL.NET » AVL.NET - AVL Relation
AVL.NET - AVL Relation
Overview
AVL.NET is an AVL wrapper which means that when we call AVL.NET functions, we actually call native AVL functions. That requires the AVL.dll library to be present in the same location as the AvlNet.dll assembly when running the application that references AvlNet.dll assembly.
Functions
In .NET a function must be a member of some type (which makes it a method rather than a function). Therefore while in AVL functions
may be accessed through the namespace only (e.g. avl::AddImages(...)
), in AVL.NET all the library functions are
static methods of the Invoke
class:
using Avl; // Use function AddImages to add two images. Invoke.AddImages(image1, image2, null, 1.0f, imageSum);
Types
Most of the native AVL types have their counterpart in the AvlNet.Types.dll assembly. Internally, a managed type, if not a simple structure or enumeration type, may contain a native pointer to the AVL type. Because of those native pointers (unmanaged resources),
objects of those types need to be disposed properly
when not used any more to avoid memory leaks. This is guaranteed thanks to the
System.IDisposable
interface but it is the user's responsibility to call it's
Dispose method
to release resources immediately instead of leaving it to the next
Garbage Collection. This may increase the application performance. More about managing AvlNet types can be found here.
Optionals and Conditionals
The AVL's atl::Optional
and atl::Conditional
types are mapped by the Atl.Optional<T>
and Atl.Conditional<T>
respectively.
The table below lists how different types are handled in AVL.NET:
AVL Type | AVL.NET Type |
---|---|
int | int |
long | long |
float | float |
double | double |
bool | bool |
atl::String |
string |
atl::Optional<T> |
Atl.Optional<T> |
atl::Conditional<T> |
Atl.Conditional<T> |
atl::Array<T> |
System.Collections.Generic.List<T> |
Diagnostic outputs
All diagnostic outputs in AVL.NET are of type Avl.Diagnostic<T>
, all with default value of null which makes them an optional parameters.
For T
being a reference type it is safe to pass the T
variable to arguments expecting the Avl.Diagnostic<T>
values. This is due to implicit T
to Avl.Diagnostic<T>
conversion.
For value types Avl.Diagnostic<T>
object must be created before passing to the function, otherwise implicit conversion to Avl.Diagnostic<T>
will make the function operate on the copy of the T
object
and the result will not be passed back to the original T
variable.
Arguments with default value
Like in C++ functions, there are AvlNet functions with arguments having default values that can be skipped. However this feature is not reproduced in every case since C# is more restrictive about optional arguments. Namely, in AvlNet, optional arguments can be found only for the following types:
- Primitive types
- Value types with value as an expression of the form
default(T)
- Reference types with
null
value Atl.Optional<T>
withnull
valueAvl.Diagnostic<T>
withnull
value
Arguments of reference types other than Atl.Optional<T>
and Avl.Diagnostic<T>
are always required, even if the underlying C++ function have default value defined for that argument.
Previous: Getting Started with Aurora Vision Library .NET | Next: Serialization |