forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollectorDatafileCancianImpl.cpp
76 lines (61 loc) · 1.66 KB
/
CollectorDatafileCancianImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: CollectorDatafileCancianImpl.cpp
* Author: cancian
*
* Created on 2 de Outubro de 2018, 16:12
*/
#include <fstream>
#include "CollectorDatafileCancianImpl.h"
CollectorDatafileCancianImpl::CollectorDatafileCancianImpl() {
}
CollectorDatafileCancianImpl::CollectorDatafileCancianImpl(const CollectorDatafileCancianImpl& orig) {
}
CollectorDatafileCancianImpl::~CollectorDatafileCancianImpl() {
}
void CollectorDatafileCancianImpl::clear() {
std::ofstream file;
file.open(_filename, std::ofstream::out | std::ofstream::trunc);
file.close();
}
void CollectorDatafileCancianImpl::addValue(double value) {
try {
std::ofstream file;
file.open(this->_filename, std::ios::out | std::ios::app);
file << value << "\n";
file.close();
} catch (const std::exception& e) {
}
}
double CollectorDatafileCancianImpl::getLastValue() {
}
unsigned long CollectorDatafileCancianImpl::numElements() {
try {
std::string line;
unsigned long count;
std::ifstream file;
file.open(_filename, std::ios::in);
if (file.is_open()) {
while (!file.eof()) {
getline(file, line);
count++;
}
file.close();
return count;
}
} catch (const std::exception& e) {
}
return 0;
}
double CollectorDatafileCancianImpl::getValue(unsigned int num) {
} // same as getValue, or value[num]
std::string CollectorDatafileCancianImpl::getDataFilename() {
return _filename;
}
void CollectorDatafileCancianImpl::setDataFilename(std::string filename) {
this->_filename = filename;
}