Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
Diff: handle/dataLocation.h
- Revision:
- 9:da906eeac51e
- Parent:
- 7:c75d5e5e6bfc
- Child:
- 14:6be57da62283
--- a/handle/dataLocation.h Tue Apr 01 17:58:35 2014 +0000 +++ b/handle/dataLocation.h Thu Apr 03 17:15:29 2014 +0000 @@ -1,3 +1,7 @@ +/** + * \brief Data location data holder + **/ + #define MAXNUMLOCS 256 // Storage of data location @@ -5,31 +9,63 @@ private: // Current value of lat lon and alt double lat,lon,alt; + double timestamp; public: + DataLocation(){} + DataLocation(double latA,double lonA,double altA,double timestampA=0):lat(latA),lon(lonA),alt(altA),timestamp(timestampA){} double& getLat(){return lat;} double& getLon(){return lon;} double& getAlt(){return alt;} -} +}; + +/// \brief Location holder type +enum LHType{ + LHType_locs=0, + LHType_targ, + LHType_base +}; + +/// \brief Location holder index type +enum LHIType{ + LHIType_head=0, + LHIType_size +}; // Singleton location holder class LocHolder{ private: // Actual Locations (absolute) - static DataLocation locs[MAXNUMLOCS]; + DataLocation locs[MAXNUMLOCS]; // Target Locations (relative to base station -> base station is at 0,0,0) - static DataLocation targ[MAXNUMLOCS]; + DataLocation targ[MAXNUMLOCS]; // Base Station Locations (absolute) - static DataLocation base[MAXNUMLOCS]; + DataLocation base[MAXNUMLOCS]; // Index of the head of the circular buffers - static unsigned int headLocs,headTarg,headBase; + unsigned int headLocs,headTarg,headBase; + // Number of locations + unsigned int sizeLocs,sizeTarg,sizeBase; public: - static DataLocation* getLocs(); - static DataLocation* getTarg(); - static DataLocation* getBase(); + /// \brief Default constructor + LocHolder():headLocs(0),headTarg(0),headBase(0),sizeLocs(0),sizeTarg(0),sizeBase(0){} + + /// \brief Get locations type + DataLocation* get(LHType type); + + /// \brief Get Current value + DataLocation& getC(LHType type,int offset=0); + + /// \brief Get Index + unsigned int& getI(LHType type,LHIType indexType=LHIType_head); - DataLocation& getCurrentLocs(int offset=0); - DataLocation& getCurrentTarg(int offset=0); - DataLocation& getCurrentBase(int offset=0); + /// \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 + void inc(LHType type,int amount=1,bool abs=false); - -}; \ No newline at end of file + /// \brief Append a location to the end. + void add(LHType type,DataLocation newLoc); +}; + +static LocHolder mainLocHolder; +static LocHolder& Locs(){return mainLocHolder;} \ No newline at end of file