Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PointerVector to manage devices in DeviceLists. #1488

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

Dimi1010
Copy link
Collaborator

@Dimi1010 Dimi1010 commented Jul 7, 2024

Rework of #1431 p1 and p2.

  • Refactored to use PointerVector<Device> in lists:

    • PcapLiveDeviceList - provides a better API then std::vector<std::unique_ptr<Device>>
    • PcapRemoteDeviceList - provides an automatic memory management then std::vector<Device*>
    • PfRingDeviceList - provides a better API then std::vector<std::unique_ptr<Device>>
  • Added begin/end iteration API to lists:

    • PcapLiveDeviceList
    • PfRingDeviceList
  • Added iterator and const_iterator type aliases to the lists.
    IMO, the member type definitions should follow the standard member types, even if they slightly deviate from the internal library convention as that would allow better integration with standard templated utility functions and classes.

    In addition, I feel like the names PcapRemoteDeviceIterator and PcapConstRemoteDeviceIterator should be best left to concrete definitions of custom iterator classes if needed, instead of being member type alias definitions. Part of the point of the member type alias definitions is to allow templated functions to dynamically fetch the type of the container at compile time, and for that the definition member identifier needs to be consistent across different containers.
    Affected lists:

    • PcapLiveDeviceList
    • PcapRemoteDeviceList
    • PfRingDeviceList
  • Deprecated getPcap*DevicesList.
    The list classes should provide direct functions for iteration and fetching devices. It makes no sense to have to get another 'List' from a 'List' class. Additionally this getter in particular returns a reference which ties the internal implementation to it making it difficult to change.
    Affected Lists:

    • PcapLiveDeviceList
    • PfRingDeviceList
  • Updated usages of deprecated methods in the library with non-deprecated methods.

@Dimi1010 Dimi1010 marked this pull request as ready for review July 8, 2024 22:20
@Dimi1010 Dimi1010 requested a review from seladb as a code owner July 8, 2024 22:20
Copy link
Collaborator

@tigercosmos tigercosmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- Added iterator API
- Added iterator type aliases.
- Deprecated getPfRingDevicesList.
- Updated calls to getPfRingDevicesList.
@Dimi1010
Copy link
Collaborator Author

@tigercosmos added PfRingDeviceList to the refactor last minute. Sry for the re-review request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants