Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
specific-contents-query.hpp
Go to the documentation of this file.
1/*
2 SPECIFIC-CONTENTS-QUERY.hpp - pick specific contents from the model, using a filter
3
4 Copyright (C)
5 2010, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
25#ifndef MOBJECT_SESSION_SPECIFIC_CONTENTS_QUERY_H
26#define MOBJECT_SESSION_SPECIFIC_CONTENTS_QUERY_H
27
28
32
33#include <functional>
34
35
36namespace steam {
37namespace mobject {
38namespace session {
39
40 using std::function;
41
43
44
53 template<class MO>
55 : public ContentsQuery<MO>
56 {
59 using SpecialPredicate = function<bool(TypedPlacement)>;
60
68 class Filter
69 {
71
72 public:
74 : predicate_(pred)
75 { }
76
77 bool
79 {
80 if (!anyMO.isCompatible<MO>())
81 return false;
82
83 TypedPlacement interestingObject = static_cast<TypedPlacement> (anyMO);
84 return predicate_(interestingObject);
85 }
86 };
87
89
97 {
98 return specialTest_;
99 }
100
101
102
103 public:
105 ,SpecialPredicate const& specialPred)
106 : ContentsQuery<MO> (scope)
107 , specialTest_(specialPred)
108 { }
109 };
110
111
112
113 namespace { // type matching helper
115 template<class PRED>
117
118 template<class MO>
119 struct _PickResult<function<bool(Placement<MO> const&)> >
120 {
121 using Type = MO;
124 };
125
126 template<class MO>
127 struct _PickResult<bool(&)(Placement<MO> const&)>
128 {
129 using Type = MO;
132 };
133
134 template<class MO>
135 struct _PickResult<bool(*)(Placement<MO> const&)>
136 {
137 using Type = MO;
140 };
141 }
142
143
144
145
150 template<typename FUNC>
151 inline _PickResult<FUNC>::FilterQuery
152 pickAllSuitable(PlacementMO const& scope, FUNC predicate)
153 {
154 using Query = _PickResult<FUNC>::FilterQuery;
155
156 return Query(scope, predicate);
157 }
158
164 template<typename FUNC>
165 inline _PickResult<FUNC>::Iterator
166 pickAllSuitable(PlacementMO const& scope, FUNC predicate, QueryResolver const& resolver)
167 {
168 using Query = _PickResult<FUNC>::FilterQuery;
169
170 return Query(scope, predicate ).resolveBy(resolver);
171 }
172
173
174
175}}} // namespace steam::mobject::session
176#endif
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition query.hpp:254
iterator resolveBy(QueryResolver const &resolver) const
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
function< bool(PlacementMO const &)> ContentFilter
Filter functor, built on top of a predicate, which is provided by the client on creation of this Spec...
from the session, based on a filter predicate.
ContentFilter buildContentFilter() const
using a specialised version of the filtering, which doesn't only check the concrete type,...
SpecificContentsQuery(PlacementMO const &scope, SpecialPredicate const &specialPred)
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
_PickResult< FUNC >::FilterQuery pickAllSuitable(PlacementMO const &scope, FUNC predicate)
convenience shortcut to issue a SpecificContentsQuery, figuring out the actual return/filter type aut...
Steam-Layer implementation namespace root.
Core abstraction: placement of a media object into session context.
framework and to resolve logical queries.
Specific queries to explore contents of a scope within the high-level model.