rtmlib
writer.h
Go to the documentation of this file.
1 /*
2  * rtmlib is a Real-Time Monitoring Library.
3  *
4  * Copyright (C) 2018-2020 AndrĂ© Pedro
5  *
6  * This file is part of rtmlib.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef _RTEML_WRITER_H_
23 #define _RTEML_WRITER_H_
24 
25 #include "circularbuffer.h"
26 #include "event.h"
27 
36 template <typename B> class RTML_writer {
37 private:
43  B &buffer;
44 
45 public:
51  RTML_writer(B &buffer);
52 
58  typename B::error_t push(typename B::event_t &);
59 };
60 
61 template <typename B>
62 RTML_writer<B>::RTML_writer(B &_buffer) : buffer(_buffer) {}
63 
64 template <typename B>
65 typename B::error_t RTML_writer<B>::push(typename B::event_t &event) {
66 
67  timespan timestamp = clockgettime();
68  event.setTime(timestamp);
69  typename B::error_t e = buffer.push(event);
70 
71  return e;
72 }
73 
74 #endif //_RTEML_WRITER_H_
B & buffer
Definition: writer.h:43
RTML_writer(B &buffer)
Definition: writer.h:62
B::error_t push(typename B::event_t &)
Definition: writer.h:65
Definition: writer.h:36