You are here: Start » Introduction » Adaptive Template Library

Adaptive Template Library

Adaptive Vision Library 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 portable to embedded platforms, including the ones that do not support C++ templates fully.

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 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:

    Optional<Point2D> p;
    p = Point2D(10, 25);        // normal value
    p = atl::NIL;               // NIL value
    if (p != atl::NIL)
    {
        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", 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()

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.

For more convenient usage the dummy() macro is created.

Sample use:

    avl::Region region;
    avl::Circle2D circle = avl::Circle2D(50.0f, 50.0f, 50.0f);
    int width = 0.0f;
	
    avl::CreateCircularRegion(circle, atl::NIL, atl::NIL, region);
	
    // Second and forth parameters are not used.
    avl::RegionBoundingBox(region, dummy(avl::Box), width, dummy(int) );
	
    // Without using the dummy() macro.
    avl::RegionBoundingBox(region, atl::Dummy<avl::Box>().Get(), width, atl::Dummy<int>().Get() );
	
    printf("Region width: %d", width);
Previous: Programming Conventions Next: Getting Started