next up previous
Next: 2 Making the Source Up: PrimEx Bank Definition Markup Previous: PrimEx Bank Definition Markup

1 Introduction

Adding a new bank to the PrimEx software system requires modifications to the code in at least two places: in the bank definition header file, src/libraries/include/bankdef.h, and in the routine where each bank is initialized, src/libraries/codaIO/PEvent.cc. In addition, we will maintain documentation where the bank format is described, perhaps in more than one place. To insure consistency among these locations, we define each bank in a single place: src/include/bankdef.xml and generate the source code files and (in the future) documentation files from this source. To define the banks in bankdef.xml we use a custom mark-up language, the Bank Definition Markup Language (BDML) to specify all of the necessary information. This is a form of the Extensible Mark-up Language (XML[1]). This standard is used widely and is maintained by the World Wide Web Consortium[2].

For example, the BDML snippet

<bank name="hycalhit" comment="HYCAL hit bank (calibrated)">
<column name="id" type="int" comment="HYCAL block ID" />
<column name="E" type="float" comment="energy deposited in block (GeV)" />
</bank>
will generate the code snippet
/*----- start of hycalhit bank -----*/
/* hycalhit: HYCAL hit bank (calibrated) */
 
typedef struct {
  int id; /* HYCAL block ID */
  float E; /* energy deposited in block (GeV) */
} hycalhit_t;
 
typedef struct {
  bankHeader_t bank;
  hycalhit_t *hycalhit;
} primHYCALHIT_t;
 
/*----- end of hycalhit bank -----*/
in bankdef.h and the code
InitializeBank((void**)&banks.HYCALHIT, "HYCALHIT", sizeof(hycalhit_t), BANKFLAG_NONE);
in PEvent.cc (via an include file).

In addition, structures can be defined outside of banks. For example

<struct name="bankHeader_t" comment="this is a general bank header definition">
<member name="nrow" type="int" comment="number of rows" />
<member name="maxrows" type="int" comment="maximum number of rows" />
<member name="size" type="int" comment="number of 4-byte words in a row" />
<member name="name[16]" type="char" comment="bank name" />
<member name="flags" type="int" comment="Flags defined from above enum" />
</struct>
generates the code
/* ----- start of bankHeader_t structure -----*/
/* bankHeader_t: this is a general bank header definition */
 
typedef struct {
  int nrow; /* number of rows */
  int maxrows; /* maximum number of rows */
  int size; /* number of 4-byte words in a row */
  char name[16]; /* bank name */
  int flags; /* Flags defined from above enum */
} bankHeader_t;
                                                                                
/*----- end of bankHeader_t structure -----*/
in bankdef.h. For structures, no code is generated in PEvent.cc.


next up previous
Next: 2 Making the Source Up: PrimEx Bank Definition Markup Previous: PrimEx Bank Definition Markup
Mark M. Ito 2003-12-10