Difference between revisions of "Truxton media get load configuration id"

From truxwiki.com
Jump to navigation Jump to search
Line 17: Line 17:
  
 
=Sample=
 
=Sample=
<syntaxhighlight lang="C" highlight="3">
+
<source lang="C" highlight="3">
 
void dump_route(uint64_t media)
 
void dump_route(uint64_t media)
 
{
 
{
Line 23: Line 23:
  
 
   printf( "The media is using configuration %" PRIu64 " to process the data\n", id );
 
   printf( "The media is using configuration %" PRIu64 " to process the data\n", id );
}</syntaxhighlight>
+
}</source>
 +
 
 +
The <code>PRIu64</code> in the sample code above is a standard way of [https://en.wikipedia.org/wiki/C_data_types#Printf_and_scanf_format_specifiers formatting] a 64-bit unsigned integer in C.
 +
Over the years, different compilers on different operating systems used different format specifiers for things, these <code>PRI</code> macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.

Revision as of 07:27, 6 February 2021

This retrieves the load configuration used to load the data. This corresponds to the LoadConfigurationID column of the Media table. It should be a value from the ID column of the LoadConfiguration table. A load configuration is the mapping of file types to the message queues that will process it.

Syntax

uint64_t truxton_media_get_load_configuration_id( uint64_t media_handle );

Parameters

media_handle

The handle created by the truxton_media_open_id or truxton_media_create call.

Return value

The identifier for the load configuration.

Sample

void dump_route(uint64_t media)
{
   uint64_t id = truxton_media_get_load_configuration_id( media );

   printf( "The media is using configuration %" PRIu64 " to process the data\n", id );
}

The PRIu64 in the sample code above is a standard way of formatting a 64-bit unsigned integer in C. Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.