API lifetime#

Primary ItalaApi functionalities are accessible via an abstraction called system, which is the root of the API. To initialize the ItalaApi, the client code must initialize the system instance.

Warning

The client code is responsible for the system instance lifetime. The client code must create the system before using it and destroy it when it’s no longer required. As long as the system instance is alive, the ItalaApi can be used.

The SYS_Initialize free function initializes ItalaApi. The SYS_Dispose() function works exactly like a delete operator: it destroys the system instance.

#include "ItalaApiC/ItalaC.h"

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char **argv)
{
        ItalaError error = ItalaErrorSuccess;

        error = SYS_Initialize();
        if(error != ItalaErrorSuccess){
                printf("Error occured!\n");
        }

        // Use the method of ItalaApiC

        error = SYS_Dispose();
        if(error != ItalaErrorSuccess){
                printf("Error occured!\n");
        }
        printf("System instance disposed.\n");
        return 0;
}

Since the system is the root of the API, it is unique and only one instance is created at a time.