Colin Stearns / Mbed 2 deprecated dgps

Dependencies:   mbed

Committer:
dylanembed123
Date:
Thu Apr 03 15:56:05 2014 +0000
Revision:
5:eef5ea6a9916
Parent:
4:c75d5e5e6bfc
Child:
6:f0248eb6714d
Update data location;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dylanembed123 4:c75d5e5e6bfc 1
dylanembed123 4:c75d5e5e6bfc 2
dylanembed123 4:c75d5e5e6bfc 3 DataLocation* LocHolder::locs=NULL;
dylanembed123 4:c75d5e5e6bfc 4 DataLocation* LocHolder::targ=NULL;
dylanembed123 4:c75d5e5e6bfc 5 DataLocation* LocHolder::base=NULL;
dylanembed123 4:c75d5e5e6bfc 6
dylanembed123 5:eef5ea6a9916 7 unsigned int LocHolder::headLocs=0;
dylanembed123 5:eef5ea6a9916 8 unsigned int LocHolder::headTarg=0;
dylanembed123 5:eef5ea6a9916 9 unsigned int LocHolder::headBase=0;
dylanembed123 5:eef5ea6a9916 10
dylanembed123 5:eef5ea6a9916 11 unsigned int LocHolder::sizeLocs=0;
dylanembed123 5:eef5ea6a9916 12 unsigned int LocHolder::sizeTarg=0;
dylanembed123 5:eef5ea6a9916 13 unsigned int LocHolder::sizeBase=0;
dylanembed123 4:c75d5e5e6bfc 14
dylanembed123 5:eef5ea6a9916 15 DataLocation* LocHolder::get(LHType type){
dylanembed123 5:eef5ea6a9916 16 if(type==LHType_locs){
dylanembed123 5:eef5ea6a9916 17 if(locs==NULL)locs=new DataLocation[MAXNUMLOCS];
dylanembed123 5:eef5ea6a9916 18 return locs;
dylanembed123 5:eef5ea6a9916 19 }else if(type==LHType_targ){
dylanembed123 5:eef5ea6a9916 20 if(targ==NULL)targ=new DataLocation[MAXNUMLOCS];
dylanembed123 5:eef5ea6a9916 21 return targ;
dylanembed123 5:eef5ea6a9916 22 }else if(type==LHType_base){
dylanembed123 5:eef5ea6a9916 23 if(base==NULL)base=new DataLocation[MAXNUMLOCS];
dylanembed123 5:eef5ea6a9916 24 return base;
dylanembed123 5:eef5ea6a9916 25 }
dylanembed123 4:c75d5e5e6bfc 26 }
dylanembed123 4:c75d5e5e6bfc 27
dylanembed123 4:c75d5e5e6bfc 28 unsigned int LocHolder::getRealIndex(int index,int offset=0){
dylanembed123 4:c75d5e5e6bfc 29 return (index+offset)%MAXNUMLOCS;
dylanembed123 4:c75d5e5e6bfc 30 }
dylanembed123 4:c75d5e5e6bfc 31
dylanembed123 5:eef5ea6a9916 32 DataLocation& LocHolder::getC(LHType type,int offset=0){
dylanembed123 5:eef5ea6a9916 33 return get(type)[getRealIndex(headLocs,offset)];
dylanembed123 4:c75d5e5e6bfc 34 }
dylanembed123 5:eef5ea6a9916 35
dylanembed123 5:eef5ea6a9916 36 unsigned int& getI(LHType type,LHIType indexType=LHIType_head){
dylanembed123 5:eef5ea6a9916 37 if(indexType==LHIType_head){
dylanembed123 5:eef5ea6a9916 38 // Grab proper header
dylanembed123 5:eef5ea6a9916 39 if(type==LHType_locs){return headLocs;}else if(type==LHType_targ){return headTarg;}else if(type==LHType_base){return headBase;}
dylanembed123 5:eef5ea6a9916 40 }else if(indexType==LHIType_size){
dylanembed123 5:eef5ea6a9916 41 // Grab proper size
dylanembed123 5:eef5ea6a9916 42 if(type==LHType_locs){return sizeLocs;}else if(type==LHType_targ){return sizeTarg;}else if(type==LHType_base){return sizeBase;}
dylanembed123 5:eef5ea6a9916 43 }
dylanembed123 4:c75d5e5e6bfc 44 }
dylanembed123 5:eef5ea6a9916 45
dylanembed123 5:eef5ea6a9916 46 void inc(LHType type,int amount=1){
dylanembed123 5:eef5ea6a9916 47 unsigned int& index=getI(type);
dylanembed123 5:eef5ea6a9916 48 index=(index+amount)%getI(type,LHIType_size);
dylanembed123 5:eef5ea6a9916 49 getI(type)=index;
dylanembed123 5:eef5ea6a9916 50 }