From bb2689b491dd87be6a13db36bb34339cfa772ec0 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 30 Apr 1999 15:24:53 +0000 Subject: [PATCH] fixed improper container index bug --- src/gdd/dbMapper.cc | 232 +++++++++++++++++++++------------------- src/gdd/dbMapper.h | 11 +- src/gdd/gdd.cc | 136 ++++++++++++++++++++--- src/gdd/gdd.h | 176 ++++++++++++++++++++---------- src/gdd/gddAppTable.cc | 76 ++++++------- src/gdd/gddAppTable.h | 15 +-- src/gdd/gddArray.cc | 7 +- src/gdd/gddArray.h | 9 +- src/gdd/gddContainer.cc | 40 +++---- src/gdd/gddContainer.h | 15 ++- src/gdd/gddContainerI.h | 14 +-- src/gdd/gddI.h | 185 +++++++++++++++++++++++--------- src/gdd/gddScalar.h | 5 +- 13 files changed, 590 insertions(+), 331 deletions(-) diff --git a/src/gdd/dbMapper.cc b/src/gdd/dbMapper.cc index 69840f648..8ebeaf79a 100644 --- a/src/gdd/dbMapper.cc +++ b/src/gdd/dbMapper.cc @@ -4,6 +4,9 @@ // $Id$ // // $Log$ +// Revision 1.21 1999/01/28 19:12:46 jhill +// fixed a mostly benign string array bounds over reach +// // Revision 1.20 1998/06/16 03:12:40 jhill // added comments // @@ -100,7 +103,7 @@ // we explicitly specify extern // epicsShareDef extern const chtype gddAitToDbr[] = { - 0, + DBR_STRING, DBR_CHAR, DBR_CHAR, DBR_SHORT, @@ -111,10 +114,13 @@ epicsShareDef extern const chtype gddAitToDbr[] = { DBR_FLOAT, DBR_DOUBLE, DBR_STRING, - DBR_STRING, - 999 + DBR_STRING }; +/* + * application type ("app" field) is initialized + * at run tim using the "app_name" field. + */ epicsShareDef gddDbrToAitTable gddDbrToAit[] = { // normal { aitEnumFixedString, 0, "value" }, @@ -190,23 +196,23 @@ static gdd* mapStringToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToString(void* vd, aitIndex count, gdd* dd) { +static int mapGddToString(void* vd, aitIndex count, const gdd& dd) { aitFixedString* db = (aitFixedString*)vd; - aitIndex sz = dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz = dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count<=sz) { if(local_data_format==aitLocalDataFormat) { if((aitFixedString*)v!=db) { - status = aitConvert(aitEnumFixedString,db,dd->primitiveType(),v,count); + status = aitConvert(aitEnumFixedString,db,dd.primitiveType(),v,count); } else { status = sz*sizeof(aitFixedString); } } else { - status = aitConvertToNet(aitEnumFixedString,db,dd->primitiveType(),v,count); + status = aitConvertToNet(aitEnumFixedString,db,dd.primitiveType(),v,count); } } else { @@ -231,23 +237,23 @@ static gdd* mapShortToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToShort(void* vd, aitIndex count, gdd* dd) { +static int mapGddToShort(void* vd, aitIndex count, const gdd &dd) { dbr_short_t* sv = (dbr_short_t*)vd; - aitIndex sz = dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz = dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if (local_data_format==aitLocalDataFormat) { if((dbr_short_t*)v!=sv) { - status = aitConvert(aitEnumInt16,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumInt16,sv,dd.primitiveType(),v,sz); } else { status = sz*sizeof(dbr_short_t); } } else { - status = aitConvertToNet(aitEnumInt16,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumInt16,sv,dd.primitiveType(),v,sz); } } else { @@ -272,23 +278,23 @@ static gdd* mapFloatToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToFloat(void* vd, aitIndex count, gdd* dd) { +static int mapGddToFloat(void* vd, aitIndex count, const gdd& dd) { dbr_float_t* sv = (dbr_float_t*)vd; - aitIndex sz=dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz=dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if(local_data_format==aitLocalDataFormat) { if((dbr_float_t*)v!=sv) { - status = aitConvert(aitEnumFloat32,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumFloat32,sv,dd.primitiveType(),v,sz); } else { status = sz*sizeof(dbr_float_t); } } else { - status = aitConvertToNet(aitEnumFloat32,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumFloat32,sv,dd.primitiveType(),v,sz); } } else { @@ -313,23 +319,23 @@ static gdd* mapEnumToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToEnum(void* vd, aitIndex count, gdd* dd) { +static int mapGddToEnum(void* vd, aitIndex count, const gdd& dd) { dbr_enum_t* sv = (dbr_enum_t*)vd; - aitIndex sz=dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz=dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if(local_data_format==aitLocalDataFormat) { if((dbr_enum_t*)v!=sv) { - status = aitConvert(aitEnumEnum16,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumEnum16,sv,dd.primitiveType(),v,sz); } else { status = sizeof(dbr_enum_t)*count; } } else { - status = aitConvertToNet(aitEnumEnum16,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumEnum16,sv,dd.primitiveType(),v,sz); } } else { @@ -354,23 +360,23 @@ static gdd* mapCharToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToChar(void* vd, aitIndex count, gdd* dd) { +static int mapGddToChar(void* vd, aitIndex count, const gdd& dd) { dbr_char_t* sv = (dbr_char_t*)vd; - aitIndex sz=dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz=dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if (local_data_format==aitLocalDataFormat) { if((dbr_char_t*)v!=sv) { - status = aitConvert(aitEnumInt8,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumInt8,sv,dd.primitiveType(),v,sz); } else { status = sz*sizeof(dbr_char_t); } } else { - status = aitConvertToNet(aitEnumInt8,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumInt8,sv,dd.primitiveType(),v,sz); } } else { @@ -395,23 +401,23 @@ static gdd* mapLongToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToLong(void* vd, aitIndex count, gdd* dd) { +static int mapGddToLong(void* vd, aitIndex count, const gdd& dd) { dbr_long_t* sv = (dbr_long_t*)vd; - aitIndex sz=dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz=dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if (local_data_format==aitLocalDataFormat) { if ((dbr_long_t*)v!=sv) { - status = aitConvert(aitEnumInt32,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumInt32,sv,dd.primitiveType(),v,sz); } else { status = count*sizeof(dbr_long_t); } } else { - status = aitConvertToNet(aitEnumInt32,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumInt32,sv,dd.primitiveType(),v,sz); } } else { @@ -436,23 +442,23 @@ static gdd* mapDoubleToGdd(void* v,aitIndex count) { return dd; } -static int mapGddToDouble(void* vd, aitIndex count, gdd* dd) { +static int mapGddToDouble(void* vd, aitIndex count, const gdd& dd) { dbr_double_t* sv = (dbr_double_t*)vd; - aitIndex sz=dd->getDataSizeElements(); - void* v=dd->dataVoid(); + aitIndex sz=dd.getDataSizeElements(); + void* v=dd.dataVoid(); int status; if (count==sz) { if (local_data_format==aitLocalDataFormat) { if ((dbr_double_t*)v!=sv) { - status = aitConvert(aitEnumFloat64,sv,dd->primitiveType(),v,sz); + status = aitConvert(aitEnumFloat64,sv,dd.primitiveType(),v,sz); } else { status = count*sizeof(dbr_double_t); } } else { - status = aitConvertToNet(aitEnumFloat64,sv,dd->primitiveType(),v,sz); + status = aitConvertToNet(aitEnumFloat64,sv,dd.primitiveType(),v,sz); } } else { @@ -489,12 +495,12 @@ static gdd* mapStsStringToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToString(void* v, aitIndex count, gdd* dd) +static int mapStsGddToString(void* v, aitIndex count, const gdd& dd) { dbr_sts_string* db = (dbr_sts_string*)v; aitFixedString* dbv = (aitFixedString*)db->value; - dd->getStatSevr(db->status,db->severity); + dd.getStatSevr(db->status,db->severity); return mapGddToString(dbv, count, dd); } @@ -506,10 +512,10 @@ static gdd* mapStsShortToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToShort(void* v, aitIndex count, gdd* dd) +static int mapStsGddToShort(void* v, aitIndex count, const gdd& dd) { dbr_sts_short* dbv = (dbr_sts_short*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); return mapGddToShort(&dbv->value, count, dd); } @@ -521,10 +527,10 @@ static gdd* mapStsFloatToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToFloat(void* v, aitIndex count, gdd* dd) +static int mapStsGddToFloat(void* v, aitIndex count, const gdd& dd) { dbr_sts_float* dbv = (dbr_sts_float*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); return mapGddToFloat(&dbv->value,count,dd); } @@ -536,10 +542,10 @@ static gdd* mapStsEnumToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToEnum(void* v, aitIndex count, gdd* dd) +static int mapStsGddToEnum(void* v, aitIndex count, const gdd& dd) { dbr_sts_enum* dbv = (dbr_sts_enum*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); return mapGddToEnum(&dbv->value,count,dd); } @@ -551,10 +557,10 @@ static gdd* mapStsCharToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToChar(void* v, aitIndex count, gdd* dd) +static int mapStsGddToChar(void* v, aitIndex count, const gdd& dd) { dbr_sts_char* dbv = (dbr_sts_char*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); dbv->RISC_pad = '\0'; // shut up purify return mapGddToChar(&dbv->value,count,dd); } @@ -567,10 +573,10 @@ static gdd* mapStsLongToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToLong(void* v, aitIndex count, gdd* dd) +static int mapStsGddToLong(void* v, aitIndex count, const gdd& dd) { dbr_sts_long* dbv = (dbr_sts_long*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); return mapGddToLong(&dbv->value,count,dd); } @@ -582,10 +588,10 @@ static gdd* mapStsDoubleToGdd(void* v,aitIndex count) return dd; } -static int mapStsGddToDouble(void* v, aitIndex count, gdd* dd) +static int mapStsGddToDouble(void* v, aitIndex count, const gdd& dd) { dbr_sts_double* dbv = (dbr_sts_double*)v; - dd->getStatSevr(dbv->status,dbv->severity); + dd.getStatSevr(dbv->status,dbv->severity); dbv->RISC_pad = 0; // shut up purify return mapGddToDouble(&dbv->value,count,dd); } @@ -618,13 +624,13 @@ static gdd* mapTimeStringToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToString(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToString(void* v, aitIndex count, const gdd& dd) { dbr_time_string* db = (dbr_time_string*)v; aitFixedString* dbv = (aitFixedString*)db->value; - dd->getStatSevr(db->status,db->severity); - dd->getTimeStamp((aitTimeStamp*)&db->stamp); + dd.getStatSevr(db->status,db->severity); + dd.getTimeStamp((aitTimeStamp*)&db->stamp); return mapGddToString(dbv, count, dd); } @@ -637,11 +643,11 @@ static gdd* mapTimeShortToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToShort(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToShort(void* v, aitIndex count, const gdd& dd) { dbr_time_short* dbv = (dbr_time_short*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); dbv->RISC_pad = 0; // shut up purify return mapGddToShort(&dbv->value,count,dd); } @@ -655,11 +661,11 @@ static gdd* mapTimeFloatToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToFloat(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToFloat(void* v, aitIndex count, const gdd& dd) { dbr_time_float* dbv = (dbr_time_float*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); return mapGddToFloat(&dbv->value,count,dd); } @@ -672,11 +678,11 @@ static gdd* mapTimeEnumToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToEnum(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToEnum(void* v, aitIndex count, const gdd& dd) { dbr_time_enum* dbv = (dbr_time_enum*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); dbv->RISC_pad = 0; // shut up purify return mapGddToEnum(&dbv->value,count,dd); } @@ -690,11 +696,11 @@ static gdd* mapTimeCharToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToChar(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToChar(void* v, aitIndex count, const gdd& dd) { dbr_time_char* dbv = (dbr_time_char*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); dbv->RISC_pad0 = 0; // shut up purify dbv->RISC_pad1 = '\0'; // shut up purify return mapGddToChar(&dbv->value,count,dd); @@ -709,11 +715,11 @@ static gdd* mapTimeLongToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToLong(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToLong(void* v, aitIndex count, const gdd& dd) { dbr_time_long* dbv = (dbr_time_long*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); return mapGddToLong(&dbv->value,count,dd); } @@ -726,11 +732,11 @@ static gdd* mapTimeDoubleToGdd(void* v,aitIndex count) return dd; } -static int mapTimeGddToDouble(void* v, aitIndex count, gdd* dd) +static int mapTimeGddToDouble(void* v, aitIndex count, const gdd& dd) { dbr_time_double* dbv = (dbr_time_double*)v; - dd->getStatSevr(dbv->status,dbv->severity); - dd->getTimeStamp((aitTimeStamp*)&dbv->stamp); + dd.getStatSevr(dbv->status,dbv->severity); + dd.getTimeStamp((aitTimeStamp*)&dbv->stamp); dbv->RISC_pad = 0; // shut up purify return mapGddToDouble(&dbv->value,count,dd); } @@ -814,11 +820,11 @@ static gdd* mapControlShortToGdd(void* v, aitIndex count) return dd; } -static int mapGraphicGddToShort(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToShort(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_gr_short* db = (dbr_gr_short*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_short_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_short_value]; dd[gddAppTypeIndex_dbr_gr_short_units].getRef(str); if(str->string()) { @@ -834,14 +840,14 @@ static int mapGraphicGddToShort(void* v, aitIndex count, gdd* dd) db->upper_warning_limit=dd[gddAppTypeIndex_dbr_gr_short_alarmHighWarning]; vdd.getStatSevr(db->status,db->severity); - return mapGddToShort(&db->value,count,&vdd); + return mapGddToShort(&db->value,count,vdd); } -static int mapControlGddToShort(void* v, aitIndex count, gdd* dd) +static int mapControlGddToShort(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_ctrl_short* db = (dbr_ctrl_short*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_short_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_short_value]; dd[gddAppTypeIndex_dbr_ctrl_short_units].getRef(str); if(str->string()) { @@ -859,7 +865,7 @@ static int mapControlGddToShort(void* v, aitIndex count, gdd* dd) db->upper_warning_limit=dd[gddAppTypeIndex_dbr_ctrl_short_alarmHighWarning]; vdd.getStatSevr(db->status,db->severity); - return mapGddToShort(&db->value,count,&vdd); + return mapGddToShort(&db->value,count,vdd); } // -------------map the float structures---------------- @@ -939,11 +945,11 @@ static gdd* mapControlFloatToGdd(void* v, aitIndex count) return dd; } -static int mapGraphicGddToFloat(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToFloat(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_gr_float* db = (dbr_gr_float*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_float_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_float_value]; dd[gddAppTypeIndex_dbr_gr_float_units].getRef(str); if(str->string()) { @@ -961,14 +967,14 @@ static int mapGraphicGddToFloat(void* v, aitIndex count, gdd* dd) db->RISC_pad0 = 0; // shut up purify vdd.getStatSevr(db->status,db->severity); - return mapGddToFloat(&db->value,count,&vdd); + return mapGddToFloat(&db->value,count,vdd); } -static int mapControlGddToFloat(void* v, aitIndex count, gdd* dd) +static int mapControlGddToFloat(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_ctrl_float* db = (dbr_ctrl_float*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_float_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_float_value]; dd[gddAppTypeIndex_dbr_ctrl_float_units].getRef(str); if(str->string()) { @@ -988,7 +994,7 @@ static int mapControlGddToFloat(void* v, aitIndex count, gdd* dd) db->RISC_pad = 0; // shut up purify vdd.getStatSevr(db->status,db->severity); - return mapGddToFloat(&db->value,count,&vdd); + return mapGddToFloat(&db->value,count,vdd); } // -------------map the enum structures---------------- @@ -1076,12 +1082,12 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/) return dd; } -static int mapGraphicGddToEnum(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToEnum(void* v, aitIndex count, const gdd& dd) { dbr_gr_enum* db = (dbr_gr_enum*)v; - gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums]; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_enum_value]; - aitFixedString* str = menu; + const gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_enum_value]; + const aitFixedString* str = menu; aitFixedString* f = (aitFixedString*)db->strs; int i; @@ -1096,15 +1102,15 @@ static int mapGraphicGddToEnum(void* v, aitIndex count, gdd* dd) db->strs[i][MAX_ENUM_STRING_SIZE-1u] = '\0'; } } - return mapGddToEnum(&db->value, count, &vdd); + return mapGddToEnum(&db->value, count, vdd); } -static int mapControlGddToEnum(void* v, aitIndex count, gdd* dd) +static int mapControlGddToEnum(void* v, aitIndex count, const gdd& dd) { dbr_ctrl_enum* db = (dbr_ctrl_enum*)v; - gdd& menu = dd[gddAppTypeIndex_dbr_ctrl_enum_enums]; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_enum_value]; - aitFixedString* str = menu; + const gdd& menu = dd[gddAppTypeIndex_dbr_ctrl_enum_enums]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_enum_value]; + const aitFixedString* str = menu; aitFixedString* f = (aitFixedString*)db->strs; int i; @@ -1119,7 +1125,7 @@ static int mapControlGddToEnum(void* v, aitIndex count, gdd* dd) db->strs[i][sizeof(aitFixedString)-1u] = '\0'; } } - return mapGddToEnum(&db->value, count, &vdd); + return mapGddToEnum(&db->value, count, vdd); } // -------------map the char structures---------------- @@ -1197,11 +1203,11 @@ static gdd* mapControlCharToGdd(void* v, aitIndex count) return dd; } -static int mapGraphicGddToChar(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToChar(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_gr_char* db = (dbr_gr_char*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_char_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_char_value]; dd[gddAppTypeIndex_dbr_gr_char_units].getRef(str); if(str->string()) { @@ -1218,14 +1224,14 @@ static int mapGraphicGddToChar(void* v, aitIndex count, gdd* dd) db->RISC_pad = 0; vdd.getStatSevr(db->status,db->severity); - return mapGddToChar(&db->value,count,&vdd); + return mapGddToChar(&db->value,count,vdd); } -static int mapControlGddToChar(void* v, aitIndex count, gdd* dd) +static int mapControlGddToChar(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_ctrl_char* db = (dbr_ctrl_char*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_char_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_char_value]; dd[gddAppTypeIndex_dbr_ctrl_char_units].getRef(str); if(str->string()) { @@ -1244,7 +1250,7 @@ static int mapControlGddToChar(void* v, aitIndex count, gdd* dd) db->RISC_pad = '\0'; // shut up purify vdd.getStatSevr(db->status,db->severity); - return mapGddToChar(&db->value,count,&vdd); + return mapGddToChar(&db->value,count,vdd); } // -------------map the long structures---------------- @@ -1322,11 +1328,11 @@ static gdd* mapControlLongToGdd(void* v, aitIndex count) return dd; } -static int mapGraphicGddToLong(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToLong(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_gr_long* db = (dbr_gr_long*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_long_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_long_value]; dd[gddAppTypeIndex_dbr_gr_long_units].getRef(str); if(str->string()) { @@ -1342,14 +1348,14 @@ static int mapGraphicGddToLong(void* v, aitIndex count, gdd* dd) db->upper_warning_limit=dd[gddAppTypeIndex_dbr_gr_long_alarmHighWarning]; vdd.getStatSevr(db->status,db->severity); - return mapGddToLong(&db->value,count,&vdd); + return mapGddToLong(&db->value,count,vdd); } -static int mapControlGddToLong(void* v, aitIndex count, gdd* dd) +static int mapControlGddToLong(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_ctrl_long* db = (dbr_ctrl_long*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_long_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_long_value]; dd[gddAppTypeIndex_dbr_ctrl_long_units].getRef(str); if(str->string()) { @@ -1367,7 +1373,7 @@ static int mapControlGddToLong(void* v, aitIndex count, gdd* dd) db->upper_warning_limit=dd[gddAppTypeIndex_dbr_ctrl_long_alarmHighWarning]; vdd.getStatSevr(db->status,db->severity); - return mapGddToLong(&db->value,count,&vdd); + return mapGddToLong(&db->value,count,vdd); } // -------------map the double structures---------------- @@ -1447,11 +1453,11 @@ static gdd* mapControlDoubleToGdd(void* v, aitIndex count) return dd; } -static int mapGraphicGddToDouble(void* v, aitIndex count, gdd* dd) +static int mapGraphicGddToDouble(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_gr_double* db = (dbr_gr_double*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_gr_double_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_gr_double_value]; dd[gddAppTypeIndex_dbr_gr_double_units].getRef(str); if(str->string()) { @@ -1469,14 +1475,14 @@ static int mapGraphicGddToDouble(void* v, aitIndex count, gdd* dd) db->RISC_pad0 = 0; // shut up purify vdd.getStatSevr(db->status,db->severity); - return mapGddToDouble(&db->value,count,&vdd); + return mapGddToDouble(&db->value,count,vdd); } -static int mapControlGddToDouble(void* v, aitIndex count, gdd* dd) +static int mapControlGddToDouble(void* v, aitIndex count, const gdd& dd) { aitString* str; dbr_ctrl_double* db = (dbr_ctrl_double*)v; - gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_double_value]; + const gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_double_value]; dd[gddAppTypeIndex_dbr_ctrl_double_units].getRef(str); if(str->string()) { @@ -1496,7 +1502,7 @@ static int mapControlGddToDouble(void* v, aitIndex count, gdd* dd) db->RISC_pad0 = '\0'; // shut up purify vdd.getStatSevr(db->status,db->severity); - return mapGddToDouble(&db->value,count,&vdd); + return mapGddToDouble(&db->value,count,vdd); } // ----------------must run this to use mapping functions-------------- diff --git a/src/gdd/dbMapper.h b/src/gdd/dbMapper.h index 52989a392..3334c2282 100644 --- a/src/gdd/dbMapper.h +++ b/src/gdd/dbMapper.h @@ -8,6 +8,9 @@ * $Id$ * * $Log$ + * Revision 1.4 1997/08/05 00:51:10 jhill + * fixed problems in aitString and the conversion matrix + * * Revision 1.3 1997/04/23 17:12:57 jhill * fixed export of symbols from WIN32 DLL * @@ -44,7 +47,7 @@ typedef gdd* (*to_gdd)(void* db_struct, aitIndex element_count); // number of elements that the value field of db_struct points to if the // gdd points to an array or -1 if the number of elements in the value // field is not identical to element_count available in db_struct. -typedef int (*to_dbr)(void* db_struct, aitIndex element_count, gdd*); +typedef int (*to_dbr)(void* db_struct, aitIndex element_count, const gdd &); struct gddDbrMapFuncTable { to_gdd conv_gdd; @@ -59,9 +62,9 @@ struct gddDbrToAitTable { }; typedef struct gddDbrToAitTable gddDbrToAitTable; -epicsShareExtern gddDbrToAitTable gddDbrToAit[]; -epicsShareExtern const chtype gddAitToDbr[]; -epicsShareExtern const gddDbrMapFuncTable gddMapDbr[]; +epicsShareExtern gddDbrToAitTable gddDbrToAit[35]; +epicsShareExtern const chtype gddAitToDbr[12]; +epicsShareExtern const gddDbrMapFuncTable gddMapDbr[35]; epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable& tt); epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable* tt); diff --git a/src/gdd/gdd.cc b/src/gdd/gdd.cc index 278cb9e0a..877dded86 100644 --- a/src/gdd/gdd.cc +++ b/src/gdd/gdd.cc @@ -4,6 +4,9 @@ // $Id$ // // $Log$ +// Revision 1.26 1998/10/26 11:18:41 lange +// Bug in gdd::~gdd fixed (CA gateway crashes). +// // Revision 1.25 1998/06/23 15:10:36 jhill // fixed use of nill ptr in gdd::put(const gdd* dd) // @@ -187,7 +190,13 @@ void gdd::init(int app, aitEnum prim, int dimen) gdd::gdd(gdd* dd) { - ref_cnt=1; + // + // added this because the "copy()" below bombs + // if the GDD isnt initialized + // joh - 4-23-99 + // + this->init (dd->appl_type, dd->primitiveType(), dd->dimension()); + copyInfo(dd); } @@ -313,9 +322,16 @@ gddStatus gdd::genCopy(aitEnum t, const void* d, aitDataFormat f) } else { - setData(buf); destruct=new gddDestructor; - destruct->reference(); + if (destruct==NULL) { + gddAutoPrint("gdd::genCopy()",gddErrorNewFailed); + rc=gddErrorNewFailed; + free (buf); + } + else { + setData(buf); + destruct->reference(); + } } } if(rc==0) @@ -374,7 +390,7 @@ gddStatus gdd::setBound(unsigned index_dim, aitIndex first, aitIndex count) return rc; } -gddStatus gdd::getBound(unsigned index_dim, aitIndex& first, aitIndex& count) +gddStatus gdd::getBound(unsigned index_dim, aitIndex& first, aitIndex& count) const { gddStatus rc=0; if(index_dimapplicationType(),dd->primitiveType(),dd->dimension()); - if(dd->isScalar()) - data=dd->data; + if(dd->isScalar()) { + if (dd->primitiveType()==aitEnumString) { + aitString* pStrDest =(aitString*)&data; + aitString* pStrSrc =(aitString*)&dd->data; + *pStrDest = *pStrSrc; + } + else if (dd->primitiveType()==aitEnumFixedString) { + aitFixedString* pStrDest =(aitFixedString*)data.Pointer; + aitFixedString* pStrSrc =(aitFixedString*)dd->data.Pointer; + memcpy (pStrDest, pStrSrc, sizeof(aitFixedString)); + } + else { + data=dd->data; + } + } else // atomic { const gddBounds* bnds = dd->getBounds(); @@ -444,9 +473,16 @@ gddStatus gdd::copyStuff(gdd* dd,int ctype) if( (array=new aitUint8[a_size]) ) { destruct=new gddDestructor; - destruct->reference(); - memcpy(array,dd->dataPointer(),a_size); - setData(array); + if (destruct!=NULL) { + destruct->reference(); + memcpy(array,dd->dataPointer(),a_size); + setData(array); + } + else { + free (array); + gddAutoPrint("gdd::copyStuff()",gddErrorNewFailed); + rc=gddErrorNewFailed; + } } else { @@ -1014,6 +1050,17 @@ gddStatus gdd::clear(void) return gddErrorNotAllowed; } + + if(isScalar()) + { + // + // this code clears out aitString and + // aitFixedString scalars + // + // joh 4-23-99 + // + changeType(0,aitEnumInvalid); + } if(isAtomic()) { destroyData(); @@ -1065,7 +1112,7 @@ gddStatus gdd::reset(aitEnum prim, int dimen, aitIndex* cnt) return rc; } -void gdd::get(aitString& d) +void gdd::get(aitString& d) const { if(primitiveType()==aitEnumString) { @@ -1075,7 +1122,7 @@ void gdd::get(aitString& d) else get(aitEnumString,&d); } -void gdd::get(aitFixedString& d) +void gdd::get(aitFixedString& d) const { if(primitiveType()==aitEnumFixedString){ strncpy(d.fixed_string,data.FString->fixed_string, @@ -1086,12 +1133,12 @@ void gdd::get(aitFixedString& d) get(aitEnumFixedString,&d); } -void gdd::getConvert(aitString& d) +void gdd::getConvert(aitString& d) const { get(aitEnumString,&d); } -void gdd::getConvert(aitFixedString& d) +void gdd::getConvert(aitFixedString& d) const { get(aitEnumFixedString,d.fixed_string); } @@ -1246,8 +1293,15 @@ gddStatus gdd::put(const gdd* dd) if((arr=new aitUint8[sz])) { destruct=new gddDestructor; - destruct->reference(); - setData(arr); + if (destruct!=NULL) { + destruct->reference(); + setData(arr); + } + else { + free (arr); + gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNewFailed); + rc=gddErrorNewFailed; + } } else { @@ -1558,9 +1612,57 @@ void gdd::setPrimType (aitEnum t) } // - // I (joh) assume that nothing needs to be done when - // the primative type of a container changes + // I (joh) assume that something needs to be done when + // the primative type of a container changes, but I + // have not looked into this so far. // this->prim_type = t; } + +// +// gdd::indexDD() +// +// modified by JOH 4-23-99 so that the correct method +// is used if the container gdd is not organized +// as an array of GDDs in memory (i.e. its not flat) +// +const gdd* gdd::indexDD (aitIndex index) const +{ + aitIndex i; + unsigned nElem; + + if (index==0u) { + return this; + } + + // + // otherwise this had better be a container + // we are indexing + // + assert (this->prim_type==aitEnumContainer); + + // + // catch out of bounds index + // + nElem = getDataSizeElements(); + assert (index<=nElem); + + // + // if the container GDD is "flat" + // + if (this->isFlat()) { + return this + index; + } + + // + // otherwise linear search for it + // + gdd* dd = (gdd*) dataPointer(); + i = nElem; + while (i>index) { + dd=(gdd*)dd->next(); + i--; + } + return dd; +} \ No newline at end of file diff --git a/src/gdd/gdd.h b/src/gdd/gdd.h index 5e0b07f31..02d0f3400 100644 --- a/src/gdd/gdd.h +++ b/src/gdd/gdd.h @@ -8,6 +8,9 @@ * $Id$ * * $Log$ + * Revision 1.25 1998/05/05 21:09:52 jhill + * removed backslash which conuses cpp + * * Revision 1.24 1997/08/05 00:51:12 jhill * fixed problems in aitString and the conversion matrix * @@ -127,7 +130,7 @@ #include "aitConvert.h" class gddContainer; -class gddAtomic; +class gddArray; class gddScalar; // Not Complete in this prototype: @@ -193,7 +196,9 @@ public: aitEnum primitiveType(void) const; unsigned dimension(void) const; aitType& getData(void); + const aitType& getData(void) const; aitType* dataUnion(void); + const aitType* dataUnion(void) const; gddDestructor* destructor(void) const; gdd* next(void); void setNext(gdd*); @@ -201,7 +206,7 @@ public: const gddBounds* getBounds(void) const; const gddBounds* getBounds(int bn) const; - void dump(void); + void dump(void) const; void test(void); void setPrimType(aitEnum t); @@ -212,7 +217,7 @@ public: gddStatus clear(void); // clear all fields of the DD, including arrays gddStatus changeType(int appltype, aitEnum primtype); gddStatus setBound(unsigned dim_to_set, aitIndex first, aitIndex count); - gddStatus getBound(unsigned dim_to_get, aitIndex& first, aitIndex& count); + gddStatus getBound(unsigned dim_to_get, aitIndex& first, aitIndex& count) const; gddStatus registerDestructor(gddDestructor*); gddStatus replaceDestructor(gddDestructor*); void* dataVoid(void) const; @@ -234,7 +239,7 @@ public: aitUint16 getStat(void) const; aitUint16 getSevr(void) const; void setStatSevr(aitInt16 stat, aitInt16 sevr); - void getStatSevr(aitInt16& stat, aitInt16& sevr); + void getStatSevr(aitInt16& stat, aitInt16& sevr) const; size_t getTotalSizeBytes(void) const; size_t getDataSizeBytes(void) const; @@ -287,6 +292,17 @@ public: gdd& operator=(const gdd& v); // get a pointer to the data in the DD + void getRef(const aitFloat64*& d) const; + void getRef(const aitFloat32*& d) const; + void getRef(const aitUint32*& d) const; + void getRef(const aitInt32*& d) const; + void getRef(const aitUint16*& d) const; + void getRef(const aitInt16*& d) const; + void getRef(const aitUint8*& d) const; + void getRef(const aitInt8*& d) const; + void getRef(const aitString*& d) const; + void getRef(const aitFixedString*& d) const; + void getRef(const void*& d) const; void getRef(aitFloat64*& d); void getRef(aitFloat32*& d); void getRef(aitUint32*& d); @@ -326,16 +342,16 @@ public: gddStatus putRef(const gdd*); // get the data in the form the user wants (do conversion) - void getConvert(aitFloat64& d); - void getConvert(aitFloat32& d); - void getConvert(aitUint32& d); - void getConvert(aitInt32& d); - void getConvert(aitUint16& d); - void getConvert(aitInt16& d); - void getConvert(aitUint8& d); - void getConvert(aitInt8& d); - void getConvert(aitString& d); - void getConvert(aitFixedString& d); + void getConvert(aitFloat64& d) const; + void getConvert(aitFloat32& d) const; + void getConvert(aitUint32& d) const; + void getConvert(aitInt32& d) const; + void getConvert(aitUint16& d) const; + void getConvert(aitInt16& d) const; + void getConvert(aitUint8& d) const; + void getConvert(aitInt8& d) const; + void getConvert(aitString& d) const; + void getConvert(aitFixedString& d) const; // convert the user data to the type in the DD and set value void putConvert(aitFloat64 d); @@ -376,31 +392,31 @@ public: gddStatus put(aitType* d); // copy the array data out of the DD - void get(void* d); - void get(void* d,aitEnum); - void get(aitFloat64* d); - void get(aitFloat32* d); - void get(aitUint32* d); - void get(aitInt32* d); - void get(aitUint16* d); - void get(aitInt16* d); - void get(aitUint8* d); - void get(aitInt8* d); - void get(aitString* d); - void get(aitFixedString* d); + void get(void* d) const; + void get(void* d,aitEnum) const; + void get(aitFloat64* d) const; + void get(aitFloat32* d) const; + void get(aitUint32* d) const; + void get(aitInt32* d) const; + void get(aitUint16* d) const; + void get(aitInt16* d) const; + void get(aitUint8* d) const; + void get(aitInt8* d) const; + void get(aitString* d) const; + void get(aitFixedString* d) const; // copy the data out of the DD - void get(aitFloat64& d); - void get(aitFloat32& d); - void get(aitUint32& d); - void get(aitInt32& d); - void get(aitUint16& d); - void get(aitInt16& d); - void get(aitUint8& d); - void get(aitInt8& d); - void get(aitString& d); - void get(aitFixedString& d); - void get(aitType& d); + void get(aitFloat64& d) const; + void get(aitFloat32& d) const; + void get(aitUint32& d) const; + void get(aitInt32& d) const; + void get(aitUint16& d) const; + void get(aitInt16& d) const; + void get(aitUint8& d) const; + void get(aitInt8& d) const; + void get(aitString& d) const; + void get(aitFixedString& d) const; + void get(aitType& d) const; // Same as putRef() methods gdd& operator=(aitFloat64* v); @@ -427,34 +443,73 @@ public: // gdd& operator=(aitFixedString d); // not present // Same as getRef() methods - operator aitFloat64*(void) const; - operator aitFloat32*(void) const; - operator aitUint32*(void) const; - operator aitInt32*(void) const; - operator aitUint16*(void) const; - operator aitInt16*(void) const; - operator aitUint8*(void) const; - operator aitInt8*(void) const; - operator aitString*(void) const; - operator aitFixedString*(void) const; + operator const aitFloat64*(void) const; + operator const aitFloat32*(void) const; + operator const aitUint32*(void) const; + operator const aitInt32*(void) const; + operator const aitUint16*(void) const; + operator const aitInt16*(void) const; + operator const aitUint8*(void) const; + operator const aitInt8*(void) const; + operator const aitString*(void) const; + operator const aitFixedString*(void) const; + + operator aitFloat64*(void); + operator aitFloat32*(void); + operator aitUint32*(void); + operator aitInt32*(void); + operator aitUint16*(void); + operator aitInt16*(void); + operator aitUint8*(void); + operator aitInt8*(void); + operator aitString*(void); + operator aitFixedString*(void); // Same as get() methods - operator aitFloat64(void); - operator aitFloat32(void); - operator aitUint32(void); - operator aitInt32(void); - operator aitUint16(void); - operator aitInt16(void); - operator aitUint8(void); - operator aitInt8(void); - operator aitString(void); + operator aitFloat64(void) const; + operator aitFloat32(void) const; + operator aitUint32(void) const; + operator aitInt32(void) const; + operator aitUint16(void) const; + operator aitInt16(void) const; + operator aitUint8(void) const; + operator aitInt8(void) const; + operator aitString(void) const; // gdd::operator aitFixedString(void); // not present + // + // added by JOH 4-23-99 so that the correct method + // is used if the container gdd is not organized + // as an array of GDDs in memory + // + // note that this requires a reference (pointers + // do not invoke this function) + // + gdd & operator [] (aitIndex index); + const gdd & operator [] (aitIndex index) const; + gdd & operator [] (int index); + const gdd & operator [] (int index) const; + + // + // The following can be slow and inefficient + // if the GDD isnt "flat" + // + // Only appropriate for container GDDs + // + const gdd* getDD(aitIndex index) const; + const gdd* getDD(aitIndex index, const gddScalar*&) const; + const gdd* getDD(aitIndex index, const gddArray*&) const; + const gdd* getDD(aitIndex index, const gddContainer*&) const; + gdd* getDD(aitIndex index); + gdd* getDD(aitIndex index,gddScalar*&); + gdd* getDD(aitIndex index,gddArray*&); + gdd* getDD(aitIndex index,gddContainer*&); + gddStatus genCopy(aitEnum t, const void* d, aitDataFormat f=aitLocalDataFormat); void adjust(gddDestructor* d,void* v,aitEnum type, aitDataFormat f=aitLocalDataFormat); - void get(aitEnum t,void* v,aitDataFormat f=aitLocalDataFormat); + void get(aitEnum t,void* v,aitDataFormat f=aitLocalDataFormat) const; void set(aitEnum t,const void* v,aitDataFormat f=aitLocalDataFormat); // following methods are used to import and export data into and out @@ -485,7 +540,7 @@ protected: void init(int app, aitEnum prim, int dimen); void freeBounds(void); - void dumpInfo(void); + void dumpInfo(void) const; gddStatus copyStuff(gdd*,int type); gddStatus clearData(void); @@ -513,13 +568,16 @@ protected: private: aitUint16 ref_cnt; aitUint8 flags; + + const gdd* gdd::indexDD (aitIndex index) const; }; -#include "gddI.h" // include these to be backward compatible with first gdd library version #include "gddArray.h" #include "gddScalar.h" #include "gddContainer.h" +#include "gddI.h" + #endif diff --git a/src/gdd/gddAppTable.cc b/src/gdd/gddAppTable.cc index 231eccc6d..519612f16 100644 --- a/src/gdd/gddAppTable.cc +++ b/src/gdd/gddAppTable.cc @@ -4,6 +4,9 @@ // $Id$ // // $Log$ +// Revision 1.9 1997/08/05 00:51:14 jhill +// fixed problems in aitString and the conversion matrix +// // Revision 1.8 1997/04/23 17:13:01 jhill // fixed export of symbols from WIN32 DLL // @@ -497,10 +500,9 @@ aitUint32 gddApplicationTypeTable::getValue(aitUint32 ap) // ----------------------smart copy functions------------------------ // the source in the container we must walk through is this called -gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::copyDD_src(gdd& dest, const gdd& src) { gddStatus rc=0,s; - gddContainer* cdd; gddCursor cur; gdd* dd; aitIndex index; @@ -508,52 +510,52 @@ gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* src) // this could be done better (faster) if we did not always recurse for // each GDD. I could have checked for type container before recursing. - if(src->isContainer()) + if(src.isContainer()) { + gddContainer& cdd = (gddContainer&) src; + // go through src gdd and map app types to index into dest - cdd=(gddContainer*)src; - cur=cdd->getCursor(); - for(dd=cur.first();dd;dd=dd->next()) copyDD_src(dest,dd); + cur=cdd.getCursor(); + for(dd=cur.first();dd;dd=dd->next()) copyDD_src(dest,*dd); } else { // find src gdd in dest container and just do put() - s=mapAppToIndex(dest->applicationType(),src->applicationType(),index); + s=mapAppToIndex(dest.applicationType(),src.applicationType(),index); if(s==0) - rc=dest[index].put(src); + rc=dest[index].put(&src); } return rc; } // the destination in the container we must walk through is this called -gddStatus gddApplicationTypeTable::copyDD_dest(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::copyDD_dest(gdd& dest, const gdd& src) { gddStatus rc=0,s; - gddContainer* cdd; gddCursor cur; gdd* dd; aitIndex index; - if(dest->isContainer()) + if(dest.isContainer()) { + gddContainer& cdd = (gddContainer&) dest; // go through dest gdd and map app types to index into src - cdd=(gddContainer*)dest; - cur=cdd->getCursor(); - for(dd=cur.first();dd;dd=dd->next()) copyDD_dest(dd,src); + cur=cdd.getCursor(); + for(dd=cur.first();dd;dd=dd->next()) copyDD_dest(*dd,src); } else { // find dest gdd in src container and just do put() - s=mapAppToIndex(src->applicationType(),dest->applicationType(),index); + s=mapAppToIndex(src.applicationType(),dest.applicationType(),index); if(s==0) - rc=dest->put(&src[index]); + rc=dest.put(&src[index]); } return rc; } -gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, const gdd* src) { gddStatus rc=0; @@ -561,9 +563,9 @@ gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src) // feature is used. if(dest->isContainer() && dest->isManaged()) - rc=copyDD_src(dest,src); + rc=copyDD_src(*dest,*src); else if(src->isContainer() && src->isManaged()) - rc=copyDD_dest(dest,src); + rc=copyDD_dest(*dest,*src); else if(!src->isContainer() && !dest->isContainer()) rc=dest->put(src); // both are not containers, let gdd handle it else @@ -575,10 +577,9 @@ gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src) // ----------------------smart reference functions------------------------ // the source in the container we must walk through is this called -gddStatus gddApplicationTypeTable::refDD_src(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::refDD_src(gdd& dest, const gdd& src) { gddStatus rc=0,s; - gddContainer* cdd; gddCursor cur; gdd* dd; aitIndex index; @@ -586,52 +587,51 @@ gddStatus gddApplicationTypeTable::refDD_src(gdd* dest, gdd* src) // this could be done better (faster) if we did not always recurse for // each GDD. I could have checked for type container before recursing. - if(src->isContainer()) + if(src.isContainer()) { + gddContainer& cdd=(gddContainer&)src; // go through src gdd and map app types to index into dest - cdd=(gddContainer*)src; - cur=cdd->getCursor(); - for(dd=cur.first();dd;dd=dd->next()) refDD_src(dest,dd); + cur=cdd.getCursor(); + for(dd=cur.first();dd;dd=dd->next()) refDD_src(dest,*dd); } else { // find src gdd in dest container and just do put() - s=mapAppToIndex(dest->applicationType(),src->applicationType(),index); + s=mapAppToIndex(dest.applicationType(),src.applicationType(),index); if(s==0) - rc=dest[index].putRef(src); + rc=dest[index].putRef(&src); } return rc; } // the destination in the container we must walk through is this called -gddStatus gddApplicationTypeTable::refDD_dest(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::refDD_dest(gdd& dest, const gdd& src) { gddStatus rc=0,s; - gddContainer* cdd; gddCursor cur; gdd* dd; aitIndex index; - if(dest->isContainer()) + if(dest.isContainer()) { + gddContainer& cdd=(gddContainer&)dest; // go through dest gdd and map app types to index into src - cdd=(gddContainer*)dest; - cur=cdd->getCursor(); - for(dd=cur.first();dd;dd=dd->next()) refDD_dest(dd,src); + cur=cdd.getCursor(); + for(dd=cur.first();dd;dd=dd->next()) refDD_dest(*dd,src); } else { // find dest gdd in src container and just do put() - s=mapAppToIndex(src->applicationType(),dest->applicationType(),index); + s=mapAppToIndex(src.applicationType(),dest.applicationType(),index); if(s==0) - rc=dest->putRef(&src[index]); + rc=dest.putRef(&src[index]); } return rc; } -gddStatus gddApplicationTypeTable::smartRef(gdd* dest, gdd* src) +gddStatus gddApplicationTypeTable::smartRef(gdd* dest, const gdd* src) { gddStatus rc=0; @@ -639,9 +639,9 @@ gddStatus gddApplicationTypeTable::smartRef(gdd* dest, gdd* src) // feature is used. if(dest->isContainer() && dest->isManaged()) - rc=refDD_src(dest,src); + rc=refDD_src(*dest,*src); else if(src->isContainer() && src->isManaged()) - rc=refDD_dest(dest,src); + rc=refDD_dest(*dest,*src); else if(!src->isContainer() && !dest->isContainer()) rc=dest->putRef(src); // both are not containers, let gdd handle it else diff --git a/src/gdd/gddAppTable.h b/src/gdd/gddAppTable.h index 552a44d89..0ad84740b 100644 --- a/src/gdd/gddAppTable.h +++ b/src/gdd/gddAppTable.h @@ -8,6 +8,9 @@ * $Id$ * * $Log$ + * Revision 1.5 1997/04/23 17:13:02 jhill + * fixed export of symbols from WIN32 DLL + * * Revision 1.4 1997/01/12 20:32:49 jbk * many errors fixed * @@ -125,8 +128,8 @@ public: // copy as best as possible from src to dest, one of the gdd must be // managed for this to succeed - gddStatus smartCopy(gdd* dest, gdd* src); - gddStatus smartRef(gdd* dest, gdd* src); + gddStatus smartCopy(gdd* dest, const gdd* src); + gddStatus smartRef(gdd* dest, const gdd* src); // old style interface int tagC2I(const char* const ctag, int& tag); @@ -155,10 +158,10 @@ public: protected: void GenerateTypes(void); - gddStatus copyDD_src(gdd* dest, gdd* src); - gddStatus copyDD_dest(gdd* dest, gdd* src); - gddStatus refDD_src(gdd* dest, gdd* src); - gddStatus refDD_dest(gdd* dest, gdd* src); + gddStatus copyDD_src(gdd& dest, const gdd& src); + gddStatus copyDD_dest(gdd& dest, const gdd& src); + gddStatus refDD_src(gdd& dest, const gdd& src); + gddStatus refDD_dest(gdd& dest, const gdd& src); private: gddStatus splitApplicationType(aitUint32 r,aitUint32& g,aitUint32& a) const; diff --git a/src/gdd/gddArray.cc b/src/gdd/gddArray.cc index 5f342293b..36cc8f25b 100644 --- a/src/gdd/gddArray.cc +++ b/src/gdd/gddArray.cc @@ -7,6 +7,9 @@ // // $Id$ // $Log$ +// Revision 1.2 1997/04/23 17:13:02 jhill +// fixed export of symbols from WIN32 DLL +// // Revision 1.1 1997/03/21 01:56:04 jbk // *** empty log message *** // @@ -31,7 +34,7 @@ gddAtomic::gddAtomic(int app, aitEnum prim, int dimen, ...): va_end(ap); } -gddStatus gddAtomic::getBoundingBoxSize(aitUint32* b) +gddStatus gddAtomic::getBoundingBoxSize(aitUint32* b) const { unsigned i; gddStatus rc=0; @@ -63,7 +66,7 @@ gddStatus gddAtomic::setBoundingBoxSize(const aitUint32* const b) return rc; } -gddStatus gddAtomic::getBoundingBoxOrigin(aitUint32* b) +gddStatus gddAtomic::getBoundingBoxOrigin(aitUint32* b) const { unsigned i; gddStatus rc=0; diff --git a/src/gdd/gddArray.h b/src/gdd/gddArray.h index b88a2200a..5585b85d0 100644 --- a/src/gdd/gddArray.h +++ b/src/gdd/gddArray.h @@ -7,6 +7,9 @@ * * $Id$ * $Log$ + * Revision 1.2 1997/04/23 17:13:03 jhill + * fixed export of symbols from WIN32 DLL + * * Revision 1.1 1997/03/21 01:56:05 jbk * *** empty log message *** * @@ -32,12 +35,12 @@ public: gddArray(int app, aitEnum prim, int dimen, ...); // view dimension size info as a bounding box instead of first/count - gddStatus getBoundingBoxSize(aitUint32* put_info_here); + gddStatus getBoundingBoxSize(aitUint32* put_info_here) const; gddStatus setBoundingBoxSize(const aitUint32* const get_info_from_here); - gddStatus getBoundingBoxOrigin(aitUint32* put_info_here); + gddStatus getBoundingBoxOrigin(aitUint32* put_info_here) const; gddStatus setBoundingBoxOrigin(const aitUint32* const get_info_from_here); - void dump(void); + void dump(void) const; void test(void); gddArray& operator=(aitFloat64* v) { *((gdd*)this)=v; return *this; } diff --git a/src/gdd/gddContainer.cc b/src/gdd/gddContainer.cc index df8e2b674..866d4f687 100644 --- a/src/gdd/gddContainer.cc +++ b/src/gdd/gddContainer.cc @@ -8,6 +8,9 @@ // // $Id$ // $Log$ +// Revision 1.2 1997/04/23 17:13:03 jhill +// fixed export of symbols from WIN32 DLL +// // Revision 1.1 1997/03/21 01:56:05 jbk // *** empty log message *** // @@ -47,12 +50,28 @@ void gddContainer::cInit(int tot) setData(dd_list); } + gddContainer::gddContainer(gddContainer* ec) { + // + // added this because the "copy()" below bombs + // if the GDD isnt initialized + // joh - 4-23-99 + // + this->init (ec->appl_type, aitEnumContainer, 1); + +#if 1 + // + // this replaces some the strange code below + // that existed before + // joh - 4-23-99 + // + copyInfo(ec); +#else unsigned i; gdd* dd_list; gdd* temp; - + copy(ec); dd_list=NULL; @@ -67,24 +86,7 @@ gddContainer::gddContainer(gddContainer* ec) dd_list=temp; } setData(dd_list); -} - -gdd* gddContainer::getDD(aitIndex index) -{ - if (index==0u) { - return this; - } - else if(index>getDataSizeElements()) - return NULL; - else - { - aitIndex i; - gdd* dd=(gdd*)dataPointer(); - for(i=1u;inext(); - } - return dd; - } +#endif } gddStatus gddContainer::insert(gdd* dd) diff --git a/src/gdd/gddContainer.h b/src/gdd/gddContainer.h index 911650d12..9836d7f45 100644 --- a/src/gdd/gddContainer.h +++ b/src/gdd/gddContainer.h @@ -7,6 +7,9 @@ * * $Id$ * $Log$ + * Revision 1.2 1997/04/23 17:13:04 jhill + * fixed export of symbols from WIN32 DLL + * * Revision 1.1 1997/03/21 01:56:06 jbk * *** empty log message *** * @@ -29,18 +32,11 @@ public: gddStatus insert(gdd*); gddStatus remove(aitIndex index); - int total(void); + int total(void) const; - void dump(void); + void dump(void) const; void test(void); - // The following are slow and inefficient - gdd* getDD(aitIndex index); - gdd* getDD(aitIndex index,gddScalar*&); - gdd* getDD(aitIndex index,gddAtomic*&); - gdd* getDD(aitIndex index,gddContainer*&); - gdd* operator[](aitIndex index); - // preferred method for looking into a container gddCursor getCursor(void) const; gdd* cData(void) const; @@ -87,6 +83,7 @@ public: gdd* current(gddContainer*&); gdd* operator[](int index); + private: const gddContainer* list; gdd* curr; diff --git a/src/gdd/gddContainerI.h b/src/gdd/gddContainerI.h index cb5c515fa..3aa282cd3 100644 --- a/src/gdd/gddContainerI.h +++ b/src/gdd/gddContainerI.h @@ -7,21 +7,17 @@ * * $Id$ * $Log$ + * Revision 1.1 1997/03/21 01:56:07 jbk + * *** empty log message *** + * * */ inline gdd* gddContainer::cData(void) const { return (gdd*)dataPointer(); } -inline int gddContainer::total(void) +inline int gddContainer::total(void) const { return bounds->size(); } -inline gdd* gddContainer::operator[](aitIndex index) - { return getDD(index); } -inline gdd* gddContainer::getDD(aitIndex index,gddScalar*& dd) - { return (gdd*)(dd=(gddScalar*)getDD(index)); } -inline gdd* gddContainer::getDD(aitIndex index,gddAtomic*& dd) - { return (gdd*)(dd=(gddAtomic*)getDD(index)); } -inline gdd* gddContainer::getDD(aitIndex index,gddContainer*& dd) - { return (gdd*)(dd=(gddContainer*)getDD(index)); } + inline gddStatus gddContainer::setBound(aitIndex f, aitIndex c) { bounds->set(f,c); return 0; } diff --git a/src/gdd/gddI.h b/src/gdd/gddI.h index 06b2c47dd..9d8d4c444 100644 --- a/src/gdd/gddI.h +++ b/src/gdd/gddI.h @@ -8,6 +8,9 @@ * $Id$ * * $Log$ + * Revision 1.3 1998/06/16 03:16:27 jhill + * fixed big problems with leaked ait/fixedString in gdd union + * * Revision 1.2 1997/08/05 00:51:15 jhill * fixed problems in aitString and the conversion matrix * @@ -32,7 +35,9 @@ inline gdd* gdd::next(void) { return nextgdd; } inline void gdd::setNext(gdd* n) { nextgdd=n; } inline unsigned gdd::dimension(void) const { return dim; } inline aitType& gdd::getData(void) { return data; } +inline const aitType& gdd::getData(void) const { return data; } inline aitType* gdd::dataUnion(void) { return &data; } +inline const aitType* gdd::dataUnion(void)const { return &data; } inline void gdd::setApplType(int t) { appl_type=(aitUint16)t; } inline gddStatus gdd::copyInfo(gdd* dd) { return copyStuff(dd,0); } inline gddStatus gdd::copy(gdd* dd) { return copyStuff(dd,1); } @@ -93,7 +98,7 @@ inline aitUint16 gdd::getStat(void) const { aitUint16* x = (aitUint16*)&status; return x[0]; } inline aitUint16 gdd::getSevr(void) const { aitUint16* x = (aitUint16*)&status; return x[1]; } -inline void gdd::getStatSevr(aitInt16& st, aitInt16& se) +inline void gdd::getStatSevr(aitInt16& st, aitInt16& se) const { st=getStat(); se=getSevr(); } inline void gdd::setStatSevr(aitInt16 st, aitInt16 se) { setStat(st); setSevr(se); } @@ -199,9 +204,9 @@ inline void gdd::adjust(gddDestructor* d, void* v, aitEnum type,aitDataFormat) // before you putConvert() something into it. #if aitLocalNetworkDataFormatSame == AIT_FALSE -inline void gdd::get(aitEnum t,void* v,aitDataFormat f) +inline void gdd::get(aitEnum t,void* v,aitDataFormat f) const #else -inline void gdd::get(aitEnum t,void* v,aitDataFormat) +inline void gdd::get(aitEnum t,void* v,aitDataFormat) const #endif { if(primitiveType()==aitEnumFixedString) @@ -240,6 +245,17 @@ inline void gdd::set(aitEnum t,const void* v,aitDataFormat) } // -------------------getRef(data pointer) functions---------------- +inline void gdd::getRef(const aitFloat64*& d)const { d=(aitFloat64*)dataVoid(); } +inline void gdd::getRef(const aitFloat32*& d)const { d=(aitFloat32*)dataVoid(); } +inline void gdd::getRef(const aitUint32*& d)const { d=(aitUint32*)dataVoid(); } +inline void gdd::getRef(const aitInt32*& d)const { d=(aitInt32*)dataVoid(); } +inline void gdd::getRef(const aitUint16*& d)const { d=(aitUint16*)dataVoid(); } +inline void gdd::getRef(const aitInt16*& d)const { d=(aitInt16*)dataVoid(); } +inline void gdd::getRef(const aitUint8*& d)const { d=(aitUint8*)dataVoid(); } +inline void gdd::getRef(const aitInt8*& d)const { d=(aitInt8*)dataVoid(); } +inline void gdd::getRef(const void*& d)const { d=dataVoid(); } +inline void gdd::getRef(const aitFixedString*& d)const { d=(aitFixedString*)dataVoid(); } +inline void gdd::getRef(const aitString*& d)const { d=(aitString*)dataVoid(); } inline void gdd::getRef(aitFloat64*& d) { d=(aitFloat64*)dataVoid(); } inline void gdd::getRef(aitFloat32*& d) { d=(aitFloat32*)dataVoid(); } inline void gdd::getRef(aitUint32*& d) { d=(aitUint32*)dataVoid(); } @@ -299,14 +315,14 @@ inline void gdd::putRef(const aitFixedString* v,gddDestructor* d) { adjust(d, (void*)v, aitEnumFixedString); markConstant(); } // -------------------getConvert(scalar) functions ---------------------- -inline void gdd::getConvert(aitFloat64& d) { get(aitEnumFloat64,&d); } -inline void gdd::getConvert(aitFloat32& d) { get(aitEnumFloat32,&d); } -inline void gdd::getConvert(aitUint32& d) { get(aitEnumUint32,&d); } -inline void gdd::getConvert(aitInt32& d) { get(aitEnumInt32,&d); } -inline void gdd::getConvert(aitUint16& d) { get(aitEnumUint16,&d); } -inline void gdd::getConvert(aitInt16& d) { get(aitEnumInt16,&d); } -inline void gdd::getConvert(aitUint8& d) { get(aitEnumUint8,&d); } -inline void gdd::getConvert(aitInt8& d) { get(aitEnumInt8,&d); } +inline void gdd::getConvert(aitFloat64& d) const { get(&d, aitEnumFloat64); } +inline void gdd::getConvert(aitFloat32& d) const { get(&d, aitEnumFloat32); } +inline void gdd::getConvert(aitUint32& d) const { get(&d, aitEnumUint32); } +inline void gdd::getConvert(aitInt32& d) const { get(&d, aitEnumInt32); } +inline void gdd::getConvert(aitUint16& d) const { get(&d, aitEnumUint16); } +inline void gdd::getConvert(aitInt16& d) const { get(&d, aitEnumInt16); } +inline void gdd::getConvert(aitUint8& d) const { get(&d, aitEnumUint8); } +inline void gdd::getConvert(aitInt8& d) const { get(&d, aitEnumInt8); } // -------------------putConvert(scalar) functions ---------------------- inline void gdd::putConvert(aitFloat64 d){ set(aitEnumFloat64,&d); } @@ -412,20 +428,20 @@ inline gddStatus gdd::put(aitType* d) { } // ---------------------get(pointer) functions-------------------------- -inline void gdd::get(void* d) { +inline void gdd::get(void* d) const { if(isScalar()) aitConvert(primitiveType(),d,primitiveType(),dataAddress(),1); else aitConvert(primitiveType(),d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(void* d,aitEnum e) { +inline void gdd::get(void* d,aitEnum e) const { if(isScalar()) aitConvert(e,d,primitiveType(),dataAddress(),1); else aitConvert(e,d,primitiveType(),dataPointer(),getDataSizeElements()); } -inline void gdd::get(aitFloat64* d) +inline void gdd::get(aitFloat64* d) const { if(isScalar()) aitConvert(aitEnumFloat64,d,primitiveType(),dataAddress(),1); @@ -433,56 +449,56 @@ inline void gdd::get(aitFloat64* d) aitConvert(aitEnumFloat64,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitFloat32* d) { +inline void gdd::get(aitFloat32* d) const { if(isScalar()) aitConvert(aitEnumFloat32,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumFloat32,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitUint32* d) { +inline void gdd::get(aitUint32* d) const { if(isScalar()) aitConvert(aitEnumUint32,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumUint32,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitInt32* d) { +inline void gdd::get(aitInt32* d) const { if(isScalar()) aitConvert(aitEnumInt32,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumInt32,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitUint16* d) { +inline void gdd::get(aitUint16* d) const { if(isScalar()) aitConvert(aitEnumUint16,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumUint16,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitInt16* d) { +inline void gdd::get(aitInt16* d) const { if(isScalar()) aitConvert(aitEnumInt16,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumInt16,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitUint8* d) { +inline void gdd::get(aitUint8* d) const { if(isScalar()) aitConvert(aitEnumUint8,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumUint8,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitString* d) { +inline void gdd::get(aitString* d) const { if(isScalar()) aitConvert(aitEnumString,d,primitiveType(),dataAddress(),1); else aitConvert(aitEnumString,d,primitiveType(),dataPointer(), getDataSizeElements()); } -inline void gdd::get(aitFixedString* d) { +inline void gdd::get(aitFixedString* d) const { if(isScalar()) aitConvert(aitEnumFixedString,d,primitiveType(),dataAddress(),1); else @@ -491,7 +507,7 @@ inline void gdd::get(aitFixedString* d) { } // special case for string scalar to aitInt8 array! -inline void gdd::get(aitInt8* d) +inline void gdd::get(aitInt8* d) const { if(primitiveType()==aitEnumString && dim==0) { @@ -506,39 +522,39 @@ inline void gdd::get(aitInt8* d) } // ------------------get(scalar) functions----------------- -inline void gdd::get(aitFloat64& d) { +inline void gdd::get(aitFloat64& d) const { if(primitiveType()==aitEnumFloat64) d=getData().Float64; else get(aitEnumFloat64,&d); } -inline void gdd::get(aitFloat32& d) { +inline void gdd::get(aitFloat32& d) const { if(primitiveType()==aitEnumFloat32) d=getData().Float32; else get(aitEnumFloat32,&d); } -inline void gdd::get(aitUint32& d) { +inline void gdd::get(aitUint32& d) const { if(primitiveType()==aitEnumUint32) d=getData().Uint32; else get(aitEnumUint32,&d); } -inline void gdd::get(aitInt32& d) { +inline void gdd::get(aitInt32& d) const { if(primitiveType()==aitEnumInt32) d=getData().Int32; else get(aitEnumInt32,&d); } -inline void gdd::get(aitUint16& d) { +inline void gdd::get(aitUint16& d) const { if(primitiveType()==aitEnumUint16) d=getData().Uint16; else get(aitEnumUint16,&d); } -inline void gdd::get(aitInt16& d) { +inline void gdd::get(aitInt16& d) const { if(primitiveType()==aitEnumInt16) d=getData().Int16; else get(aitEnumInt16,&d); } -inline void gdd::get(aitUint8& d) { +inline void gdd::get(aitUint8& d) const { if(primitiveType()==aitEnumUint8) d=getData().Uint8; else get(aitEnumUint8,&d); } -inline void gdd::get(aitInt8& d) { +inline void gdd::get(aitInt8& d) const { if(primitiveType()==aitEnumInt8) d=getData().Int8; else get(aitEnumInt8,&d); } -inline void gdd::get(aitType& d) { d=data; } +inline void gdd::get(aitType& d) const { d=data; } // ---------- gdd x = primitive data type pointer functions---------- inline gdd& gdd::operator=(aitFloat64* v) { putRef(v); return *this;} @@ -573,36 +589,103 @@ inline gdd& gdd::operator=(const aitString& d) { put(d); return *this; } // ------------- primitive type pointer = gdd x functions -------------- -inline gdd::operator aitFloat64*(void) const +inline gdd::operator aitFloat64*(void) { return (aitFloat64*)dataPointer(); } -inline gdd::operator aitFloat32*(void) const +inline gdd::operator aitFloat32*(void) { return (aitFloat32*)dataPointer(); } -inline gdd::operator aitUint32*(void) const +inline gdd::operator aitUint32*(void) { return (aitUint32*)dataPointer(); } -inline gdd::operator aitInt32*(void) const +inline gdd::operator aitInt32*(void) { return (aitInt32*)dataPointer(); } -inline gdd::operator aitUint16*(void) const +inline gdd::operator aitUint16*(void) { return (aitUint16*)dataPointer(); } -inline gdd::operator aitInt16*(void) const +inline gdd::operator aitInt16*(void) { return (aitInt16*)dataPointer(); } -inline gdd::operator aitUint8*(void) const +inline gdd::operator aitUint8*(void) { return (aitUint8*)dataPointer(); } -inline gdd::operator aitInt8*(void) const +inline gdd::operator aitInt8*(void) { return (aitInt8*)dataPointer(); } -inline gdd::operator aitString*(void) const +inline gdd::operator aitString*(void) { return (aitString*)dataPointer(); } -inline gdd::operator aitFixedString*(void) const +inline gdd::operator aitFixedString*(void) + { return (aitFixedString*)dataPointer(); } + +inline gdd::operator const aitFloat64*(void) const + { return (aitFloat64*)dataPointer(); } +inline gdd::operator const aitFloat32*(void) const + { return (aitFloat32*)dataPointer(); } +inline gdd::operator const aitUint32*(void) const + { return (aitUint32*)dataPointer(); } +inline gdd::operator const aitInt32*(void) const + { return (aitInt32*)dataPointer(); } +inline gdd::operator const aitUint16*(void) const + { return (aitUint16*)dataPointer(); } +inline gdd::operator const aitInt16*(void) const + { return (aitInt16*)dataPointer(); } +inline gdd::operator const aitUint8*(void) const + { return (aitUint8*)dataPointer(); } +inline gdd::operator const aitInt8*(void) const + { return (aitInt8*)dataPointer(); } +inline gdd::operator const aitString*(void) const + { return (aitString*)dataPointer(); } +inline gdd::operator const aitFixedString*(void) const { return (aitFixedString*)dataPointer(); } // ------------- primitive type = gdd x functions -------------- -inline gdd::operator aitFloat64(void) { aitFloat64 d; get(d); return d; } -inline gdd::operator aitFloat32(void) { aitFloat32 d; get(d); return d; } -inline gdd::operator aitUint32(void) { aitUint32 d; get(d); return d; } -inline gdd::operator aitInt32(void) { aitInt32 d; get(d); return d; } -inline gdd::operator aitUint16(void) { aitUint16 d; get(d); return d; } -inline gdd::operator aitInt16(void) { aitInt16 d; get(d); return d; } -inline gdd::operator aitUint8(void) { aitUint8 d; get(d); return d; } -inline gdd::operator aitInt8(void) { aitInt8 d; get(d); return d; } -inline gdd::operator aitString(void) { aitString d; get(d); return d; } +inline gdd::operator aitFloat64(void) const { aitFloat64 d; get(d); return d; } +inline gdd::operator aitFloat32(void) const { aitFloat32 d; get(d); return d; } +inline gdd::operator aitUint32(void) const { aitUint32 d; get(d); return d; } +inline gdd::operator aitInt32(void) const { aitInt32 d; get(d); return d; } +inline gdd::operator aitUint16(void) const { aitUint16 d; get(d); return d; } +inline gdd::operator aitInt16(void) const { aitInt16 d; get(d); return d; } +inline gdd::operator aitUint8(void) const { aitUint8 d; get(d); return d; } +inline gdd::operator aitInt8(void) const { aitInt8 d; get(d); return d; } +inline gdd::operator aitString(void) const { aitString d; get(d); return d; } + +inline gdd & gdd::operator [] (aitIndex index) +{ + return *this->getDD(index); +} + +inline const gdd & gdd::operator [] (aitIndex index) const +{ + return *this->getDD(index); +} + +inline gdd & gdd::operator [] (int index) +{ + assert (index>=0); + return (gdd &) *this->indexDD(index); +} + +inline const gdd & gdd::operator [] (int index) const +{ + assert (index>=0); + return *this->indexDD(index); +} + +inline const gdd* gdd::getDD(aitIndex index) const + { return indexDD(index); } + +inline gdd* gdd::getDD(aitIndex index) + { return (gdd *) indexDD(index); } + +inline gdd* gdd::getDD(aitIndex index,gddScalar*& dd) + { return (gdd*)(dd=(gddScalar*)indexDD(index)); } + +inline gdd* gdd::getDD(aitIndex index,gddArray*& dd) + { return (gdd*)(dd=(gddAtomic*)indexDD(index)); } + +inline gdd* gdd::getDD(aitIndex index,gddContainer*& dd) + { return (gdd*)(dd=(gddContainer*)indexDD(index)); } + +inline const gdd* gdd::getDD(aitIndex index, const gddScalar*& dd) const + { return (const gdd*)(dd=(const gddScalar*)indexDD(index)); } + +inline const gdd* gdd::getDD(aitIndex index, const gddArray*& dd) const + { return (const gdd*)(dd=(const gddAtomic*)indexDD(index)); } + +inline const gdd* gdd::getDD(aitIndex index, const gddContainer*& dd) const + { return (const gdd*)(dd=(const gddContainer*)indexDD(index)); } #endif diff --git a/src/gdd/gddScalar.h b/src/gdd/gddScalar.h index f63651690..1d8ea215a 100644 --- a/src/gdd/gddScalar.h +++ b/src/gdd/gddScalar.h @@ -7,6 +7,9 @@ * * $Id$ * $Log$ + * Revision 1.2 1997/04/23 17:13:05 jhill + * fixed export of symbols from WIN32 DLL + * * Revision 1.1 1997/03/21 01:56:09 jbk * *** empty log message *** * @@ -27,7 +30,7 @@ public: gddScalar(int app) : gdd(app) { } gddScalar(int app,aitEnum prim) : gdd(app,prim) { } - void dump(void); + void dump(void) const; void test(void); gddScalar& operator=(aitFloat64 d) { *((gdd*)this)=d; return *this; }