![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <Packet.h>

Classes | |
| struct | CacheEntry |
Public Member Functions | |
| PacketReadCache (CheckedFile *cFile, unsigned packetCount) | |
| std::unique_ptr< PacketLock > | lock (uint64_t packetLogicalOffset, char *&pkt) |
| void | dump (int indent=0, std::ostream &os=std::cout) |
Protected Member Functions | |
| void | unlock (unsigned cacheIndex) |
| void | readPacket (unsigned oldestEntry, uint64_t packetLogicalOffset) |
Protected Attributes | |
| unsigned | lockCount_ = 0 |
| unsigned | useCount_ = 0 |
| CheckedFile * | cFile_ = nullptr |
| std::vector< CacheEntry > | entries_ |
| PacketReadCache::PacketReadCache | ( | CheckedFile * | cFile, |
| unsigned | packetCount | ||
| ) |
Definition at line 77 of file Packet.cpp.
References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, and e57::toString().
| void PacketReadCache::dump | ( | int | indent = 0, |
| std::ostream & | os = std::cout |
||
| ) |
Definition at line 257 of file Packet.cpp.
References e57::DATA_PACKET, IndexPacket::dump(), EmptyPacketHeader::dump(), e57::DataPacket::dump(), e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, e57::EMPTY_PACKET, QtCompat::endl(), entries_, e57::INDEX_PACKET, lockCount_, EmptyPacketHeader::packetType, e57::space(), e57::toString(), and useCount_.
| std::unique_ptr< PacketLock > PacketReadCache::lock | ( | uint64_t | packetLogicalOffset, |
| char *& | pkt | ||
| ) |
Only allow one locked packet at a time.
Offset can't be 0
Linear scan for matching packet offset in cache
Found a match, so don't have to read anything
Mark entry with current useCount (keeps track of age of entry).
Publish buffer address to caller
Create lock so we are sure that we will be unlocked when use is finished.
Increment cache lock just before return
Get here if didn't find a match already in cache.
Find least recently used (LRU) packet buffer
Publish buffer address to caller
Create lock so we are sure we will be unlocked when use is finished.
Increment cache lock just before return
Definition at line 85 of file Packet.cpp.
References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, QtCompat::endl(), entries_, lockCount_, PacketLock, readPacket(), e57::toString(), and useCount_.
Referenced by e57::CompressedVectorReaderImpl::CompressedVectorReaderImpl().
|
protected |
Read header of packet first to get length. Use EmptyPacketHeader since it has the fields common to all packets.
Can't verify packet header here, because it is not really an EmptyPacketHeader.
Be paranoid about packetLength before read
Now read in whole packet into preallocated buffer_. Note buffer is
Verify that packet is good.
Mark entry with current useCount (keeps track of age of entry). This is a cache, so a small hiccup when useCount_ overflows won't hurt.
Definition at line 179 of file Packet.cpp.
References cFile_, e57::DATA_PACKET, e57::DATA_PACKET_MAX, e57::E57_ERROR_BAD_CV_PACKET, e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, e57::EMPTY_PACKET, QtCompat::endl(), entries_, e57::INDEX_PACKET, e57::CheckedFile::Logical, EmptyPacketHeader::packetLogicalLengthMinus1, EmptyPacketHeader::packetType, e57::CheckedFile::read(), e57::CheckedFile::seek(), e57::toString(), useCount_, EmptyPacketHeader::verify(), e57::DataPacket::verify(), and IndexPacket::verify().
Referenced by lock().
|
protected |
Definition at line 164 of file Packet.cpp.
References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, QtCompat::endl(), lockCount_, and e57::toString().
Referenced by e57::PacketLock::~PacketLock().
|
protected |
Definition at line 79 of file Packet.h.
Referenced by readPacket().
|
protected |
Definition at line 81 of file Packet.h.
Referenced by dump(), lock(), and readPacket().
|
protected |
|
protected |
Definition at line 78 of file Packet.h.
Referenced by dump(), lock(), and readPacket().