--- trunk/OOPSE/libmdtools/GenericData.cpp 2003/08/12 17:51:33 682 +++ branches/new-templateless/OOPSE/libmdtools/GenericData.cpp 2003/11/03 22:07:17 850 @@ -1,25 +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; } -ZConsParaData::ZConsParaData(){ - id = ZCONSPARADATA_ID; +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; + } + + if( next != NULL ) + return next->add( theID, theDval ); + + next = new GenericData( theID, theDval ); + return next; } -void ZConsParaData::sortByIndex(){ - sort(data.begin(), data.end(), ZConsParaSortCriterion()); -} \ No newline at end of file +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; +} + +GenericData* GenericData::add(char* theID, + double* theDarray, + int theArrayLength){ + + if( !strcmp( theID, id ) ){ + + 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 setValue(double theDval){ + dVal = theDval; +} + +void setValue(char* theCval){ + strcpy( cVal, theCval ); +} + +void setValue(double* theDarray, int theArrayLength){ + + 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; +// }