buffer_obs_mult.cpp 3.27 KB
Newer Older
Achim Morschhauser's avatar
Achim Morschhauser committed
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/********************************************************************************
 * WRITTEN BY ACHIM MORSCHHAUSER, GFZ POTSDAM, April 2016			*
 * mors//gfz-potsdam.de								*
 *										*
 * This class provides a buffer of observatory data that uses standard input and *
 * output. It can be used in combination with the SHELL pipe operator (|).       *
 * 										*
 * This class implements the abstract class buffer_obs.				*
 *										*
 ********************************************************************************/

// C++ Headers
#include <iostream> // Standard I/O

// Custom C++ Headers
#include <buffer_obs_pipe.hpp> // Buffer using Standard I/O and the SHELL Pipe

/********************************************************************************
 *********************************************************************************
 *										*
 * 				Constructors.					*
 *										*
 *********************************************************************************
 ********************************************************************************/
buffer_obs_pipe::buffer_obs_pipe(int precision) {

	this-> precision=precision;

}

/********************************************************************************
 *********************************************************************************
 *										*
 * 			      Public Methods.					*
 *										*
 *********************************************************************************
 ********************************************************************************/

/********************************************************************************
 *									 	*
 * Add data of type data_obs to the buffer. This is done by converting the	*
 * data to its string representation and writing to Standard Output.		*
 *										*
 ********************************************************************************/
int buffer_obs_pipe::put(data_obs* data) {

	std::string datastr;

	data->string(&datastr,precision);

	std::cout << datastr << std::endl;

	return(0);

}

/********************************************************************************
 *									 	*
 * Read data from the buffer. This is done by reading from Standard Input and	*
 * parsing the string.								*
 *										*
 ********************************************************************************/
int buffer_obs_pipe::pop(data_obs* data) {

	std::string input;

	std::getline (std::cin,input);

	/*std::cout << "STDIN: "
			  << input
			  << std::endl;
	 */

	data->parse(&input);

	return(0);

}

data_obs buffer_obs_pipe::pop(){

	data_obs data;

	pop(&data);

	return(data);

}

/********************************************************************************
 *********************************************************************************
 *										*
 * 			      Private Methods.					*
 *										*
 *********************************************************************************
 ********************************************************************************/

/********************************************************************************
 *										*
 * Method dummy for initialization: No initialization is needed.		 	*
 *										*
 ********************************************************************************/
int buffer_obs_pipe::init() {

	return(0);

}