--- trunk/OOPSE/libmdtools/GenericData.cpp 2003/07/31 15:35:07 658 +++ branches/new-templateless/OOPSE/libmdtools/GenericData.cpp 2003/11/05 19:18:17 851 @@ -1,42 +1,184 @@ +#include +#include + #include "GenericData.hpp" GenericData::GenericData(){ - id = "undefined"; + next = NULL; + sameNext = NULL; + dArray = NULL; + strcpy( id, "undefined" ); +} +GenericData::GenericData(char* theID){ + + next = NULL; + sameNext = NULL; + dArray = NULL; + strcpy( id, theID ); } -GenericData& GenericData::operator = (const GenericData& rhs){ +GenericData::GenericData(char* theID, double theDval){ + + next = NULL; + sameNext = NULL; + dArray = NULL; + strcpy( id, theID ); + dVal = theDval; +} + +GenericData::GenericData(char* theID, char* theCval){ + + next = NULL; + sameNext = NULL; + dArray = NULL; + strcpy( id, theID ); + strcpy( cVal, theCval ); +} + +GenericData::GenericData(char* theID, double* theDarray, int theArrayLength){ + int i; - if(this == &rhs) - return (*this); + next = NULL; + sameNext = NULL; + dArray = NULL; + strcpy( id, theID ); - id = rhs.id; + arrayLength = theArrayLength; + dArray = new double[arrayLength]; + for(i=0;iadd( theID ); + + sameNext = new GenericData( theID ); + return sameNext; + } + + if( next != NULL ) + return next->add( theID ); + + next = new GenericData( theID ); + return next; } -IndexData::IndexData(){ +GenericData* GenericData::add(char* theID, double theDval){ + + if( !strcmp( theID, id ) ){ + + if( sameNext != NULL ) + return sameNext->add( theID, theDval ); + + sameNext = new GenericData( theID, theDval ); + return sameNext; + } - id = "IndexData"; + if( next != NULL ) + return next->add( theID, theDval ); + next = new GenericData( theID, theDval ); + return next; } -IndexData::IndexData(const IndexData& rhs) - : GenericData(rhs), indexData(rhs.indexData){ +GenericData* GenericData::add(char* theID, char* theCval){ + + if( !strcmp( theID, id ) ){ + + if( sameNext != NULL ) + return sameNext->add( theID, theCval ); + + sameNext = new GenericData( theID, theCval ); + return sameNext; + } + if( next != NULL ) + return next->add( theID, theCval ); + + next = new GenericData( theID, theCval ); + return next; } -IndexData& IndexData::operator = (const IndexData& rhs){ +GenericData* GenericData::add(char* theID, + double* theDarray, + int theArrayLength){ - if(this == &rhs) - return (*this); + if( !strcmp( theID, id ) ){ - //chain to base class - GenericData::operator =(rhs); + if( sameNext != NULL ) + return sameNext->add( theID, theDarray, theArrayLength ); + + sameNext = new GenericData( theID, theDarray, theArrayLength ); + return sameNext; + } + + if( next != NULL ) + return next->add( theID, theDarray, theArrayLength ); + + next = new GenericData( theID, theDarray, theArrayLength ); + return next; +} + +void GenericData::setValue(double theDval){ + dVal = theDval; +} + +void GenericData::setValue(char* theCval){ + strcpy( cVal, theCval ); +} - indexData = rhs.indexData; +void GenericData::setValue(double* theDarray, int theArrayLength){ - return (*this); + int i; + + arrayLength = theArrayLength; + dArray = new double[arrayLength]; + for(i=0;ifind( findID ); + + return NULL; +} + + +// void ZConsParaData::sortByIndex(){ +// sort(data.begin(), data.end(), ZConsParaSortCriterion()); +// } +// bool ZConsParaData::isIndexUnique(){ + +// for(int i = 0; i < (int)(data.size() - 1); i++) +// for(int j = i + 1; j < (int)(data.size()); j++) +// if(data[i].zconsIndex == data[j].zconsIndex) +// return false; + +// return true; +// }