2.3. Using the reading context

If you have read the tutorials about writing a text and a graphic module, you should be fairly ready to use the information provided to your hook by the reading API.

The data structures of the reading context are based on the gobject, a object-oriented library from the glib. Some evolved types that are found in the context also comes from the "glib" (GArray, GHashTable and so on). For detailed information about "gobjects" and the "glib", see the www.gtk.org website. They provide a complete API reference about the data types they provide.

The reading context is object oriented. It is described by the lttv/tracecontext.h header. Is can be illustrated with this UML class diagram :

Linux Trace Toolkit Viewer Reading Context Class Diagram

Though, for performance's sake, navigating through it is not as encapsulated as it could. Consider the class attributes to be all public (no get/set functions). Sometimes, iteration upon a specific element can be uneasy. For example, you may have to get the number of tracefiles in a trace from the "vt" field of the trace context to be able to iterate over all the tracefiles contained by the trace.

To facilitate the common operations on the reading context, LTTV now provides a header that consists of simple macros : lttv/contextmacros.h. It gives an object look-and-feel to the context classes. Simple "GET" macros can be used to easily access the different fields are iterate over the elements (and get the total number of elements too).