Aleksandr Koptevtsov / arch_temp_stack
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TempData.cpp Source File

TempData.cpp

00001 #include "TempData.h"
00002  
00003 TempData::TempData()
00004 {
00005   _count = 0;
00006 }
00007  
00008  // push value
00009 void TempData::PushData(float data)
00010 {
00011     _buffer[_count] = data;       // store data and increment counter
00012     _count++;
00013 }
00014  
00015  // pop value. return either top value, or -999 as error code
00016 float TempData::PopData()
00017 {
00018     if(_count)          // check if buffer not empty
00019     {
00020         _count--;
00021         return _buffer[_count];   // return value
00022     }
00023     return -999;   
00024 }
00025 
00026 // get value by index
00027 float TempData::GetData(int index)
00028 {
00029     return _buffer[index];         // return value
00030 }
00031 
00032 // get number of stored measurings
00033 int TempData::GetCount()
00034 {
00035     return _count;         
00036 }