ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
DecodeChannel.cpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright 2009 - 2010 Kevin Ackley (kackley@gwi.net)
3  * Modified work Copyright 2018 - 2020 Andy Maloney <asmaloney@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person or organization
6  * obtaining a copy of the software and accompanying documentation covered by
7  * this license (the "Software") to use, reproduce, display, distribute,
8  * execute, and transmit the Software, and to prepare derivative works of the
9  * Software, and to permit third-parties to whom the Software is furnished to
10  * do so, all subject to the following:
11  *
12  * The copyright notices in the Software and this entire statement, including
13  * the above license grant, this restriction and the following disclaimer,
14  * must be included in all copies of the Software, in whole or in part, and
15  * all derivative works of the Software, unless such copies or derivative
16  * works are solely in the form of machine-executable object code generated by
17  * a source language processor.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  */
27 
28 #include "DecodeChannel.h"
29 #include "SourceDestBufferImpl.h"
30 
31 namespace e57
32 {
33  DecodeChannel::DecodeChannel( SourceDestBuffer dbuf_arg, std::shared_ptr<Decoder> decoder_arg,
34  unsigned bytestreamNumber_arg, uint64_t maxRecordCount_arg ) :
35  dbuf( dbuf_arg ), decoder( decoder_arg ), bytestreamNumber( bytestreamNumber_arg )
36  {
37  maxRecordCount = maxRecordCount_arg;
41  inputFinished = false;
42  }
43 
45  {
47  if ( decoder->totalRecordsCompleted() >= maxRecordCount )
48  {
49  return ( true );
50  }
51 
53  return ( dbuf.impl()->nextIndex() == dbuf.impl()->capacity() );
54  }
55 
57  {
59  if ( inputFinished )
60  {
61  return ( true );
62  }
63 
66  }
67 
68  void DecodeChannel::dump( int indent, std::ostream &os )
69  {
70  os << space( indent ) << "dbuf" << std::endl;
71  dbuf.dump( indent + 4, os );
72 
73  os << space( indent ) << "decoder:" << std::endl;
74  decoder->dump( indent + 4, os );
75 
76  os << space( indent ) << "bytestreamNumber: " << bytestreamNumber << std::endl;
77  os << space( indent ) << "maxRecordCount: " << maxRecordCount << std::endl;
78  os << space( indent ) << "currentPacketLogicalOffset: " << currentPacketLogicalOffset << std::endl;
79  os << space( indent ) << "currentBytestreamBufferIndex: " << currentBytestreamBufferIndex << std::endl;
80  os << space( indent ) << "currentBytestreamBufferLength: " << currentBytestreamBufferLength << std::endl;
81  os << space( indent ) << "inputFinished: " << inputFinished << std::endl;
82  os << space( indent ) << "isInputBlocked(): " << isInputBlocked() << std::endl;
83  os << space( indent ) << "isOutputBlocked(): " << isOutputBlocked() << std::endl;
84  }
85 }
void dump(int indent=0, std::ostream &os=std::cout) const
Diagnostic function to print internal state of object to output stream in an indented format.
Definition: E57Format.cpp:2167
size_t capacity() const
Get total capacity of buffer.
Definition: E57Format.cpp:2070
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
std::string space(size_t n)
Definition: Common.h:73
void dump(int indent=0, std::ostream &os=std::cout)
has exhausted data in the current packet
SourceDestBuffer dbuf
Definition: DecodeChannel.h:37
uint64_t maxRecordCount
Definition: DecodeChannel.h:40
size_t currentBytestreamBufferIndex
Definition: DecodeChannel.h:42
size_t currentBytestreamBufferLength
Definition: DecodeChannel.h:43
bool isOutputBlocked() const
bool isInputBlocked() const
uint64_t currentPacketLogicalOffset
Definition: DecodeChannel.h:41
std::shared_ptr< Decoder > decoder
Definition: DecodeChannel.h:38
unsigned bytestreamNumber
Definition: DecodeChannel.h:39
DecodeChannel(SourceDestBuffer dbuf_arg, std::shared_ptr< Decoder > decoder_arg, unsigned bytestreamNumber_arg, uint64_t maxRecordCount_arg)