You are here: Start » Adaptive Template Library

Adaptive Template Library

Adaptive Vision Library Lite is based on the Adaptive Template Library – a simplified counterpart of the C++ Standard Template Library, which avoids advanced templating techniques mainly by using raw pointers instead of abstract iterators. This makes Adaptive Vision Library Lite portable to embedded platforms, including the ones that do not support C++ templates fully.

Please note, that the following types should only be parametrized with fundamental types (int, float, etc.) or types from avl or atl namespace. Const and/or reference types are also allowed, as long as template type accepts such type (e.g. Array<T> cannot be parametrized with reference type).

Array<T>

The Array<T> type strictly corresponds to std::vector<T>. It is a random-access, sequential container with automatic memory reallocation when growing.

Here is a simplified version of the public interface is depicted: Array.h

Optional<T>

The Optional<T> type provides a consistent way of representing an optional value, something for which NULL pointers or special values (such as -1) are often used. Many APIs provide optional values using default values of parameters. This type is inspired by boost::optional<T> class from the Boost Library, but is designed mostly for input parameters, not only for function results.

In Adaptive Vision Library Lite it is used to represent optional regions of interest in image processing operations and many other input parameters that can be determined automatically when not provided by an user.

Documentation for this type is presented in Optional.h.

Sample use:

atl::Optional<avl::Point2D> p;
p = avl::Point2D(10, 25);        // normal value
p = atl::NIL;               // NIL value
if (p != atl::NIL)
{
	avl::Point2D q = p.Get();    // access to a non-nil value
	p.Get().x = 15;         // direct access to a field
}

Conditional<T>

This type of data is especially used to determine invalid results. Many functions in C return special value as -1 or NULL when their result is invalid. Type Conditional<T> is very similar to Optional<T>, but it is mostly used in outputs.

Documentation for this type is presented in Conditional.h.

Sample use:

atl::Conditional<int> result;
avl::ParseInteger("Test1", avl::NumberSystemBase::Base_10, result);	// Parsing textual data

if (result != atl::NIL)			// If textual data is not valid integer result has value atl::NIL
	printf("Valid integer.");
else
	printf("Invalid integer. Value: %d", result.Get());

Dummy<T>

Dummy<T> class is used to create a temporary object that will be released after its use. It is mostly used to create a temporary object to pass its reference to a function. Such temporary objects are helpful when not all values returned by a function are important and we don't plan to use them.

Sample use:

avl::Region region;
avl::Circle2D circle = avl::Circle2D(50.0f, 50.0f, 50.0f);

avl::CreateCircleRegion(circle, atl::NIL, 100, 100, region);

// Second parameter is not used.
avl::Segment2D minorAxis;
avl::RegionEllipticAxes(region, atl::Dummy<avl::Segment2D>(), minorAxis);

std::cout << "Minor axis length: " << minorAxis.Length();
Previous: Programming Conventions Next: Getting Started