buffer_obs_mult.cpp 3.44 KB
Newer Older
1
2
3
4
5
6
7
/*******************************************************************************
 * 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 (|). *
 *                                                                             *
Achim Morschhauser's avatar
Achim Morschhauser committed
8
9
10
11
12
13
14
15
 * This class implements the abstract class buffer_obs.				*
 *										*
 ********************************************************************************/

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

// Custom C++ Headers
16
17
#include <buffer_obs_mult.hpp>
#include <buffer_obs.hpp>
Achim Morschhauser's avatar
Achim Morschhauser committed
18
19
20
21
22
23
24
25

/********************************************************************************
 *********************************************************************************
 *										*
 * 				Constructors.					*
 *										*
 *********************************************************************************
 ********************************************************************************/
26
27
28
29
buffer_obs_mult::buffer_obs_mult(buffer_obs* buffer) {
    
    buffers.push_back(buffer);
    
Achim Morschhauser's avatar
Achim Morschhauser committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
}

/********************************************************************************
 *********************************************************************************
 *										*
 * 			      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.		*
 *										*
 ********************************************************************************/
46
int buffer_obs_mult::put(data_obs* data) {
Achim Morschhauser's avatar
Achim Morschhauser committed
47

48
49
50
51
52
    for (int i=0; i<buffers.size(); i++){
        buffers.at(i)->put(data);
    }
    
    return(0);
Achim Morschhauser's avatar
Achim Morschhauser committed
53
54
55
56
57
58
59
60
61

}

/********************************************************************************
 *									 	*
 * Read data from the buffer. This is done by reading from Standard Input and	*
 * parsing the string.								*
 *										*
 ********************************************************************************/
62
63
64
65
66
int buffer_obs_mult::pop(data_obs* data) {
    
    buffers.at(0)->pop(data);
    
    return(0);
Achim Morschhauser's avatar
Achim Morschhauser committed
67
68
69

}

70
data_obs buffer_obs_mult::pop(){
Achim Morschhauser's avatar
Achim Morschhauser committed
71
72
73
74
75
76
77

	data_obs data;

	return(data);

}

78
79
80
81
82
83
84
85
int buffer_obs_mult::add(buffer_obs* buffer) {
    
    buffers.push_back(buffer);
    
    return(0);
            
}

Achim Morschhauser's avatar
Achim Morschhauser committed
86
87
88
89
90
91
92
93
94
95
96
97
98
/********************************************************************************
 *********************************************************************************
 *										*
 * 			      Private Methods.					*
 *										*
 *********************************************************************************
 ********************************************************************************/

/********************************************************************************
 *										*
 * Method dummy for initialization: No initialization is needed.		 	*
 *										*
 ********************************************************************************/
99
int buffer_obs_mult::init() {
Achim Morschhauser's avatar
Achim Morschhauser committed
100
101
102
103

	return(0);

}