Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: handle/dataLocation.cpp
- Revision:
- 5:eef5ea6a9916
- Parent:
- 4:c75d5e5e6bfc
- Child:
- 6:f0248eb6714d
diff -r c75d5e5e6bfc -r eef5ea6a9916 handle/dataLocation.cpp
--- a/handle/dataLocation.cpp Tue Apr 01 15:52:08 2014 +0000
+++ b/handle/dataLocation.cpp Thu Apr 03 15:56:05 2014 +0000
@@ -4,31 +4,47 @@
DataLocation* LocHolder::targ=NULL;
DataLocation* LocHolder::base=NULL;
-DataLocation* LocHolder::getLocs(){
- if(locs==NULL)locs=new DataLocation[MAXNUMLOCS];
- return locs;
-}
+unsigned int LocHolder::headLocs=0;
+unsigned int LocHolder::headTarg=0;
+unsigned int LocHolder::headBase=0;
+
+unsigned int LocHolder::sizeLocs=0;
+unsigned int LocHolder::sizeTarg=0;
+unsigned int LocHolder::sizeBase=0;
-DataLocation* LocHolder::getTarg(){
- if(targ==NULL)targ=new DataLocation[MAXNUMLOCS];
- return targ;
-}
-
-DataLocation* LocHolder::getBase(){
- if(base==NULL)base=new DataLocation[MAXNUMLOCS];
- return base;
+DataLocation* LocHolder::get(LHType type){
+ if(type==LHType_locs){
+ if(locs==NULL)locs=new DataLocation[MAXNUMLOCS];
+ return locs;
+ }else if(type==LHType_targ){
+ if(targ==NULL)targ=new DataLocation[MAXNUMLOCS];
+ return targ;
+ }else if(type==LHType_base){
+ if(base==NULL)base=new DataLocation[MAXNUMLOCS];
+ return base;
+ }
}
unsigned int LocHolder::getRealIndex(int index,int offset=0){
return (index+offset)%MAXNUMLOCS;
}
-DataLocation& LocHolder::getCurrentLocs(int offset=0){
- return getLocs()[getRealIndex(headLocs,offset)];
+DataLocation& LocHolder::getC(LHType type,int offset=0){
+ return get(type)[getRealIndex(headLocs,offset)];
}
-DataLocation& LocHolder::getCurrentTarg(int offset=0){
- return getTarg()[getRealIndex(headTarg,offset)];
+
+unsigned int& getI(LHType type,LHIType indexType=LHIType_head){
+ if(indexType==LHIType_head){
+ // Grab proper header
+ if(type==LHType_locs){return headLocs;}else if(type==LHType_targ){return headTarg;}else if(type==LHType_base){return headBase;}
+ }else if(indexType==LHIType_size){
+ // Grab proper size
+ if(type==LHType_locs){return sizeLocs;}else if(type==LHType_targ){return sizeTarg;}else if(type==LHType_base){return sizeBase;}
+ }
}
-DataLocation& LocHolder::getCurrentBase(int offset=0){
- return getBase()[getRealIndex(headBase,offset)];
-}
+
+void inc(LHType type,int amount=1){
+ unsigned int& index=getI(type);
+ index=(index+amount)%getI(type,LHIType_size);
+ getI(type)=index;
+}
\ No newline at end of file
