many errors fixed
This commit is contained in:
207
src/gdd/gdd.cc
207
src/gdd/gdd.cc
@@ -262,8 +262,10 @@ void gdd::freeBounds(void)
|
||||
// should be tightly coupled, so no bounds means no dimension.
|
||||
}
|
||||
|
||||
void gdd::setDimension(int d)
|
||||
void gdd::setDimension(int d, const gddBounds* bnds)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(dim!=d)
|
||||
{
|
||||
freeBounds();
|
||||
@@ -277,6 +279,11 @@ void gdd::setDimension(int d)
|
||||
default: bounds=(gddBounds*)new gddBounds[dim]; break;
|
||||
}
|
||||
}
|
||||
if(bnds)
|
||||
{
|
||||
for(i=0;i<dim;i++)
|
||||
bounds[i]=bnds[i];
|
||||
}
|
||||
}
|
||||
|
||||
gddStatus gdd::registerDestructor(gddDestructor* dest)
|
||||
@@ -983,7 +990,7 @@ gddStatus gdd::clearData(void)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
|
||||
if(isContainer())
|
||||
if(isContainer()||isManaged()||isFlat())
|
||||
{
|
||||
gddAutoPrint("gdd::clearData()",gddErrorNotAllowed);
|
||||
rc=gddErrorNotAllowed;
|
||||
@@ -995,7 +1002,6 @@ gddStatus gdd::clearData(void)
|
||||
destruct->destroy(dataPointer());
|
||||
destruct=NULL;
|
||||
}
|
||||
freeBounds();
|
||||
setData(NULL);
|
||||
}
|
||||
return rc;
|
||||
@@ -1011,14 +1017,8 @@ gddStatus gdd::clear(void)
|
||||
|
||||
if(isAtomic())
|
||||
{
|
||||
if(destruct)
|
||||
{
|
||||
destruct->destroy(dataPointer());
|
||||
destruct=NULL;
|
||||
}
|
||||
freeBounds();
|
||||
destroyData();
|
||||
changeType(0,aitEnumInvalid);
|
||||
setData(NULL);
|
||||
}
|
||||
else if(isContainer())
|
||||
{
|
||||
@@ -1049,26 +1049,17 @@ gddStatus gdd::clear(void)
|
||||
|
||||
gddStatus gdd::reset(aitEnum prim, int dimen, aitIndex* cnt)
|
||||
{
|
||||
int i,app;
|
||||
int app=applicationType();
|
||||
int i;
|
||||
gddStatus rc;
|
||||
|
||||
if(isFlat()||isManaged()||isContainer())
|
||||
if((rc=clear())==0)
|
||||
{
|
||||
gddAutoPrint("gdd::reset()",gddErrorNotAllowed);
|
||||
return gddErrorNotAllowed;
|
||||
init(app,prim,dimen);
|
||||
for(i=0;i<dimen;i++)
|
||||
setBound(i,0,cnt[i]);
|
||||
}
|
||||
|
||||
app=applicationType();
|
||||
|
||||
if((rc=clear())<0)
|
||||
return rc;
|
||||
|
||||
init(app,prim,dimen);
|
||||
|
||||
for(i=0;i<dimen;i++)
|
||||
setBound(i,0,cnt[i]);
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void gdd::get(aitString& d)
|
||||
@@ -1251,10 +1242,20 @@ gddStatus gdd::put(const aitFixedString* const d)
|
||||
return rc;
|
||||
}
|
||||
|
||||
gddStatus gdd::putRef(const gdd*)
|
||||
{
|
||||
gddAutoPrint("gdd::putRef(const gdd*) - NOT IMPLEMENTED",
|
||||
gddErrorNotSupported);
|
||||
return gddErrorNotSupported;
|
||||
}
|
||||
|
||||
gddStatus gdd::put(const gdd* dd)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
int i;
|
||||
aitTimeStamp ts;
|
||||
aitUint32 esz;
|
||||
aitUint8* arr;
|
||||
size_t sz;
|
||||
|
||||
// bail out quickly is either dd is a container
|
||||
if(isContainer() || dd->isContainer())
|
||||
@@ -1263,29 +1264,19 @@ gddStatus gdd::put(const gdd* dd)
|
||||
return gddErrorNotSupported;
|
||||
}
|
||||
|
||||
if(!aitConvertValid(primitiveType()))
|
||||
// this primitive must be valid for this is work - set to dd if invalid
|
||||
if(!aitValid(primitiveType()))
|
||||
{
|
||||
// can't change application type here
|
||||
int app = applicationType();
|
||||
const gddBounds* ddb = dd->getBounds();
|
||||
|
||||
init(app,dd->primitiveType(),dd->dimension());
|
||||
for(i=0;i<dd->dimension();i++)
|
||||
bounds[i].set(ddb[i].first(),ddb[i].size());
|
||||
// note that flags, etc. are not set here - just data related stuff
|
||||
destroyData();
|
||||
setPrimType(dd->primitiveType());
|
||||
setDimension(dd->dimension(),dd->getBounds());
|
||||
}
|
||||
|
||||
if(isScalar() && dd->isScalar())
|
||||
{
|
||||
// this is the simple case - just make this scaler look like the other
|
||||
// need to make sure that aitString and aitFixedString work right
|
||||
|
||||
if(primitiveType()==aitEnumFixedString && data.FString==NULL)
|
||||
data.FString=new aitFixedString;
|
||||
|
||||
if(dd->primitiveType()==aitEnumFixedString)
|
||||
set(dd->primitiveType(),dd->dataPointer());
|
||||
else
|
||||
set(dd->primitiveType(),dd->dataAddress());
|
||||
set(dd->primitiveType(),dd->dataVoid());
|
||||
}
|
||||
else if(isScalar()) // dd must be atomic if this is true
|
||||
{
|
||||
@@ -1298,17 +1289,11 @@ gddStatus gdd::put(const gdd* dd)
|
||||
put(i1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(primitiveType()==aitEnumFixedString && data.FString==NULL)
|
||||
data.FString=new aitFixedString;
|
||||
|
||||
set(dd->primitiveType(),dd->dataPointer());
|
||||
}
|
||||
}
|
||||
else if(dd->isScalar()) // this must be atomic if true
|
||||
{
|
||||
if(primitiveType()==aitEnumInt8 &&
|
||||
dd->primitiveType()==aitEnumString)
|
||||
if(primitiveType()==aitEnumInt8 && dd->primitiveType()==aitEnumString)
|
||||
{
|
||||
// special case for aitString--->aitInt8
|
||||
aitString* s1=(aitString*)dd->dataAddress();
|
||||
@@ -1324,29 +1309,23 @@ gddStatus gdd::put(const gdd* dd)
|
||||
else
|
||||
{
|
||||
if(getDataSizeElements()>0)
|
||||
{
|
||||
aitConvert(primitiveType(),dataPointer(),
|
||||
dd->primitiveType(),dd->dataAddress(),1);
|
||||
}
|
||||
dd->primitiveType(),dd->dataVoid(),1);
|
||||
else
|
||||
{
|
||||
// this may expose an inconsistancy in the library.
|
||||
// you can register a gdd with bounds and no data
|
||||
// which marks it flat
|
||||
|
||||
if(isFlat())
|
||||
if(isFlat() || isManaged())
|
||||
{
|
||||
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotAllowed);
|
||||
rc=gddErrorNotAllowed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert it to a scalar - is this OK to do?
|
||||
clearData();
|
||||
setPrimType(dd->primitiveType());
|
||||
setApplType(applicationType());
|
||||
setDimension(0);
|
||||
put((aitType*)dd->dataAddress());
|
||||
destroyData();
|
||||
set(dd->primitiveType(),dd->dataVoid());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1356,97 +1335,47 @@ gddStatus gdd::put(const gdd* dd)
|
||||
// carefully place values from dd into this
|
||||
if(dataPointer()==NULL)
|
||||
{
|
||||
if(destruct)
|
||||
if(isFlat() || isManaged() || isContainer())
|
||||
{
|
||||
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotAllowed);
|
||||
rc=gddErrorNotAllowed;
|
||||
}
|
||||
else
|
||||
rc=copyData(dd); // is this the correct thing to do?
|
||||
}
|
||||
else if(dd->getDataSizeElements()>getDataSizeElements())
|
||||
{
|
||||
gddAutoPrint("gdd::put(const gdd*)",gddErrorOutOfBounds);
|
||||
rc=gddErrorOutOfBounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dd->dimension()>1)
|
||||
{
|
||||
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotSupported);
|
||||
rc=gddErrorNotSupported;
|
||||
}
|
||||
else
|
||||
{
|
||||
aitUint8* arr = (aitUint8*)dataPointer();
|
||||
aitConvert(
|
||||
primitiveType(),
|
||||
&arr[aitSize[primitiveType()]*dd->getBounds()->first()],
|
||||
dd->primitiveType(),
|
||||
dd->dataPointer(),
|
||||
dd->getBounds()->size());
|
||||
}
|
||||
setPrimType(dd->primitiveType());
|
||||
sz=describedDataSizeBytes();
|
||||
|
||||
// allocate a data buffer for the user
|
||||
if((arr=new aitUint8[sz]))
|
||||
{
|
||||
destruct=new gddDestructor;
|
||||
setData(arr);
|
||||
}
|
||||
else
|
||||
{
|
||||
gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNewFailed);
|
||||
rc=gddErrorNewFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rc==0)
|
||||
{
|
||||
esz=describedDataSizeElements();
|
||||
|
||||
// this code currently only works correctly with one
|
||||
// dimensional arrays.
|
||||
|
||||
arr=(aitUint8*)dataPointer();
|
||||
aitConvert(primitiveType(),
|
||||
&arr[aitSize[primitiveType()]*dd->getBounds()->first()],
|
||||
dd->primitiveType(), dd->dataPointer(),esz);
|
||||
}
|
||||
}
|
||||
|
||||
aitTimeStamp ts;
|
||||
setStatSevr(dd->getStat(),dd->getSevr());
|
||||
dd->getTimeStamp(&ts);
|
||||
setTimeStamp(&ts);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
gddStatus gdd::copyData(const gdd* dd)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
size_t sz;
|
||||
aitUint8* arr;
|
||||
int i;
|
||||
|
||||
if(isFlat() || isManaged() || isContainer())
|
||||
{
|
||||
gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNotAllowed);
|
||||
rc=gddErrorNotAllowed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is really a preliminary version of this function. it
|
||||
// does simple data copies and source dd to this dd.
|
||||
|
||||
// clean up the old data
|
||||
if(destruct)
|
||||
destruct->destroy(dataPointer());
|
||||
else
|
||||
{
|
||||
if(primitiveType()==aitEnumString && isScalar())
|
||||
{
|
||||
aitString* str = (aitString*)dataAddress();
|
||||
str->clear();
|
||||
}
|
||||
}
|
||||
|
||||
setPrimType(dd->primitiveType());
|
||||
setDimension(dd->dimension());
|
||||
const gddBounds* bnds = dd->getBounds();
|
||||
for(i=0;i<dd->dimension();i++) bounds[i]=bnds[i];
|
||||
sz=describedDataSizeBytes();
|
||||
|
||||
// copy the copy
|
||||
if((arr=new aitUint8[sz]))
|
||||
{
|
||||
destruct=new gddDestructor;
|
||||
setData(arr);
|
||||
memcpy(arr,dd->dataPointer(),sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNewFailed);
|
||||
rc=gddErrorNewFailed;
|
||||
}
|
||||
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -329,11 +329,10 @@ public:
|
||||
|
||||
void setPrimType(aitEnum t);
|
||||
void setApplType(int t);
|
||||
void setDimension(int d);
|
||||
void setDimension(int d,const gddBounds* = NULL);
|
||||
void destroyData(void);
|
||||
gddStatus reset(aitEnum primtype,int dimension, aitIndex* dim_counts);
|
||||
gddStatus clear(void); // clear all fields of the DD, including arrays
|
||||
gddStatus clearData(void);
|
||||
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);
|
||||
@@ -374,7 +373,6 @@ public:
|
||||
// copy data into it.
|
||||
// Dup() will copy DD info. bounds, data references copied only.
|
||||
|
||||
gddStatus copyData(const gdd*);
|
||||
gddStatus copyInfo(gdd*);
|
||||
gddStatus copy(gdd*);
|
||||
gddStatus Dup(gdd*);
|
||||
@@ -459,7 +457,7 @@ public:
|
||||
aitDataFormat=aitLocalDataFormat);
|
||||
void putRef(const aitFixedString*,gddDestructor* =0,
|
||||
aitDataFormat=aitLocalDataFormat);
|
||||
void putRef(const gdd*);
|
||||
gddStatus putRef(const gdd*);
|
||||
|
||||
// get the data in the form the user wants (do conversion)
|
||||
void getConvert(aitFloat64& d);
|
||||
@@ -602,6 +600,7 @@ protected:
|
||||
void freeBounds(void);
|
||||
void dumpInfo(void);
|
||||
gddStatus copyStuff(gdd*,int type);
|
||||
gddStatus clearData(void);
|
||||
|
||||
size_t describedDataSizeBytes(void) const;
|
||||
aitUint32 describedDataSizeElements(void) const;
|
||||
@@ -651,7 +650,10 @@ inline void* gdd::dataAddress(void) const { return (void*)&data; }
|
||||
inline void* gdd::dataPointer(void) const { return data.Pointer; }
|
||||
|
||||
inline void* gdd::dataVoid(void) const
|
||||
{ return dimension()?dataPointer():dataAddress(); }
|
||||
{
|
||||
return (dimension()||primitiveType()==aitEnumFixedString)?
|
||||
dataPointer():dataAddress();
|
||||
}
|
||||
|
||||
inline aitUint32 gdd::align8(unsigned long count) const
|
||||
{
|
||||
@@ -820,7 +822,8 @@ inline void gdd::set(aitEnum t,void* v)
|
||||
{
|
||||
if(primitiveType()==aitEnumFixedString)
|
||||
{
|
||||
if(dataPointer()==NULL) data.FString=new aitFixedString;
|
||||
if(dataPointer()==NULL)
|
||||
data.FString=new aitFixedString;
|
||||
aitConvert(primitiveType(),dataPointer(),t,v,1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -440,10 +440,12 @@ gddStatus gddApplicationTypeTable::freeDD(gdd* dd)
|
||||
// this is done because we are allowed to register atomic protos
|
||||
// that user can attach data to - which causes problems because
|
||||
// the actual structure of the DD is unknown
|
||||
|
||||
for(i=1;i<attr_table[group][app].total_dds;i++)
|
||||
{
|
||||
dd[i].destroyData();
|
||||
dd[i].setPrimType(attr_table[group][app].proto[i].primitiveType());
|
||||
dd[i].setApplType(attr_table[group][app].proto[i].applicationType());
|
||||
}
|
||||
|
||||
// fprintf(stderr,"Adding DD to free_list %d\n",app);
|
||||
@@ -486,11 +488,11 @@ aitUint32 gddApplicationTypeTable::getValue(aitUint32 ap)
|
||||
return attr_table[group][app].user_value;
|
||||
}
|
||||
|
||||
// ----------------------smart copy functions------------------------
|
||||
// the source in the container we must walk through is this called
|
||||
gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
gddStatus s;
|
||||
gddStatus rc=0,s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
@@ -504,14 +506,12 @@ gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* 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);
|
||||
}
|
||||
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);
|
||||
@@ -522,8 +522,7 @@ gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* src)
|
||||
// the destination in the container we must walk through is this called
|
||||
gddStatus gddApplicationTypeTable::copyDD_dest(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
gddStatus s;
|
||||
gddStatus rc=0,s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
@@ -534,14 +533,12 @@ gddStatus gddApplicationTypeTable::copyDD_dest(gdd* dest, gdd* src)
|
||||
// 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);
|
||||
}
|
||||
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]);
|
||||
@@ -568,3 +565,81 @@ gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src)
|
||||
gddAutoPrint("gddAppTable::smartCopy()",rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ----------------------smart reference functions------------------------
|
||||
// the source in the container we must walk through is this called
|
||||
gddStatus gddApplicationTypeTable::refDD_src(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0,s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
aitIndex index;
|
||||
|
||||
// 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())
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find src gdd in dest container and just do put()
|
||||
s=mapAppToIndex(dest->applicationType(),src->applicationType(),index);
|
||||
|
||||
if(s==0)
|
||||
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 rc=0,s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
aitIndex index;
|
||||
|
||||
if(dest->isContainer())
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find dest gdd in src container and just do put()
|
||||
s=mapAppToIndex(src->applicationType(),dest->applicationType(),index);
|
||||
|
||||
if(s==0)
|
||||
rc=dest->putRef(&src[index]);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::smartRef(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
|
||||
// only works with managed containers because app table mapping
|
||||
// feature is used.
|
||||
|
||||
if(dest->isContainer() && dest->isManaged())
|
||||
rc=refDD_src(dest,src);
|
||||
else if(src->isContainer() && src->isManaged())
|
||||
rc=refDD_dest(dest,src);
|
||||
else if(!src->isContainer() && !dest->isContainer())
|
||||
rc=dest->putRef(src); // both are not containers, let gdd handle it
|
||||
else
|
||||
rc=gddErrorNotAllowed;
|
||||
|
||||
gddAutoPrint("gddAppTable::smartRef()",rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.3 1996/09/04 20:58:55 jhill
|
||||
* added GDD_NAME_PV_NAME
|
||||
*
|
||||
* Revision 1.2 1996/08/27 13:05:09 jbk
|
||||
* final repairs to string functions, put() functions, and error code printing
|
||||
*
|
||||
@@ -120,6 +123,7 @@ 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);
|
||||
|
||||
// old style interface
|
||||
int tagC2I(const char* const ctag, int& tag);
|
||||
@@ -150,6 +154,8 @@ protected:
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
gddStatus splitApplicationType(aitUint32 r,aitUint32& g,aitUint32& a) const;
|
||||
|
||||
Reference in New Issue
Block a user