My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
regtemplate.h
1 #ifndef regtemplate_h
2 #define regtemplate_h
3 
4 /* ***** PLEASE READ BEFORE MAKING MODIFICATIONS *****
5  * If you make ANY modifications to the register template
6  * which make it incompatible with older archived register
7  * map templates, you must increment the REGMAP_REVISION
8  * macro at the top of regmap.h.
9  */
10 #include <string>
11 
12 /*
13  * This file defines the templates required by new_RegMap() for
14  * creating register maps. The resulting register map, and
15  * accompanying objects are defined in regmap.h.
16  */
17 #include "regmap.h"
18 
19 #define ARRAY_DIM(array) (sizeof(array)/sizeof((array)[0]))
20 
21 /*
22  * Each board can have up to NBASE base addresses. The choice of
23  * NBASE is arbitrary. Note, however, that if you change it, you
24  * must also change REGMAP_REVISION in regmap.h.
25  */
26 typedef enum {
27  REG_BASE0, /* To select the base address in RegBoardTemp::bases[0] */
28  REG_BASE1, /* To select the base address in RegBoardTemp::bases[1] */
29  REG_BASE2, /* To select the base address in RegBoardTemp::bases[2] */
30  REG_BASE3, /* To select the base address in RegBoardTemp::bases[3] */
31  NBASE /* The dimension of RegBoardTemp::bases[] */
32 } RegBase;
33 
34 /*
35  * The VME registers of a given board are specified via an array
36  * of the following type. This is a template for creation of a
37  * RegBlock object.
38  */
39 struct RegBlockTemp {
40  char name_[REG_NAME_LEN+1]; // The name of the block of registers
41  char axesHelp_[REG_NAME_LEN+1];
42  unsigned flags_; // A bit-set of RegFlags enumerators
43  RegAddrMode addr_mode_; // The addressing mode of the register
44  RegBase base_; // Use the base-address in board->bases[base]
45  unsigned address_; // The address of the block in the address
46  // space given by addr_mode (0 for REG_LOCAL)
47  gcp::util::CoordAxes* axes_; // An axis specifier for this register
48  std::string* comment_;
49 
50  //------------------------------------------------------------
51  // Methods associated with this struct
52  //------------------------------------------------------------
53 
54  // Constructors
55 
56  RegBlockTemp();
57  RegBlockTemp(std::string comment, std::string name, std::string axesHelp,
58  unsigned flags, unsigned address=0,
59  unsigned nel0=1, unsigned nel1=0, unsigned nel2=0);
60 
61  // Destructor
62 
63  ~RegBlockTemp();
64 
65  // Copy constructors
66 
67  RegBlockTemp(const RegBlockTemp& temp);
69 
70  // Assignment operators
71 
72  void operator=(const RegBlockTemp& temp);
73  void operator=(RegBlockTemp& temp);
74 
75  void initialize();
76 
77  // Return the total number of register elements
78 
79  unsigned nEl();
80 
81  // Return the number of bytes per element of this register
82 
83  unsigned nBytePerEl();
84 
85  // Return the size in bytes of this register
86 
87  unsigned sizeInBytes();
88 };
89 
90 /*
91  * Each board of registers is described by an element of the following
92  * type.
93  */
94 typedef struct {
95  char name_[REG_NAME_LEN+1]; // An unambiguous name for the board
96  RegBlockTemp* blocks_; // The registers of the board
97  int nblock_; // The number of register blocks in blocks[]
98  unsigned bases_[NBASE]; // An array of up to NBASE base addresses
99  char comment_[100];
100 } RegBoardTemp;
101 
105 typedef struct {
106  RegBoardTemp *boards; // The array of register-board maps
107  unsigned nboard; // The number of elements in boards[]
108  char comment_[100];
109 } RegTemplate;
110 
111 RegMap *net_get_RegMap(gcp::control::NetBuf *net);
112 
113 /* NB. del_RegMap() is prototyped in regmap.h */
114 
115 int net_put_RegTemplate(RegTemplate *regtmp, gcp::control::NetBuf *net);
116 RegTemplate *net_get_RegTemplate(gcp::control::NetBuf *net);
117 int net_RegTemplate_size(RegTemplate *regtmp);
118 
119 /*
120  * The following destructor should only be applied the dynamically
121  * allocated templates that are returned by net_get_RegTemplate().
122  */
123 RegTemplate *del_RegTemplate(RegTemplate *regtmp);
124 
125 #endif
unsigned nBytePerEl()
Definition: regtemplate.c:591
Definition: CoordAxes.h:25
Definition: regtemplate.h:39
Definition: netbuf.h:42
void initialize()
Definition: regtemplate.c:454
unsigned nEl()
Definition: regtemplate.c:573
Definition: regtemplate.h:105
unsigned sizeInBytes()
Definition: regtemplate.c:581
~RegBlockTemp()
Definition: regtemplate.c:557
Definition: regtemplate.h:94