/src/opendnp3/cpp/lib/src/app/TxBuffer.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2013-2022 Step Function I/O, LLC |
3 | | * |
4 | | * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O |
5 | | * LLC (https://stepfunc.io) under one or more contributor license agreements. |
6 | | * See the NOTICE file distributed with this work for additional information |
7 | | * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license |
8 | | * this file to you under the Apache License, Version 2.0 (the "License"); you |
9 | | * may not use this file except in compliance with the License. You may obtain |
10 | | * a copy of the License at: |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | #ifndef OPENDNP3_TXBUFFER_H |
21 | | #define OPENDNP3_TXBUFFER_H |
22 | | |
23 | | #include "app/APDUResponse.h" |
24 | | |
25 | | #include <ser4cpp/container/Buffer.h> |
26 | | |
27 | | namespace opendnp3 |
28 | | { |
29 | | |
30 | | class TxBuffer |
31 | | { |
32 | | public: |
33 | 19.0k | TxBuffer(uint32_t maxTxSize) : buffer(maxTxSize) {} |
34 | | |
35 | | APDUResponse Start() |
36 | 9.03k | { |
37 | 9.03k | APDUResponse response(buffer.as_wslice()); |
38 | 9.03k | return response; |
39 | 9.03k | } |
40 | | |
41 | | void Record(const AppControlField& control, const ser4cpp::rseq_t& view) |
42 | 9.03k | { |
43 | 9.03k | this->control = control; |
44 | 9.03k | this->lastResponse = view; |
45 | 9.03k | } |
46 | | |
47 | | const ser4cpp::rseq_t& GetLastResponse() const |
48 | 0 | { |
49 | 0 | return lastResponse; |
50 | 0 | } |
51 | | |
52 | | const AppControlField& GetLastControl() const |
53 | 0 | { |
54 | 0 | return control; |
55 | 0 | } |
56 | | |
57 | | private: |
58 | | ser4cpp::rseq_t lastResponse; |
59 | | AppControlField control; |
60 | | |
61 | | ser4cpp::Buffer buffer; |
62 | | }; |
63 | | |
64 | | } // namespace opendnp3 |
65 | | |
66 | | #endif |