| 85 | virtual UInt32 decoding(Exception& ex, UInt8* data,UInt32 size) = 0; |
| 86 | |
| 87 | class Decoding : public WorkThread, private Task, public virtual Object, |
| 88 | public Events::OnDecoding, |
| 89 | public Events::OnDecoded<DecodedType>, |
| 90 | public Events::OnDecodedEnd { |
| 91 | public: |
| 92 | |
| 93 | class OutType : public virtual Object { |
| 94 | public: |
| 95 | template <typename ...Args> |
| 96 | OutType(const PoolBuffers& poolBuffers,Args&&... args) : pBuffer(poolBuffers),decoded(args ...) {} |
| 97 | |
| 98 | DecodedType decoded; |
| 99 | PoolBuffer pBuffer; |
| 100 | }; |
| 101 | |
| 102 | Decoding(Invoker& invoker, const char* name) : _pBuffer(invoker.poolBuffers), WorkThread(name), Task(invoker) {} |
| 103 | |
| 104 | virtual ~Decoding() { |
| 105 | for (OutType* pOut : _output) |
| 106 | delete pOut; |
| 107 | } |
| 108 | |
| 109 | template <typename ...Args> |
| 110 | void receive(Args&&... args) { |
| 111 | _new = true; |
| 112 | _pLastOut = new OutType(_pBuffer.poolBuffers,args ...); |
| 113 | std::lock_guard<std::mutex> lock(_outMutex); |
| 114 | _output.emplace_back(_pLastOut); |
| 115 | _outAddresses.emplace_back(_address); |
| 116 | } |
| 117 | |
| 118 | bool run(Exception& ex) { |
| 119 | |
| 120 | // Just one! |
| 121 | |
| 122 | _new = false; |
| 123 | |
| 124 | PoolBuffer pBuffer(_pBuffer.poolBuffers); |
| 125 | { |
| 126 | std::lock_guard<std::mutex> lock(_inMutex); |
| 127 | ASSERT_RETURN(!_input.empty(),true) |
| 128 | pBuffer.swap(_input.front()); |
| 129 | _input.pop_front(); |
| 130 | _address = _inAddresses.front(); |
| 131 | _inAddresses.pop_front(); |
| 132 | } |
| 133 | |
| 134 | // add general buffer in front |
| 135 | if (!_pBuffer.empty()) { |
| 136 | if (!pBuffer.empty()) |
| 137 | _pBuffer->append(pBuffer.data(),pBuffer.size()); |
| 138 | pBuffer.swap(_pBuffer); |
| 139 | _pBuffer.release(); |
| 140 | } |
| 141 | |
| 142 | UInt32 consumed(0); |
| 143 | |
| 144 | while(consumed<pBuffer.size()) { // while everything is not consumed |
nothing calls this directly
no outgoing calls
no test coverage detected