ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
Visitor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5namespace ChimeraTK {
6
7 /********************************************************************************************************************/
8
9 /*
10 * Losely based on
11 * https://stackoverflow.com/questions/11796121/implementing-the-visitor-pattern-using-c-templates#11802080
12 */
13
14 /********************************************************************************************************************/
15
16 template<typename... Types>
17 class Visitor;
18
19 /********************************************************************************************************************/
20
21 template<typename T>
22 class Visitor<T> {
23 public:
24 virtual void dispatch(const T& t) = 0;
25 };
26
27 /********************************************************************************************************************/
28
29 template<typename T, typename... Types>
30 class Visitor<T, Types...> : public Visitor<T>, public Visitor<Types...> {
31 public:
32 using Visitor<Types...>::dispatch;
33 using Visitor<T>::dispatch;
34 };
35
36 /********************************************************************************************************************/
37
38} // namespace ChimeraTK
virtual void dispatch(const T &t)=0
InvalidityTracer application module.