OpenFOAM: API Guide
v2112
The open source CFD toolbox
Callback.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2011 OpenFOAM Foundation
9
Copyright (C) 2019 OpenCFD Ltd.
10
-------------------------------------------------------------------------------
11
License
12
This file is part of OpenFOAM.
13
14
OpenFOAM is free software: you can redistribute it and/or modify it
15
under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22
for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27
\*---------------------------------------------------------------------------*/
28
29
#include "
Callback.H
"
30
31
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33
template
<
class
CallbackType>
34
Foam::Callback<CallbackType>::Callback
(
CallbackRegistry<CallbackType>
& cbr)
35
:
36
cbr_(cbr)
37
{
38
checkIn
();
39
}
40
41
42
template
<
class
CallbackType>
43
Foam::Callback<CallbackType>::Callback
(
const
Callback<CallbackType>
& cb)
44
:
45
cbr_(cb.cbr_)
46
{
47
checkIn
();
48
}
49
50
51
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
52
53
template
<
class
CallbackType>
54
Foam::Callback<CallbackType>::~Callback
()
55
{
56
checkOut();
57
}
58
59
60
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61
62
template
<
class
CallbackType>
63
bool
Foam::Callback<CallbackType>::checkIn
()
64
{
65
if
(!
Callback<CallbackType>::link::registered
())
66
{
67
cbr_.append(
static_cast<
CallbackType*
>
(
this
));
68
return
true
;
69
}
70
71
return
false
;
72
}
73
74
75
template
<
class
CallbackType>
76
bool
Foam::Callback<CallbackType>::checkOut
()
77
{
78
if
(
Callback<CallbackType>::link::registered
())
79
{
80
CallbackType* ptr = cbr_.remove(
static_cast<
CallbackType*
>
(
this
));
81
82
return
ptr;
83
}
84
85
return
false
;
86
}
87
88
89
// ************************************************************************* //
Callback.H
Foam::CallbackRegistry
Base class with which callbacks are registered.
Definition:
CallbackRegistry.H:72
Foam::Callback
Abstract class to handle automatic call-back registration with the CallbackRegistry....
Definition:
Callback.H:56
Foam::Callback::~Callback
virtual ~Callback()
Destructor.
Definition:
Callback.C:54
Foam::Callback::checkOut
bool checkOut()
Check-out Callback from CallbackRegistry.
Definition:
Callback.C:76
Foam::Callback::checkIn
bool checkIn()
Register Callback with CallbackRegistry.
Definition:
Callback.C:63
src
OpenFOAM
db
Callback
Callback.C
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.