Lumiera  0.pre.03
»edityourfreedom«
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) Lumiera.org
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
32 #ifndef PROC_MOBJECT_SESSION_ELEMENT_QUERY_H
33 #define PROC_MOBJECT_SESSION_ELEMENT_QUERY_H
34 
35 
40 #include "lib/nocopy.hpp"
41 
42 #include <functional>
43 
44 
45 
46 namespace proc {
47 namespace mobject {
48 namespace session {
49 
50 
51  using std::function;
52 
53 
54  namespace { // type matching helper
56  template<class PRED>
57  struct _PickRes;
58 
59  template<class MO>
60  struct _PickRes<function<bool(Placement<MO> const&)> >
61  {
62  typedef MO Type;
63  typedef MORef<MO> Result;
64  typedef typename ScopeQuery<MO>::iterator Iterator;
65  };
66 
67  template<class MO>
68  struct _PickRes<bool(&)(Placement<MO> const&)>
69  {
70  typedef MO Type;
71  typedef MORef<MO> Result;
72  typedef typename ScopeQuery<MO>::iterator Iterator;
73  };
74 
75  template<class MO>
76  struct _PickRes<bool(*)(Placement<MO> const&)>
77  {
78  typedef MO Type;
79  typedef MORef<MO> Result;
80  typedef typename ScopeQuery<MO>::iterator Iterator;
81  };
82  }
83 
84 
85 
86 
104  {
105 
106  public:
107 
117  template<typename PRED>
118  typename _PickRes<PRED>::Result
119  pick (PRED const& searchPredicate)
120  {
121  typedef typename _PickRes<PRED>::Result ResultRef;
122  typedef typename _PickRes<PRED>::Iterator Iterator;
123 
125  , searchPredicate
127  ));
128  ResultRef found;
129  if (iter) // in case there is an result
130  found.activate(*iter); // pick the first element found...
131  return found; // or return an empty MObjectRef else
132  }
133 
134  };
135 
136 
137 
138 }}} // namespace proc::mobject::session
139 #endif
Implementation level session API: query a scope.
_PickRes< PRED >::Result pick(PRED const &searchPredicate)
pick the first element from session satisfying a predicate.
_PickResult< FUNC >::FilterQuery pickAllSuitable(PlacementMO const &scope, FUNC predicate)
convenience shortcut to issue a SpecificContentsQuery, figuring out the actual return/filter type aut...
Access point to session global search and query functions.
Core abstraction: placement of a media object into session context.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
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.
static lumiera::QueryResolver const & getResolver()
Namespace of Session and user visible high-level objects.
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63