Lumiera  0.pre.03
»edit your freedom«
element-query.hpp
Go to the documentation of this file.
1 /*
2  ELEMENT-QUERY.hpp - session sub-interface to query and retrieve elements
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 
23 #ifndef STEAM_MOBJECT_SESSION_ELEMENT_QUERY_H
24 #define STEAM_MOBJECT_SESSION_ELEMENT_QUERY_H
25 
26 
31 #include "lib/nocopy.hpp"
32 
33 #include <functional>
34 
35 
36 
37 namespace steam {
38 namespace mobject {
39 namespace session {
40 
41 
42  using std::function;
43 
44 
45  namespace { // type matching helper
47  template<class PRED>
48  struct _PickRes;
49 
50  template<class MO>
51  struct _PickRes<function<bool(Placement<MO> const&)> >
52  {
53  typedef MO Type;
54  typedef MORef<MO> Result;
55  typedef typename ScopeQuery<MO>::iterator Iterator;
56  };
57 
58  template<class MO>
59  struct _PickRes<bool(&)(Placement<MO> const&)>
60  {
61  typedef MO Type;
62  typedef MORef<MO> Result;
63  typedef typename ScopeQuery<MO>::iterator Iterator;
64  };
65 
66  template<class MO>
67  struct _PickRes<bool(*)(Placement<MO> const&)>
68  {
69  typedef MO Type;
70  typedef MORef<MO> Result;
71  typedef typename ScopeQuery<MO>::iterator Iterator;
72  };
73  }
74 
75 
76 
77 
95  {
96 
97  public:
98 
108  template<typename PRED>
109  typename _PickRes<PRED>::Result
110  pick (PRED const& searchPredicate)
111  {
112  typedef typename _PickRes<PRED>::Result ResultRef;
113  typedef typename _PickRes<PRED>::Iterator Iterator;
114 
116  , searchPredicate
118  ));
119  ResultRef found;
120  if (iter) // in case there is an result
121  found.activate(*iter); // pick the first element found...
122  return found; // or return an empty MObjectRef else
123  }
124 
125  };
126 
127 
128 
129 }}} // namespace steam::mobject::session
130 #endif
_PickRes< PRED >::Result pick(PRED const &searchPredicate)
pick the first element from session satisfying a predicate.
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
Definition: trait.hpp:82
Implementation level session API: query a scope.
Result(VAL &&) -> Result< VAL >
deduction guide: allow perfect forwarding of a any result into the ctor call.
An active (smart-ptr like) external reference to a specifically placed MObject "instance" within the ...
Definition: mobject-ref.hpp:85
static lumiera::QueryResolver const & getResolver()
Core abstraction: placement of a media object into session context.
_PickResult< FUNC >::FilterQuery pickAllSuitable(PlacementMO const &scope, FUNC predicate)
convenience shortcut to issue a SpecificContentsQuery, figuring out the actual return/filter type aut...
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Steam-Layer implementation namespace root.
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:65
Implementation facility to query and retrieve session context with filtering conditions.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
External MObject/Placement reference.
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...
Access point to session global search and query functions.