libept
0.5.25
Main Page
Namespaces
Classes
Files
File List
File Members
ept
core
source.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
3
#include <
ept/core/list.h
>
4
5
#ifndef EPT_CORE_SOURCE_H
6
#define EPT_CORE_SOURCE_H
7
8
namespace
ept {
9
namespace
core {
10
11
template
<
typename
Self,
typename
Setup,
12
template
<
typename
Setup::PropertyId >
class
PType >
13
struct
Source
{
14
typedef
typename
Setup::PropertyId
PropertyId
;
15
typedef
typename
Setup::Token
Token
;
16
17
Token
m_cachedToken
;
18
typename
Setup::Internal
m_cached
;
19
20
Self &
self
() {
return
*
static_cast<
Self *
>
( this ); }
21
22
template
< PropertyId property >
23
typename
PType< property >::T
get
(
Token
t ) {
24
if
(
m_cachedToken
!= t ) {
25
m_cachedToken
= t;
26
m_cached
=
self
().lookupToken( t );
27
}
28
return
self
().
template
getInternal< property >(
m_cached
);
29
}
30
31
void
invalidate
() {
32
m_cachedToken
=
ept::Token
();
33
m_cached
=
typename
Setup::Internal
();
34
}
35
36
template
< PropertyId _property >
37
struct
ComposedList
: wibble::mixin::Comparable< ComposedList< _property > >
38
{
39
typedef
Self
Origin
;
40
typedef
typename
Setup::Token
Token
;
41
typedef
typename
PType< _property >::T
Property
;
42
typedef
ComposedList
Type
;
43
44
Origin
*
origin
;
45
typename
Setup::InternalList
internal
;
46
47
ComposedList
tail
()
const
{
48
return
ComposedList< _property >
( *
origin
,
internal
.tail() );
49
}
50
51
bool
empty
()
const
{
return
internal
.empty(); }
52
53
bool
operator<
(
const
ComposedList
&o )
const
{
54
return
token
() < o.
token
();
55
}
56
57
ComposedList
&
head
() {
return
*
this
; }
58
const
ComposedList
&
head
()
const
{
return
*
this
; }
59
60
Token
token
()
const
{
return
origin
->getToken(
internal
.
head
() ); }
61
62
Property
property
()
const
{
63
return
origin
->template getInternal< _property >(
64
internal
.head() );
65
}
66
67
template
< PropertyId P >
68
typename
PType< P >::T
69
get
()
const
{
70
return
origin
->template getInternal< P >(
internal
.head() );
71
}
72
73
ComposedList
() :
origin
( 0 ) {}
74
75
ComposedList
(
Origin
&o,
typename
Setup::InternalList
i )
76
:
origin
( &o ),
internal
( i ) {}
77
};
78
79
template
< PropertyId property >
80
ComposedList< property >
list
()
81
{
82
return
ComposedList< property >(
self
(),
self
().listInternal() );
83
}
84
85
template
< PropertyId P,
typename
F >
86
struct
Propertify
{
87
F
f
;
88
Propertify
( F _f = F() ) :
f
( _f ) {}
89
bool
operator()
(
const
ComposedList< P >
&x )
const
{
90
return
f
( x.
token
(), x.
property
() );
91
}
92
};
93
94
template
< PropertyId P,
typename
F >
95
struct
PropertyFilter
{
96
typedef
typename
list::Filtered<
97
ComposedList< P >
,
Propertify< P, F >
>
T
;
98
};
99
100
template
< PropertyId P,
typename
F >
101
typename
PropertyFilter< P, F >::T
102
propertyFilter
( F f ) {
103
return
list::filter( list< P >(), Propertify< P, F >( f ) );
104
}
105
106
Source
()
107
{
108
}
109
};
110
111
}
112
}
113
114
#endif
Generated on Tue Apr 7 2020 14:42:12 for libept by
1.8.1.2