Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
Revision 27:db73f8ac6c75, committed 2014-04-22
- Comitter:
- dylanembed123
- Date:
- Tue Apr 22 14:56:03 2014 +0000
- Parent:
- 26:06f1c9d70e9f
- Child:
- 28:4e608589d787
- Commit message:
- Add documentation examples to the top of datalocation
Changed in this revision
handle/dataLocation.cpp | Show annotated file Show diff for this revision Revisions of this file |
handle/dataLocation.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/handle/dataLocation.cpp Tue Apr 22 14:21:01 2014 +0000 +++ b/handle/dataLocation.cpp Tue Apr 22 14:56:03 2014 +0000 @@ -31,14 +31,18 @@ } void LocHolder::inc(LHType type,int amount,bool abs){ + // Grab current index holder unsigned int& index=getI(type); - index=getRealIndex(type,(abs?0:index),amount);//((abs?0:index)+amount)%getI(type,LHIType_size); - getI(type)=index; + // Set index and make sure the index is valid (not negative or greater than max) + index=getRealIndex(type,(abs?0:index)+amount); } void LocHolder::add(LHType type,DataLocation newLoc){ + // Set the current index to the current size getI(type)=getI(type,LHIType_size); + // Increment size getI(type,LHIType_size)++; + // Assign current index getC(type)=newLoc; }
--- a/handle/dataLocation.h Tue Apr 22 14:21:01 2014 +0000 +++ b/handle/dataLocation.h Tue Apr 22 14:56:03 2014 +0000 @@ -1,6 +1,13 @@ /** * \brief Data location data holder **/ +// Example Usage +// Looping: for(int i=0;i<DH::locs().getI(LHType_locs);i++){DataLocation thisData=DH::locs().getC(LHType_locs,i);} +// Appending: DH::locs().add(LHType_locs,DataLocation(4.0f,5.0f,6.0f)); +// ResetStart: DH::locs().inc(LHType_locs,0,true); +// ResetEnd: DH::locs().inc(LHType_locs,-1,true); +// Increment: DH::locs().inc(LHType_locs); +// GetCurrent: DH::locs().getC(LHType_locs,DH::locs().getI()); #ifndef _DATA_LOCATION_H_ #define _DATA_LOCATION_H_ #define MAXNUMLOCS 64 @@ -72,15 +79,19 @@ DataLocation* get(LHType type=LHType_locs); /// \brief Get Current value + // Set the offset to a positive number to start from beg + // Set the offset to a negative number to start from end DataLocation& getC(LHType type=LHType_locs,int offset=0); /// \brief Get Index + // Set type to head to find get the index of the current incremeter. + // Set type to size to find the size unsigned int& getI(LHType type=LHType_locs,LHIType indexType=LHIType_head); /// \brief Fix an index that might be out of bounds; unsigned int getRealIndex(LHType type,int index,int offset=0,bool useSize=true); - /// \brief Increment index + /// \brief Increment index (loop on overflow) void inc(LHType type=LHType_locs,int amount=1,bool abs=false); /// \brief Append a location to the end.