Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
9e8564af
Kaydet (Commit)
9e8564af
authored
Mar 05, 2015
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplify o3tl::LazyUpdate
Change-Id: I7569a20877411a5ceb4a7475d82cb634eb6cb114
üst
f965b108
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
195 deletions
+35
-195
simplecanvasimpl.cxx
canvas/source/simplecanvas/simplecanvasimpl.cxx
+5
-5
lazy_update.hxx
include/o3tl/lazy_update.hxx
+30
-190
No files found.
canvas/source/simplecanvas/simplecanvasimpl.cxx
Dosyayı görüntüle @
9e8564af
...
@@ -46,7 +46,7 @@ using namespace canvas;
...
@@ -46,7 +46,7 @@ using namespace canvas;
namespace
namespace
{
{
inline
uno
::
Sequence
<
double
>
color2Sequence
(
sal_Int32
const
&
nColor
)
inline
uno
::
Sequence
<
double
>
color2Sequence
(
sal_Int32
nColor
)
{
{
// TODO(F3): Color management
// TODO(F3): Color management
uno
::
Sequence
<
double
>
aRes
(
4
);
uno
::
Sequence
<
double
>
aRes
(
4
);
...
@@ -84,13 +84,13 @@ namespace
...
@@ -84,13 +84,13 @@ namespace
{
{
o3tl
::
LazyUpdate
<
sal_Int32
,
o3tl
::
LazyUpdate
<
sal_Int32
,
uno
::
Sequence
<
double
>
,
uno
::
Sequence
<
double
>
,
o3tl
::
LAZYUPDATE_FUNCTION_TAG
>
m_aPenColor
;
decltype
(
&
color2Sequence
)
>
m_aPenColor
;
o3tl
::
LazyUpdate
<
sal_Int32
,
o3tl
::
LazyUpdate
<
sal_Int32
,
uno
::
Sequence
<
double
>
,
uno
::
Sequence
<
double
>
,
o3tl
::
LAZYUPDATE_FUNCTION_TAG
>
m_aFillColor
;
decltype
(
&
color2Sequence
)
>
m_aFillColor
;
o3tl
::
LazyUpdate
<
geometry
::
RealRectangle2D
,
o3tl
::
LazyUpdate
<
geometry
::
RealRectangle2D
,
uno
::
Reference
<
rendering
::
XPolyPolygon2D
>
,
uno
::
Reference
<
rendering
::
XPolyPolygon2D
>
,
o3tl
::
LAZYUPDATE_FUNCTOR_TAG
>
m_aRectClip
;
boost
::
function1
<
uno
::
Reference
<
rendering
::
XPolyPolygon2D
>
,
geometry
::
RealRectangle2D
>
>
m_aRectClip
;
geometry
::
AffineMatrix2D
m_aTransformation
;
geometry
::
AffineMatrix2D
m_aTransformation
;
explicit
SimpleRenderState
(
uno
::
Reference
<
rendering
::
XGraphicDevice
>
const
&
xDevice
)
:
explicit
SimpleRenderState
(
uno
::
Reference
<
rendering
::
XGraphicDevice
>
const
&
xDevice
)
:
...
@@ -367,7 +367,7 @@ namespace
...
@@ -367,7 +367,7 @@ namespace
typedef
o3tl
::
LazyUpdate
<
typedef
o3tl
::
LazyUpdate
<
rendering
::
FontRequest
,
rendering
::
FontRequest
,
uno
::
Reference
<
rendering
::
XCanvasFont
>
,
uno
::
Reference
<
rendering
::
XCanvasFont
>
,
o3tl
::
LAZYUPDATE_FUNCTOR_TAG
>
SimpleFont
;
boost
::
function1
<
uno
::
Reference
<
rendering
::
XCanvasFont
>
,
rendering
::
FontRequest
>
>
SimpleFont
;
uno
::
Reference
<
rendering
::
XCanvas
>
mxCanvas
;
uno
::
Reference
<
rendering
::
XCanvas
>
mxCanvas
;
SimpleFont
maFont
;
SimpleFont
maFont
;
...
...
include/o3tl/lazy_update.hxx
Dosyayı görüntüle @
9e8564af
...
@@ -20,8 +20,9 @@
...
@@ -20,8 +20,9 @@
#ifndef INCLUDED_O3TL_LAZY_UPDATE_HXX
#ifndef INCLUDED_O3TL_LAZY_UPDATE_HXX
#define INCLUDED_O3TL_LAZY_UPDATE_HXX
#define INCLUDED_O3TL_LAZY_UPDATE_HXX
#include <sal/types.h>
#include <sal/config.h>
#include <boost/function.hpp>
#include <utility>
namespace
o3tl
namespace
o3tl
{
{
...
@@ -35,7 +36,7 @@ namespace o3tl
...
@@ -35,7 +36,7 @@ namespace o3tl
@example
@example
<pre>
<pre>
LazyUpdate<InType,OutType,
LAZYUPDATE_DIRECT_TAG> myValue
;
LazyUpdate<InType,OutType,
decltype(F)> myValue(F)
;
*myValue = newInput;
*myValue = newInput;
myValue->updateInput( this, that, those );
myValue->updateInput( this, that, those );
...
@@ -47,208 +48,47 @@ output( myValue.getOutValue() );
...
@@ -47,208 +48,47 @@ output( myValue.getOutValue() );
</pre>
</pre>
if the compiler does not recognize the const context.
if the compiler does not recognize the const context.
*/
*/
template
<
typename
InputType
,
typename
OutputType
,
typename
Tag
>
class
LazyUpdate
;
template
<
typename
In
,
typename
Out
,
typename
Func
>
class
LazyUpdate
{
/// LazyUpdate specialization takes boost::function argument
struct
LAZYUPDATE_FUNCTOR_TAG
{};
/// LazyUpdate specialization takes OutputType (*FunctionType)( InputType const& ) argument
struct
LAZYUPDATE_FUNCTION_TAG
{};
/// LazyUpdate specialization can directly convert, OutputType ctor must take InputType argument
struct
LAZYUPDATE_DIRECT_TAG
{};
namespace
detail
{
/// @internal
template
<
typename
InputType
,
typename
OutputType
,
typename
Functor
>
class
LazyUpdateImpl
:
private
Functor
{
public
:
public
:
typedef
OutputType
output_type
;
LazyUpdate
(
Func
const
&
func
)
:
func_
(
func
),
input_
(),
dirty_
(
true
)
{}
typedef
InputType
input_type
;
LazyUpdateImpl
()
:
m_aInput
()
{}
template
<
typename
ParamType
>
explicit
LazyUpdateImpl
(
ParamType
const
&
rParm
)
:
Functor
(
rParm
),
m_aInput
()
{}
enum
UnaryConstructorTag
{
UNARY_CONSTRUCTOR_TAG
};
LazyUpdateImpl
(
const
input_type
&
rInput
,
UnaryConstructorTag
)
:
m_aInput
(
rInput
)
{}
template
<
typename
ParamType
>
LazyUpdateImpl
(
ParamType
const
&
rParm
,
const
input_type
&
rInput
)
:
Functor
(
rParm
),
m_aInput
(
rInput
)
{}
// default copy ctor/assignment operator are ok
// LazyUpdate( const LazyUpdate& );
// LazyUpdate& operator=( const LazyUpdate& );
void
setInValue
(
input_type
const
&
rIn
)
{
Functor
::
m_bCacheDirty
=
true
;
m_aInput
=
rIn
;
}
template
<
typename
T
>
void
setInValue
(
T
&&
in
)
{
input_type
const
&
getInValue
()
const
{
return
m_aInput
;
}
dirty_
=
true
;
output_type
const
&
getOutValue
()
const
{
return
this
->
implUpdateValue
(
m_aInput
);
}
input_
=
std
::
forward
(
in
);
}
input_type
&
operator
*
()
{
Functor
::
m_bCacheDirty
=
true
;
return
m_aInput
;
}
input_type
*
operator
->
()
{
Functor
::
m_bCacheDirty
=
true
;
return
&
m_aInput
;
}
output_type
const
&
operator
*
()
const
{
return
this
->
implUpdateValue
(
m_aInput
);
}
output_type
const
*
operator
->
()
const
{
return
&
(
this
->
implUpdateValue
(
m_aInput
));
}
private
:
input_type
m_aInput
;
};
template
<
typename
InputType
,
typename
OutputType
>
struct
DefaultFunctor
In
const
&
getInValue
()
const
{
return
input_
;
}
{
protected
:
typedef
OutputType
output_type
;
typedef
InputType
input_type
;
DefaultFunctor
()
:
Out
const
&
getOutValue
()
const
{
return
update
();
}
m_aOutput
(),
m_bCacheDirty
(
true
)
{}
OutputType
const
&
implUpdateValue
(
input_type
const
&
rIn
)
const
In
&
operator
*
()
{
{
dirty_
=
true
;
if
(
m_bCacheDirty
)
return
input_
;
{
m_aOutput
=
output_type
(
rIn
);
m_bCacheDirty
=
false
;
}
}
return
m_aOutput
;
In
*
operator
->
()
{
dirty_
=
true
;
return
&
input_
;
}
}
mutable
output_type
m_aOutput
;
Out
const
&
operator
*
()
const
{
return
update
();
}
mutable
bool
m_bCacheDirty
;
// when true, m_aOutput needs update
};
template
<
typename
InputType
,
typename
OutputType
,
typename
FunctionType
>
struct
FunctionPointer
{
protected
:
typedef
OutputType
output_type
;
typedef
InputType
input_type
;
typedef
FunctionType
function_type
;
FunctionPointer
()
:
Out
const
*
operator
->
()
const
{
return
&
update
();
}
m_pFunc
(),
m_aOutput
(),
m_bCacheDirty
(
true
)
{}
private
:
Out
const
&
update
()
const
{
explicit
FunctionPointer
(
function_type
const
&
pFunc
)
:
if
(
dirty_
)
{
m_pFunc
(
pFunc
),
output_
=
func_
(
input_
);
m_aOutput
(),
dirty_
=
false
;
m_bCacheDirty
(
true
)
{}
output_type
const
&
implUpdateValue
(
input_type
const
&
rIn
)
const
{
if
(
m_bCacheDirty
)
{
m_aOutput
=
m_pFunc
(
rIn
);
m_bCacheDirty
=
false
;
}
return
m_aOutput
;
}
}
return
output_
;
function_type
m_pFunc
;
mutable
output_type
m_aOutput
;
mutable
bool
m_bCacheDirty
;
// when true, m_aOutput needs update
};
}
}
// partial specializations for the three LAZYUPDATE_* tags
Func
const
func_
;
template
<
typename
InputType
,
typename
OutputType
>
class
LazyUpdate
<
InputType
,
In
input_
;
OutputType
,
mutable
Out
output_
;
LAZYUPDATE_DIRECT_TAG
>
:
mutable
bool
dirty_
;
public
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
DefaultFunctor
<
InputType
,
OutputType
>
>
{
public
:
LazyUpdate
()
{}
explicit
LazyUpdate
(
InputType
const
&
rIn
)
:
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
DefaultFunctor
<
InputType
,
OutputType
>
>
(
rIn
,
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
DefaultFunctor
<
InputType
,
OutputType
>
>::
UNARY_CONSTRUCTOR_TAG
)
{}
};
template
<
typename
InputType
,
typename
OutputType
>
class
LazyUpdate
<
InputType
,
OutputType
,
LAZYUPDATE_FUNCTION_TAG
>
:
public
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
OutputType
(
*
)(
InputType
const
&
)
>
>
{
public
:
explicit
LazyUpdate
(
OutputType
(
*
pFunc
)(
InputType
const
&
)
)
:
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
OutputType
(
*
)(
InputType
const
&
)
>
>
(
pFunc
)
{}
LazyUpdate
(
OutputType
(
*
pFunc
)(
InputType
const
&
),
InputType
const
&
rIn
)
:
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
OutputType
(
*
)(
InputType
const
&
)
>
>
(
pFunc
,
rIn
)
{}
};
};
template
<
typename
InputType
,
typename
OutputType
>
class
LazyUpdate
<
InputType
,
OutputType
,
LAZYUPDATE_FUNCTOR_TAG
>
:
public
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
boost
::
function1
<
OutputType
,
InputType
>
>
>
{
public
:
explicit
LazyUpdate
(
boost
::
function1
<
OutputType
,
InputType
>
const
&
rFunc
)
:
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
boost
::
function1
<
OutputType
,
InputType
>
>
>
(
rFunc
)
{}
LazyUpdate
(
boost
::
function1
<
OutputType
,
InputType
>
const
&
rFunc
,
InputType
const
&
rIn
)
:
detail
::
LazyUpdateImpl
<
InputType
,
OutputType
,
detail
::
FunctionPointer
<
InputType
,
OutputType
,
boost
::
function1
<
OutputType
,
InputType
>
>
>
(
rFunc
,
rIn
)
{}
};
}
}
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment