Skip to content

Conversation

Copy link

Copilot AI commented Jan 8, 2026

Description

Adds C++20 concepts defining common interfaces across frame types, enabling compile-time type checking and generic programming with detector data structures.

Implementation

Core concepts (12 total organized by category):

  • Data access: HasADC (single-sample), HasADCSample (TDE16Frame interface), HasChannelData (WIBFrame channel-based), HasMultiSampleADC (WIBEthFrame multi-sample)
  • Metadata: HasTimestamp, HasChannel, HasHeader
  • Composite: IsFrame (timestamp + any data access), IsCompleteFrame (adds channel ID)
  • Binary format: BinaryCompatible, FrameHeader, WordBased, ADCData

Design decisions:

  • Non-intrusive: works with existing interfaces without modification
  • Flexible: accommodates different naming conventions (get_adc vs get_channel vs get_adc_sample)
  • Each frame type satisfies IsFrame via its specific data access pattern

Usage example:

#include "fddetdataformats/Concepts.hpp"

// Generic processing for any frame type
template<IsFrame F>
void process_frame(const F& frame) {
  auto timestamp = frame.get_timestamp();
  // ...
}

// Constrained to specific interface
template<HasADC F>
uint16_t read_adc(const F& frame, int ch) {
  return frame.get_adc(ch);
}

Type of change

  • New feature or enhancement (non-breaking change which adds functionality)

Testing checklist

  • Unit tests pass (e.g. dbt-build --unittest)
  • Minimal system quicktest passes (pytest -s minimal_system_quick_test.py)
  • Full set of integration tests pass (daqsystemtest_integtest_bundle.sh)
  • Python tests pass if applicable (e.g. python -m pytest)
  • Pre-commit hooks run successfully if applicable (e.g. pre-commit run --all-files)

Comprehensive unit tests added in Concepts_test.cxx verifying all concepts against all frame types. Concepts verified to compile with g++ 13.3.0 and C++20.

Further checks

All concepts documented with usage examples in docs/README.md.

Original prompt

Create a set of C++20 concepts to apply to the structs in this repository


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 8, 2026 17:03
Co-authored-by: eflumerf <61473357+eflumerf@users.noreply.github.com>
Co-authored-by: eflumerf <61473357+eflumerf@users.noreply.github.com>
Co-authored-by: eflumerf <61473357+eflumerf@users.noreply.github.com>
Co-authored-by: eflumerf <61473357+eflumerf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add C++20 concepts for struct validation Add C++20 concepts for frame type interfaces Jan 8, 2026
Copilot AI requested a review from eflumerf January 8, 2026 17:12
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.

2 participants