|
39 | 39 | // class record: base class for application records. |
40 | 40 | // destructor: inline, ancrec.h. |
41 | 41 | //*************************************************************************************************************************** |
| 42 | +record::record(BP _b, TI i, SI noZ/*=0*/) // construct record i of basAnc b, zero all members unless noZ |
| 43 | +{ |
| 44 | + /* possible conditional statSetup elimination: |
| 45 | + if (i==0 (and at least b->rt matches if no validate()) and b->p==0 and b->n < b->mn, |
| 46 | + set b->p=this, mn/n/nAl 1 record, RFSTAT. BE SURE to override mn: 1-->0. |
| 47 | + if (i > 0 and b RFSTAT and b->p consistent and b->n==i-1, |
| 48 | + b->n++ : additional record in static array. |
| 49 | + CAUTION can be called from statSetup (til eliminated). */ |
| 50 | + |
| 51 | + _b->validate("record::record"); // abort if base bad -- we depend on it for size |
| 52 | + if (!noZ) // can be suppressed for data-init (static) records |
| 53 | + memset((char *)this + SZVFTP, 0, _b->eSz - SZVFTP); /* zero all members of DERIVED CLASS record |
| 54 | + except virtFcnTblPtr in 1st 2 or 4 bytes (ancrec.h define) */ |
| 55 | + b = _b; |
| 56 | + rt = _b->rt; |
| 57 | + ss = i; // set base class members, for appl and anchor class use |
| 58 | + gud = 1; // say space in use and record good |
| 59 | +} // record::record |
| 60 | +//--------------------------------------------------------------------------------------------------------------------------- |
42 | 61 | void* record::field( int fn) // point to member in record by FIELD # |
43 | 62 | { return (void *)((char *)this + b->fir[fn].off); } |
44 | 63 | //----------------------------------------------------------------------------- |
@@ -87,63 +106,10 @@ int record::DType( int fn) const |
87 | 106 | return dt; |
88 | 107 | } // record::DType |
89 | 108 | //----------------------------------------------------------------------------- |
90 | | -record::record( BP _b, TI i, SI noZ/*=0*/) // construct record i of basAnc b, zero all members unless noZ |
91 | | -{ |
92 | | - /* possible conditional statSetup elimination: |
93 | | - if (i==0 (and at least b->rt matches if no validate()) and b->p==0 and b->n < b->mn, |
94 | | - set b->p=this, mn/n/nAl 1 record, RFSTAT. BE SURE to override mn: 1-->0. |
95 | | - if (i > 0 and b RFSTAT and b->p consistent and b->n==i-1, |
96 | | - b->n++ : additional record in static array. |
97 | | - CAUTION can be called from statSetup (til eliminated). */ |
98 | | - |
99 | | - _b->validate("record::record"); // abort if base bad -- we depend on it for size |
100 | | - if (!noZ) // can be suppressed for data-init (static) records |
101 | | - memset( (char *)this+SZVFTP, 0, _b->eSz-SZVFTP); /* zero all members of DERIVED CLASS record |
102 | | - except virtFcnTblPtr in 1st 2 or 4 bytes (ancrec.h define) */ |
103 | | - b = _b; |
104 | | - rt = _b->rt; |
105 | | - ss = i; // set base class members, for appl and anchor class use |
106 | | - gud = 1; // say space in use and record good |
107 | | -} // record::record |
108 | | -//--------------------------------------------------------------------------------------------------------------------------- |
109 | | -#if 0 |
110 | | -x // 7-20-92: NOT COMPLETED: believe nothing would set virt fcn tbl ptr. |
111 | | -x |
112 | | -x not completed, believe won't work without further changes cuz virtual fcn table pointer of record won't get set. |
113 | | -x Instead, do same thing as record::record in record::init. |
114 | | -x User derived class constructors won't work (none anyway). Tested here, ancrec.h. 7-20-92. */ |
115 | | -x // failed cuz our operator= does not copy front members; = probably never copies vft. |
116 | | -x construct-in-place thoughts: |
117 | | -x 1. won't work as now cuz virt fcn tbl ptr not init since not constructed. |
118 | | -x 2. would be constructed if alloc'd with 'new'.. .p = new BLAHRAT[n]. |
119 | | -x --> interface record::new to dmAl( , WRN | DMZERO) |
120 | | -x then set .b, .i, etc on return (maybe at add(), in .init)? |
121 | | -x problem: no way to add records, unless we copy the virt fcn tbl ptr? |
122 | | -x x3. make = non-virtual, init on stack and copy. maybe provide an afterCopy virt fcn to dup ptrs. failed (above). |
123 | | -x 4. init on stack and memcpy! |
124 | | -x |
125 | | -x record::init( BP _b, TI i, SI noZ/*=0*/) // pseudo-construct record i of basAnc b, zero all members unless noZ. |
126 | | -x |
127 | | -x /* used to 'construct' previously-allocated record in place at use (when .add()'d) under BC 3.1, |
128 | | -x cuz couldn't get compiler to recognize call to constructor for method used under BC 3.0 (see ancrec.h). |
129 | | -x ***** --> derived class constructors won't override (but derived class init() should). 7-20-92. */ |
130 | | -x{ |
131 | | -x _b->validate("record::init"); // abort if base bad -- we depend on it for size |
132 | | -x if (!noZ) // can be suppressed for data-init (static) records |
133 | | -x memset( (char *)this+2, 0, _b->eSz-2); // zero all members of DERIVED CLASS record except virtFcnTblPtr in 1st 2 bytes |
134 | | -x b = _b; rt = _b->rt; ss = i; // set base class members, for appl and anchor class use |
135 | | -x gud = 1; // say space in use and record good |
136 | | -x} // record::init |
137 | | -#endif |
138 | | -//----------------------------------------------------------------------------- |
139 | 109 | int record::IsNameMatch( const char* _name) const |
140 | 110 | { |
141 | | -#if 0 // 7-2-2013 |
142 | | -x return strMatch( _name, name); |
143 | | -#else |
144 | 111 | // Note: prior (1994) version disregarded unexpected excess chars |
145 | 112 | return !_strnicmp( _name, name, sizeof(ANAME)-1); |
146 | | -#endif |
147 | 113 | } // record::IsNameMatch |
148 | 114 | //----------------------------------------------------------------------------- |
149 | 115 | /*virtual*/ record& record::CopyFrom( |
@@ -257,6 +223,17 @@ const char* record::getChoiTx( |
257 | 223 |
|
258 | 224 | } // record::getChoiTx |
259 | 225 | //----------------------------------------------------------------------------- |
| 226 | +record* record::getOwner() const |
| 227 | +// return ptr to owner record |
| 228 | +// NULL if linkage bad |
| 229 | +{ |
| 230 | + BP bOf = b->ownB; |
| 231 | + record* r = bOf ? bOf->GetAtSafe(ownTi) : NULL; |
| 232 | + if (!r) |
| 233 | + oer("getOwner() fail for %s", objIdTx()); |
| 234 | + return r; |
| 235 | +} // record::getOwner |
| 236 | +//----------------------------------------------------------------------------- |
260 | 237 | const char* record::whatIn() const // return basAnc record owner text |
261 | 238 | // e.g. "zone 'Z1'" or "sgdist 'foo' of glazing 'gl1' of zone 'Z1'" |
262 | 239 | { |
|
0 commit comments