Lumiera  0.pre.03
»edit your freedom«
output-designation.cpp
Go to the documentation of this file.
1 /*
2  OutputDesignation - specifying a desired output destination
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 
31 #include "lib/error.hpp"
32 #include "lib/symbol.hpp"
33 #include "lib/query-util.hpp"
40 #include "lib/util.hpp"
41 
42 #include <boost/functional/hash.hpp>
43 #include <cstdlib>
44 
45 using lumiera::Symbol;
50 using lib::HashVal;
51 using util::uNum;
52 
53 namespace steam {
54 namespace mobject {
55 
56  typedef OutputDesignation::PPipe PPipe;
57  typedef OutputDesignation::PID PID;
58  typedef OutputDesignation::TargetSpec TargetSpec;
59 
60 
61  struct AbsoluteSpec
62  : TargetSpec
63  {
64  PID target_;
65 
66  AbsoluteSpec (PID explicitTarget)
67  : target_(explicitTarget)
68  { }
69 
70  PID resolve (PPipe) { return target_; }
71  };
72 
73  struct IndirectSpec
74  : TargetSpec
75  {
76  RefPlacement mediator_;
77 
78  IndirectSpec (RefPlacement const& indirectTarget)
79  : mediator_(indirectTarget)
80  { }
81 
82  PID
83  resolve (PPipe)
84  {
85  REQUIRE (mediator_);
86  UNIMPLEMENTED ("how to query a placement for output designation");
87  }
88  };
89 
90  struct RelativeSpec
91  : TargetSpec
92  {
93  uint busNr_;
94 
95  RelativeSpec (uint relative_busNr)
96  : busNr_(relative_busNr)
97  { }
98 
99  PID
100  resolve (PPipe)
101  {
102  UNIMPLEMENTED ("how the hell can we get a grip on the target to resolve the bus??");
103  }
104  };
105 
106 
107 
108 
109  OutputDesignation::TargetSpec::~TargetSpec() { }
110 
111 
116  : spec_(AbsoluteSpec (explicitTarget))
117  { }
118 
119 
125  : spec_(IndirectSpec (indirectTarget))
126  { }
127 
128 
139  : spec_(RelativeSpec (relative_busNr))
140  { }
141 
142 
143 
144 
145 
146 
147  namespace _mapping {
148 
152  HashVal
153  slot (Query<asset::Pipe> const& query)
154  {
155  return hash_value (query);
156  }
157 
163  HashVal
164  resolveQuery (Query<asset::Pipe> const& query4pipe)
165  {
166  PPipe res;
168  typeHandler.resolve (res, query4pipe);
169  HashVal resulting_targetPipeID (res? (HashVal)res->getID() : 0 );
170  return resulting_targetPipeID;
171  }
172 
173  Symbol SEQNR_PREDICATE = "ord";
174 
175  uint
177  {
178  string seqNr = query4pipe.extractID (SEQNR_PREDICATE);
179  return uNum (seqNr); // defaults to 0 in case of an invalid number
180  }
181 
184  {
185  return query4pipe.rebuild()
186  .removeTerm (SEQNR_PREDICATE);
187  }
188  }
189 
190 
191 
192 }} // namespace mobject
SpecBuff spec_
Storage to hold the Target Spec inline.
Utilities to support working with predicate queries.
HashVal resolveQuery(Query< asset::Pipe > const &query4pipe)
delegate target pipe resolution to the rules system
HashVal slot(Query< asset::Pipe > const &query)
yield a suitable table slot for this query
the "front side" interface: the Steam-Layer code can use this QueryHandler to retrieve instances of t...
framework and to resolve logical queries.
virtual bool resolve(P< TY > &solution, Query< TY > const &q)=0
try to find or create an object of type TY fulfilling the given query.
Core abstraction of the Session model: a media object.
Steam-Layer implementation namespace root.
Definition of the concrete frontend for rule based configuration within the session.
string extractID(Symbol sym, const string &termString)
(preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expressio...
Definition: query-util.cpp:92
Token or Atom with distinct identity.
Definition: symbol.hpp:117
static lib::Depend< ConfigResolver > instance
Singleton factory instance, configured with the actual implementation type.
uint is_defaults_query_with_channel(Query< asset::Pipe > const &query4pipe)
detect the special case, when actually the Nth solution of a defaults query is requested ...
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
string removeTerm(Symbol sym, string &queryString)
(preliminary) helper: cut a term with the given symbol.
Definition: query-util.cpp:109
Translating and wiring output designations.
A generic reference mechanism for Placements, as added to the current session.
Lumiera error handling (C++ interface).
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
Core abstraction: symbolic representation of some output target.
OutputDesignation(PID explicitTarget)
create an output designation by directly specifying the target to connect
user-visible Interface to the ConfigRules subsystem.
Query< asset::Pipe > build_corresponding_sourceQuery(Query< asset::Pipe > const &query4pipe)
..and build the corresponding defaults source query for this case
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition: query.hpp:270
string extractID(Symbol predicate) const
convenience shortcut to extract a desired name-ID.
Definition: query.hpp:586