Line |
Branch |
Exec |
Source |
1 |
|
|
/***************************************************************************** |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2016 Richard Hacker (lerichi at gmx dot net) |
4 |
|
|
* |
5 |
|
|
* This file is part of the PdCom library. |
6 |
|
|
* |
7 |
|
|
* The PdCom library is free software: you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU Lesser General Public License as published by |
9 |
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
10 |
|
|
* option) any later version. |
11 |
|
|
* |
12 |
|
|
* The PdCom library is distributed in the hope that it will be useful, but |
13 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
15 |
|
|
* License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
18 |
|
|
* along with the PdCom library. If not, see <http://www.gnu.org/licenses/>. |
19 |
|
|
* |
20 |
|
|
*****************************************************************************/ |
21 |
|
|
|
22 |
|
|
#include "IOLayer.h" |
23 |
|
|
|
24 |
|
|
using namespace PdCom::impl; |
25 |
|
|
|
26 |
|
|
/////////////////////////////////////////////////////////////////////////// |
27 |
|
|
/////////////////////////////////////////////////////////////////////////// |
28 |
|
328 |
IOLayer::IOLayer(IOLayer *parent) |
29 |
|
|
{ |
30 |
|
328 |
m_parent = parent; |
31 |
|
|
|
32 |
|
328 |
rxbytes = 0; |
33 |
|
328 |
txbytes = 0; |
34 |
|
328 |
} |
35 |
|
|
|
36 |
|
|
/////////////////////////////////////////////////////////////////////////// |
37 |
|
326 |
IOLayer::~IOLayer() |
38 |
|
326 |
{} |
39 |
|
|
|
40 |
|
|
/////////////////////////////////////////////////////////////////////////// |
41 |
|
1426 |
int IOLayer::read(char *buf, int n) |
42 |
|
|
{ |
43 |
|
1426 |
int count = m_parent->read(buf, n); |
44 |
|
|
|
45 |
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 17 times.
|
1426 |
if (count > 0) |
46 |
|
1409 |
rxbytes += count; |
47 |
|
|
|
48 |
|
1426 |
return count; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
/////////////////////////////////////////////////////////////////////////// |
52 |
|
16924 |
void IOLayer::write(const char *buf, size_t n) |
53 |
|
|
{ |
54 |
|
16924 |
m_parent->write(buf, n); |
55 |
|
|
|
56 |
|
16924 |
txbytes += n; |
57 |
|
16924 |
} |
58 |
|
|
|
59 |
|
|
/////////////////////////////////////////////////////////////////////////// |
60 |
|
554 |
void IOLayer::flush() |
61 |
|
|
{ |
62 |
|
554 |
m_parent->flush(); |
63 |
|
554 |
} |
64 |
|
|
|
65 |
|
|
/////////////////////////////////////////////////////////////////////////// |
66 |
|
✗ |
void IOLayer::insert(IOLayer *io) |
67 |
|
|
{ |
68 |
|
✗ |
m_parent = io; |
69 |
|
|
} |
70 |
|
|
|