LibreOffice Module o3tl (master)
1
include
o3tl
lazy_update.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
4
*
5
* This Source Code Form is subject to the terms of the Mozilla Public
6
* License, v. 2.0. If a copy of the MPL was not distributed with this
7
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
*
9
* This file incorporates work covered by the following license notice:
10
*
11
* Licensed to the Apache Software Foundation (ASF) under one or more
12
* contributor license agreements. See the NOTICE file distributed
13
* with this work for additional information regarding copyright
14
* ownership. The ASF licenses this file to you under the Apache
15
* License, Version 2.0 (the "License"); you may not use this file
16
* except in compliance with the License. You may obtain a copy of
17
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
*/
19
20
#ifndef INCLUDED_O3TL_LAZY_UPDATE_HXX
21
#define INCLUDED_O3TL_LAZY_UPDATE_HXX
22
23
#include <utility>
24
25
namespace
o3tl
26
{
49
template
<
typename
In,
typename
Out,
typename
Func>
class
LazyUpdate
{
50
public
:
51
LazyUpdate
(Func func):
func_
(
std
::move(func)),
input_
(),
dirty_
(true) {}
52
53
In
const
&
getInValue
()
const
{
return
input_
; }
54
55
Out
const
&
getOutValue
()
const
{
return
update
(); }
56
57
In
&
operator *
() {
58
dirty_
=
true
;
59
return
input_
;
60
}
61
62
In
*
operator ->
() {
63
dirty_
=
true
;
64
return
&
input_
;
65
}
66
67
Out
const
&
operator *
()
const
{
return
update
(); }
68
69
Out
const
*
operator ->
()
const
{
return
&
update
(); }
70
71
private
:
72
Out
const
&
update
()
const
{
73
if
(
dirty_
) {
74
output_
=
func_
(
input_
);
75
dirty_
=
false
;
76
}
77
return
output_
;
78
}
79
80
Func
const
func_
;
81
In
input_
;
82
mutable
Out
output_
;
83
mutable
bool
dirty_
;
84
};
85
}
86
87
#endif
88
89
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
o3tl::LazyUpdate
Definition:
lazy_update.hxx:49
o3tl::LazyUpdate::operator->
In * operator->()
Definition:
lazy_update.hxx:62
o3tl::LazyUpdate::output_
Out output_
Definition:
lazy_update.hxx:82
o3tl::LazyUpdate::getInValue
In const & getInValue() const
Definition:
lazy_update.hxx:53
o3tl::LazyUpdate::getOutValue
Out const & getOutValue() const
Definition:
lazy_update.hxx:55
o3tl::LazyUpdate::dirty_
bool dirty_
Definition:
lazy_update.hxx:83
o3tl::LazyUpdate::input_
In input_
Definition:
lazy_update.hxx:81
o3tl::LazyUpdate::func_
Func const func_
Definition:
lazy_update.hxx:80
o3tl::LazyUpdate::LazyUpdate
LazyUpdate(Func func)
Definition:
lazy_update.hxx:51
o3tl::LazyUpdate::update
Out const & update() const
Definition:
lazy_update.hxx:72
o3tl::LazyUpdate::operator*
In & operator*()
Definition:
lazy_update.hxx:57
o3tl
std
SVGToken::In
@ In
Out
SwHTMLWriter & Out(const SwAttrFnTab, const SfxPoolItem &, SwHTMLWriter &)
Generated on Sun Jul 30 2023 04:39:37 for LibreOffice Module o3tl (master) by
1.9.3