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

Refactor: Modernizing filters to Cpp11. #1323

Merged
merged 2 commits into from
Feb 24, 2024

Conversation

Dimi1010
Copy link
Collaborator

@Dimi1010 Dimi1010 commented Feb 23, 2024

Part of #977

The change is mostly C-style casts to Cpp style casts.
Marked all parseToString overrides as override.

Additionally, some changes I think it might be beneficial, but I would like an opinion before starting on them:

  1. parseToString being marked as const.
    Reasoning: The conversion to string should not modify the filter internals under any circumstances.
    Potential issues: If someone has written custom filters inherited from GenericFilter or down the chain and implemented their own parseToString this will be a breaking change for the custom filter as parseToString and parseToString const are considered different functions by the compiler.
    No expected issues with plain usage of the function, if only one version exists, or the non-const version calls the const version as a default via some black magics like:
virtual void parseToString(std::string &result)
{
    static_cast<GeneralFilter const *>(this)->parseToString(result);
};
virtual void parseToString(std::string &result) const = 0;
  1. enum -> enum class - Read some of the discussion in Refactor code: use enum class in TcpLayer #1289, about potential solutions to that. Duplicated enums/ctors seem like the best solution for keeping the backwards compatibility in the intermediary period. Although I am debating on the naming. Simplest solution is to stick a V2 or Type suffix or something? (example Direction -> DirectionV2 or DirectionType).
    Also I am wondering what to do with the functions that return an enum like Direction getDir()?

  2. Implement C++11 move semantics for filter ctors that take string const&. Either by implementing 'perfect forwarding' or 'pass by value and move' as a simpler alternative.

  3. Explicitly defaulting empty destructors. Should produce no compatibility issues in the current situation but can have some caveats in other situations explained here

@Dimi1010 Dimi1010 requested a review from seladb as a code owner February 23, 2024 17:48
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.38%. Comparing base (28b9072) to head (7c72afb).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1323      +/-   ##
==========================================
- Coverage   82.41%   82.38%   -0.03%     
==========================================
  Files         163      163              
  Lines       20938    20938              
  Branches     7903     7903              
==========================================
- Hits        17256    17250       -6     
- Misses       3019     3026       +7     
+ Partials      663      662       -1     
Flag Coverage Δ
alpine317 72.41% <100.00%> (-0.01%) ⬇️
fedora37 72.42% <100.00%> (ø)
macos-12 61.43% <25.00%> (ø)
macos-13 60.46% <25.00%> (ø)
macos-14 60.46% <25.00%> (ø)
macos-ventura 61.48% <25.00%> (ø)
mingw32 70.28% <100.00%> (-0.04%) ⬇️
mingw64 70.30% <100.00%> (-0.02%) ⬇️
npcap 83.35% <100.00%> (-0.06%) ⬇️
rhel93 72.40% <100.00%> (-0.05%) ⬇️
ubuntu1804 74.76% <100.00%> (ø)
ubuntu2004 73.16% <100.00%> (-0.06%) ⬇️
ubuntu2204 72.23% <100.00%> (ø)
ubuntu2204-icpx 58.98% <25.00%> (-0.06%) ⬇️
unittest 82.38% <100.00%> (-0.03%) ⬇️
windows-2019 83.39% <100.00%> (-0.03%) ⬇️
windows-2022 83.40% <100.00%> (-0.03%) ⬇️
winpcap 83.38% <100.00%> (ø)
xdp 59.07% <0.00%> (-0.01%) ⬇️
zstd 73.79% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seladb seladb merged commit 9f94199 into seladb:dev Feb 24, 2024
40 checks passed
@Dimi1010 Dimi1010 deleted the refactor/filter-cpp11-modenrization branch May 5, 2024 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants