Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • C cmsgemos
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 100
    • Issues 100
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cmsgemonline
  • gem-daq
  • cmsgemos
  • Issues
  • #96
Closed
Open
Created Jun 01, 2020 by Laurent Petre@lpetreOwner

Provide easy type-safe hardware layout tree traversal mechanism

Summary

Just copying https://gitlab.cern.ch/cmsgemonline/cmsgemos/-/issues/42#note_3440296 here, so the idea does not get lost, even if the implementation is delayed.

""" The two elements described in the original description are introduced in !28 (merged). While developing it, I had a new idea to provide easier type-safe traversal of the tree. One could enable the following syntax (starting from a link):

link.children() | type_switch(
    [] (const optohybrid_fpga_node& oh_fpga) {
        std::cout << "this is the fpga" << std::endl;
    },
    [] (const vfat_node& vfat) {
        std::cout << "this is a vfat" << std::endl;
    },
    [] (const gbtx_node& gbtx) {
        std::cout << "this is a gbtx" << std::endl;
    }
)

type_switch would perform the required dynamic_cast under the hood and call the relevant lambda for each node. It could also have an overload taking a node* as first argument, type_switch(node*, lambdas...).

In many cases type_switch would be more powerful alternative to filter_nodes, but the latter is still useful because it requires less typing and returns a valid range that can be passed to <algorithm> & co.

Thoughts, comments, ideas? Please add 😍 if you can't live without this and ⚱ if you think it's not worth using variadic templates. [edit: the two options also read as "include it" and "don't"]

[The ⏳ means we should wait] """

Assignee
Assign to
Time tracking