-
Notifications
You must be signed in to change notification settings - Fork 38
WriteBasicTrePlugin20C
anna-dodd edited this page Jun 3, 2015
·
1 revision
This API is subject to change
For 2.0, we have simplified the parsing description structures, making it easier to create a TRE plug-in
TRE parsing, in the NITRO library, is done using plug-ins. This allows us the same extensibility provided to the NITF specification itself. When we have a plug-in that can read a TRE, we use it. When we can't we use a special default handler.
Our library was designed to support all types of TREs, but to make it especially easy to handle typical, straight-forward TREs. In most cases, plug-in writers don't have to write any actually "code" -- they can get away with simply declaring a parsing description as an array of TREDescription objects, followed by a special macro that declares that this code is a plug-in (the macro does a whole lot of work for us). First, we need to have a plug-in in a separate C file:
The 2.0 release can support much more complicated plug-ins than the 1.5 version, since it was re-abstracted to use a TRE interface table. The 1.5 methodologies are still supported (as seen above), but custom plug-ins can be written to support just about anything. For more information on advanced TRE processing for 2.0, check out our advanced TRE snippet.
For more examples of simpple plug-ins, check out the shared section of our library. There are many examples that illustrate the syntax allowed in the TREDescription structures.
For 2.0, we have simplified the parsing description structures, making it easier to create a TRE plug-in
TRE parsing, in the NITRO library, is done using plug-ins. This allows us the same extensibility provided to the NITF specification itself. When we have a plug-in that can read a TRE, we use it. When we can't we use a special default handler.
Our library was designed to support all types of TREs, but to make it especially easy to handle typical, straight-forward TREs. In most cases, plug-in writers don't have to write any actually "code" -- they can get away with simply declaring a parsing description as an array of TREDescription objects, followed by a special macro that declares that this code is a plug-in (the macro does a whole lot of work for us). First, we need to have a plug-in in a separate C file:
/*
* MYTREA.c - demonstrate creation of a TRE handler for a made up TRE.
*/
#include <import/nitf.h>
static nitf_TREDescription description[] = {
{ NITF_BCS_A, 32, "Creator Name", "CREATOR" },
{ NITF_BCS_N, 4, "Num Contributors", "NCONTRIB" },
{ NITF_LOOP, 0, NULL, "NCONTRIB" }, /* Want to loop NCONTRIB times */
{ NITF_BCS_A, 32, "Contributor Name", "CONTRIBUTOR" },
{ NITF_ENDLOOP, 0, NULL, NULL},
{NITF_END, 0, NULL, NULL}
}
/*
* When we want to retrieve this data from our application, we need to get the TREs field named
* CONTRIBUTOR[0], CONTRIBUTOR[1], ..., CONTRIBUTOR[ncontrib-1]
*/
/* Expose this plugin */
NITF_DECLARE_SINGLE_PLUGIN(MYTREA, description)
* MYTREA.c - demonstrate creation of a TRE handler for a made up TRE.
*/
#include <import/nitf.h>
static nitf_TREDescription description[] = {
{ NITF_BCS_A, 32, "Creator Name", "CREATOR" },
{ NITF_BCS_N, 4, "Num Contributors", "NCONTRIB" },
{ NITF_LOOP, 0, NULL, "NCONTRIB" }, /* Want to loop NCONTRIB times */
{ NITF_BCS_A, 32, "Contributor Name", "CONTRIBUTOR" },
{ NITF_ENDLOOP, 0, NULL, NULL},
{NITF_END, 0, NULL, NULL}
}
/*
* When we want to retrieve this data from our application, we need to get the TREs field named
* CONTRIBUTOR[0], CONTRIBUTOR[1], ..., CONTRIBUTOR[ncontrib-1]
*/
/* Expose this plugin */
NITF_DECLARE_SINGLE_PLUGIN(MYTREA, description)
The 2.0 release can support much more complicated plug-ins than the 1.5 version, since it was re-abstracted to use a TRE interface table. The 1.5 methodologies are still supported (as seen above), but custom plug-ins can be written to support just about anything. For more information on advanced TRE processing for 2.0, check out our advanced TRE snippet.
For more examples of simpple plug-ins, check out the shared section of our library. There are many examples that illustrate the syntax allowed in the TREDescription structures.