Lumiera  0.pre.03
»edit your freedom«
scope-query.hpp
Go to the documentation of this file.
1 /*
2  SCOPE-QUERY.hpp - query to discover the contents of a container-like part of the model
3 
4  Copyright (C)
5  2009, 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 
32 #ifndef STEAM_MOBJECT_SESSION_SCOPE_QUERY_H
33 #define STEAM_MOBJECT_SESSION_SCOPE_QUERY_H
34 
35 
38 #include "lib/format-string.hpp"
39 
40 #include <functional>
41 
42 
43 namespace steam {
44 namespace mobject {
45 namespace session {
46 
47  using std::bind;
48  using std::function;
49  using std::placeholders::_1;
50 
51  using lumiera::Goal;
52  using lumiera::Query;
53 
54 
55 
64  template<class MO>
66  : public Query<Placement<MO>>
67  {
68  typedef Query<Placement<MO>> _Query;
69 
70 
71  public:
72  typedef typename _Query::iterator iterator;
73 
74  typedef function<bool(PlacementMO const&)> ContentFilter;
75 
76 
77  ContentFilter
78  contentFilter () const
79  {
80  return buildContentFilter();
81  }
82 
83  protected:
85  virtual ContentFilter buildContentFilter() const =0;
86 
87 
88 
89 
91  : _Query (_Query::defineQueryTypeID (Goal::DISCOVERY)
92  , lib::QueryText("")) // syntactic representation supplied on demand
93  { }
94 
95  private:
98  };
99 
100 
102  { CONTENTS = 0
105  , PATH
106  };
107 
108 
134  template<class MO>
136  : public DiscoveryQuery<MO>
137  {
138  typedef DiscoveryQuery<MO> _Parent;
139  typedef Query<Placement<MO>> _Query;
140 
141 
142  PlacementMO::ID startPoint_;
143  ScopeQueryKind to_discover_;
144 
145  public:
146  typedef typename _Parent::iterator iterator;
147  typedef typename _Parent::ContentFilter ContentFilter;
148 
149 
150  ScopeQuery (PlacementMO const& scope,
151  ScopeQueryKind direction)
152  : startPoint_(scope)
153  , to_discover_(direction)
154  { }
155 
156 
157 
158  PlacementMO::ID const&
159  searchScope () const
160  {
161  return startPoint_;
162  }
163 
165  searchDirection () const
166  {
167  return to_discover_;
168  }
169 
170 
171 
172  private:
179  ContentFilter
181  {
182  return bind (&PlacementMO::isCompatible<MO>, _1 );
183  }
184 
193  {
194  using util::_Fmt;
195  TODO ("valid syntactic representation of scope queries");
196  return lib::QueryText (_Fmt ("scope(X, %08X), scopeRelation(X, %d)")
197  % hash_value(searchScope())
198  % uint(searchDirection()));
199  }
200  };
201 
202 
203  template<class MO>
205  : ScopeQuery<MO>
206  {
207  ContentsQuery (PlacementMO const& scope)
208  : ScopeQuery<MO> (scope, CONTENTS)
209  { }
210 
211  };
212 
213 
214  template<class MO>
215  struct PathQuery
216  : ScopeQuery<MO>
217  {
218  PathQuery (PlacementMO const& scope)
219  : ScopeQuery<MO> (scope, PARENTS)
220  { }
221 
222  };
223 
224 
225 
226 
227 }}} // namespace steam::mobject::session
228 #endif
Query ABC: unspecific goal for resolution or retrieval.
Definition: query.hpp:116
Query a scope to discover it&#39;s contents or location.
framework and to resolve logical queries.
Core abstraction: placement of a media object into session context.
Front-end for printf-style string template interpolation.
ContentFilter buildContentFilter() const
the default implementation of the content filtering builds on the downcast-function available on each...
discover any contained objects depth-first
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:65
discover the path to root
discover the enclosing scopes
virtual ContentFilter buildContentFilter() const =0
yield additional filter to be applied to the result set.
lib::QueryText buildSyntacticRepresentation() const
supplement a syntactic representation (as generic query in predicate form).
discover the immediate children
DiscoveryQuery const & operator=(DiscoveryQuery const &)
Assignment explicitly disallowed (but copy ctor is ok)
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition: query.hpp:270
ABC to build Queries for placement-attached objects.
Definition: scope-query.hpp:65
Syntactical query representation.
Definition: query-text.hpp:61