Component Data API

API Reference

In some contexts (e.g. on real-time operating systems) a single process may contain multiple instances of a component. Ordinary global or static variables will be shared across all instances of the component in the process. The Legato Component Data API provides a method to associate data with a specific component instance.

To create per-component instance data, use the LE_CDATA_DECLARE macro to declare your per-instance data at file scope:

int numFoo;
char* fooStr;

Only one component instance data can be declared per-file, and this data is only available within the file where it's declared.

Then use LE_CDATA_THIS to access the current component instance's data. For example:

LE_CDATA_THIS->numFoo = 5;