Leosac
0.8.0
Open Source Access Control
Visitor.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <type_traits>
23
24
namespace
Leosac
25
{
26
namespace
Tools
27
{
28
29
class
IVisitable;
30
37
class
BaseVisitor
38
{
39
public
:
40
virtual
~BaseVisitor
() =
default
;
41
45
virtual
void
cannot_visit
(
const
IVisitable
&);
46
};
47
48
class
IVisitable
;
49
63
template
<
typename
T>
64
class
Visitor
:
public
virtual
BaseVisitor
65
{
66
public
:
67
using
VisitableT
= std::remove_reference_t<std::remove_const_t<T>>;
68
69
// While correct, this forces additional includes.
70
// static_assert(std::is_base_of<IVisitable, VisitableT>::value,
71
// "Trying to implement a visitor for a type that doesn't implement "
72
// "IVisitable.");
73
74
virtual
void
visit
(
const
VisitableT
&)
75
{
76
}
77
virtual
void
visit
(
VisitableT
&visitable)
78
{
79
visit
(
const_cast<
const
VisitableT
&
>
(visitable));
80
}
81
};
82
}
83
}
Leosac::Tools::BaseVisitor::~BaseVisitor
virtual ~BaseVisitor()=default
Leosac::Tools::BaseVisitor::cannot_visit
virtual void cannot_visit(const IVisitable &)
Invoked when the visitable cannot be visited by the visitor.
Definition:
Visitor.cpp:30
Leosac::Tools::BaseVisitor
Base class for visitor, should not be used directly.
Definition:
Visitor.hpp:37
Leosac::Tools::Visitor< Audit::IUpdateEvent >::VisitableT
std::remove_reference_t< std::remove_const_t< Audit::IUpdateEvent > > VisitableT
Definition:
Visitor.hpp:67
Leosac::Tools::Visitor
A Visitor object.
Definition:
Visitor.hpp:64
Leosac::Tools::Visitor::visit
virtual void visit(const VisitableT &)
Definition:
Visitor.hpp:74
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Tools::IVisitable
Base class to make an object visitable.
Definition:
IVisitable.hpp:43
Leosac::Tools::Visitor::visit
virtual void visit(VisitableT &visitable)
Definition:
Visitor.hpp:77
src
tools
Visitor.hpp
Generated on Tue Mar 22 2022 10:48:32 for Leosac by
1.8.17