Class EventPacketContainer

Class Documentation

class EventPacketContainer

Public Types

using value_type = std::shared_ptr<EventPacket>
using const_value_type = std::shared_ptr<const EventPacket>
using size_type = int32_t
using difference_type = ptrdiff_t
using iterator = EventPacketContainerCopyIterator<std::vector<std::shared_ptr<EventPacket>>::iterator, std::shared_ptr<EventPacket>>
using const_iterator = EventPacketContainerCopyIterator<std::vector<std::shared_ptr<EventPacket>>::const_iterator, std::shared_ptr<const EventPacket>>
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Functions

inline EventPacketContainer()

Construct a new EventPacketContainer.

inline EventPacketContainer(size_type eventPacketsNumber)

Construct a new EventPacketContainer with enough space to store up to the given number of event packet pointers. The pointers are present and initialized to nullptr.

Parameters:

eventPacketsNumber – the initial number of event packet pointers that can be stored in this container. Must be equal to one or higher.

inline EventPacketContainer(caerEventPacketContainer packetContainer, bool takeMemoryOwnership = true)

Construct a new EventPacketContainer from a C-style caerEventPacketContainer. The contained packets can take over memory ownership if so requested.

Parameters:
  • packetContainer – C-style caerEventPacketContainer from which to initialize the new packet container.

  • takeMemoryOwnership – true if the container packets shall take over the ownership of the memory containing the events from the C-style packets.

inline size_type capacity() const noexcept
inline size_type size() const noexcept
inline bool empty() const noexcept
inline void clear() noexcept
inline value_type getEventPacket(size_type index)

Get the pointer to the event packet stored in this container at the given index.

Parameters:

index – the index of the event packet to get.

Throws:

std:out_of_range – no packet exists at given index.

Returns:

a pointer to an event packet.

inline value_type operator[](size_type index)
inline const_value_type getEventPacket(size_type index) const

Get the pointer to the event packet stored in this container at the given index. This is a read-only event packet, do not change its contents in any way!

Parameters:

index – the index of the event packet to get.

Throws:

std:out_of_range – no packet exists at given index.

Returns:

a pointer to a read-only event packet.

inline const_value_type operator[](size_type index) const
inline void setEventPacket(size_type index, value_type packetHeader)

Set the pointer to the event packet stored in this container at the given index. The index must be valid already, this does not change the container size.

Parameters:
  • index – the index of the event packet to set.

  • packetHeader – a pointer to an event packet. Can be a nullptr.

Throws:

std:out_of_range – no packet exists at given index.

inline void addEventPacket(value_type packetHeader)

Add an event packet pointer at the end of this container. Increases container size by one.

Parameters:

packetHeader – a pointer to an event packet. Can be a nullptr.

inline int64_t getLowestEventTimestamp() const noexcept

Get the lowest timestamp contained in this event packet container.

Returns:

the lowest timestamp (in µs) or -1 if not initialized.

inline int64_t getHighestEventTimestamp() const noexcept

Get the highest timestamp contained in this event packet container.

Returns:

the highest timestamp (in µs) or -1 if not initialized.

inline int32_t getEventsNumber() const noexcept

Get the number of events contained in this event packet container.

Returns:

the number of events in this container.

inline int32_t getEventsValidNumber() const noexcept

Get the number of valid events contained in this event packet container.

Returns:

the number of valid events in this container.

inline void updateStatistics() noexcept

Recalculates and updates all the packet-container level statistics (event counts and timestamps).

inline value_type findEventPacketByType(int16_t typeID)

Get the pointer to an event packet stored in this container with the given event type. This returns the first found event packet with that type ID, or nullptr if we get to the end without finding any such event packet.

Parameters:

typeID – the event type to search for.

Returns:

a pointer to an event packet with a certain type or nullptr if none found.

inline std::unique_ptr<std::vector<value_type>> findEventPacketsByType(int16_t typeID)
inline const_value_type findEventPacketByType(int16_t typeID) const

Get the pointer to a read-only event packet stored in this container with the given event type. This returns the first found event packet with that type ID, or nullptr if we get to the end without finding any such event packet.

Parameters:

typeID – the event type to search for.

Returns:

a pointer to a read-only event packet with a certain type or nullptr if none found.

inline std::unique_ptr<std::vector<const_value_type>> findEventPacketsByType(int16_t typeID) const
inline value_type findEventPacketBySource(int16_t sourceID)

Get the pointer to an event packet stored in this container from the given event source. This returns the first found event packet with that source ID, or nullptr if we get to the end without finding any such event packet.

Parameters:

sourceID – the event source to search for.

Returns:

a pointer to an event packet with a certain source or nullptr if none found.

inline std::unique_ptr<std::vector<value_type>> findEventPacketsBySource(int16_t sourceID)
inline const_value_type findEventPacketBySource(int16_t sourceID) const

Get the pointer to a read-only event packet stored in this container from the given event source. This returns the first found event packet with that source ID, or nullptr if we get to the end without finding any such event packet.

Parameters:

sourceID – the event source to search for.

Returns:

a pointer to a read-only event packet with a certain source or nullptr if none found.

inline std::unique_ptr<std::vector<const_value_type>> findEventPacketsBySource(int16_t sourceID) const
inline std::unique_ptr<EventPacketContainer> copyAllEvents() const

Make a deep copy of this event packet container and all of its event packets and their current events. A normal copy (using copy constructor or assignment) copies all the container’s internals, and correctly handles the pointers to the event packets held in it, but those will still point to the old event packets. To also copy the individual event packets and point to the new copies, use this function.

Returns:

a deep copy of this event packet container, containing all events.

inline std::unique_ptr<EventPacketContainer> copyValidEvents() const

Make a deep copy of this event packet container, with its event packets sized down to only include the currently valid events (eventValid), and discarding everything else. A normal copy (using copy constructor or assignment) copies all the container’s internals, and correctly handles the pointers to the event packets held in it, but those will still point to the old event packets. To also copy the individual event packets and point to the new copies, use this function.

Returns:

a deep copy of this event packet container, containing only valid events.

inline iterator begin() noexcept
inline iterator end() noexcept
inline const_iterator begin() const noexcept
inline const_iterator end() const noexcept
inline const_iterator cbegin() const noexcept
inline const_iterator cend() const noexcept
inline reverse_iterator rbegin() noexcept
inline reverse_iterator rend() noexcept
inline const_reverse_iterator rbegin() const noexcept
inline const_reverse_iterator rend() const noexcept
inline const_reverse_iterator crbegin() const noexcept
inline const_reverse_iterator crend() const noexcept