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) 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 
40 #include "lib/error.hpp"
41 #include "lib/symbol.hpp"
42 #include "lib/query-util.hpp"
49 #include "lib/util.hpp"
50 
51 #include <boost/functional/hash.hpp>
52 #include <cstdlib>
53 
54 using lumiera::Symbol;
59 using lib::HashVal;
60 using util::uNum;
61 
62 namespace steam {
63 namespace mobject {
64 
65  typedef OutputDesignation::PPipe PPipe;
66  typedef OutputDesignation::PID PID;
67  typedef OutputDesignation::TargetSpec TargetSpec;
68 
69 
70  struct AbsoluteSpec
71  : TargetSpec
72  {
73  PID target_;
74 
75  AbsoluteSpec (PID explicitTarget)
76  : target_(explicitTarget)
77  { }
78 
79  PID resolve (PPipe) { return target_; }
80  };
81 
82  struct IndirectSpec
83  : TargetSpec
84  {
85  RefPlacement mediator_;
86 
87  IndirectSpec (RefPlacement const& indirectTarget)
88  : mediator_(indirectTarget)
89  { }
90 
91  PID
92  resolve (PPipe)
93  {
94  REQUIRE (mediator_);
95  UNIMPLEMENTED ("how to query a placement for output designation");
96  }
97  };
98 
99  struct RelativeSpec
100  : TargetSpec
101  {
102  uint busNr_;
103 
104  RelativeSpec (uint relative_busNr)
105  : busNr_(relative_busNr)
106  { }
107 
108  PID
109  resolve (PPipe)
110  {
111  UNIMPLEMENTED ("how the hell can we get a grip on the target to resolve the bus??");
112  }
113  };
114 
115 
116 
117 
118  OutputDesignation::TargetSpec::~TargetSpec() { }
119 
120 
125  : spec_(AbsoluteSpec (explicitTarget))
126  { }
127 
128 
134  : spec_(IndirectSpec (indirectTarget))
135  { }
136 
137 
148  : spec_(RelativeSpec (relative_busNr))
149  { }
150 
151 
152 
153 
154 
155 
156  namespace _mapping {
157 
161  HashVal
162  slot (Query<asset::Pipe> const& query)
163  {
164  return hash_value (query);
165  }
166 
172  HashVal
173  resolveQuery (Query<asset::Pipe> const& query4pipe)
174  {
175  PPipe res;
177  typeHandler.resolve (res, query4pipe);
178  HashVal resulting_targetPipeID (res? (HashVal)res->getID() : 0 );
179  return resulting_targetPipeID;
180  }
181 
182  Symbol SEQNR_PREDICATE = "ord";
183 
184  uint
186  {
187  string seqNr = query4pipe.extractID (SEQNR_PREDICATE);
188  return uNum (seqNr); // defaults to 0 in case of an invalid number
189  }
190 
193  {
194  return query4pipe.rebuild()
195  .removeTerm (SEQNR_PREDICATE);
196  }
197  }
198 
199 
200 
201 }} // 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:101
Token or Atom with distinct identity.
Definition: symbol.hpp:126
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:118
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:56
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:279
string extractID(Symbol predicate) const
convenience shortcut to extract a desired name-ID.
Definition: query.hpp:595