Lumiera  0.pre.03
»edit your freedom«
struct.cpp
Go to the documentation of this file.
1 /*
2  Struct(Asset) - key abstraction: structural asset
3 
4  Copyright (C) Lumiera.org
5  2008, 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 "steam/asset/struct.hpp"
41 #include "steam/assetmanager.hpp"
43 
45 
46 #include "lib/util.hpp"
47 #include "lib/symbol.hpp"
48 #include "lib/query-util.hpp"
49 #include "lib/format-string.hpp"
50 #include "include/logging.h"
51 #include "common/query.hpp"
52 
53 using util::_Fmt;
54 using lib::Symbol;
58 
59 using util::contains;
60 
61 
62 namespace steam {
63 namespace asset {
64 
65  /****** NOTE: not fully implemented yet. What follows is partially a hack to build simple tests *******/
66 
67 
68 
69 
70 
72  StructFactory Struct::retrieve;
73 
74 
77  : impl_(new StructFactoryImpl(*this))
78  { }
79 
80 
92  template<class STRU>
95  {
96  Query<STRU> desired_name (isnil(nameID)? "" : "id("+nameID+")");
97  STRU* pS = impl_->fabricate (desired_name);
98  return AssetManager::instance().wrap (*pS);
99  }
100 
101 
102 
119  template<class STRU>
122  {
123  lib::P<STRU> res;
125  typeHandler.resolve (res, capabilities);
126 
127  if (res)
128  return res;
129 
130  // create new one, since the
131  // ConfigQuery didn't yield any result
132  STRU* pS = impl_->fabricate(capabilities);
133  return AssetManager::instance().wrap (*pS);
134  }
135 
136 
138 
147  template<class STRU>
150  {
151  STRU* pS = impl_->fabricate(query);
152  return AssetManager::instance().wrap (*pS);
153  }
155 
156 
166  lib::P<Pipe>
167  StructFactory::newPipe (string pipeID, string streamID)
168  {
169  normaliseID (pipeID);
170  normaliseID (streamID);
171  _Fmt descriptor("pipe(%s), stream(%s).");
172  Pipe* pP = impl_->fabricate (Query<Pipe> (descriptor % pipeID % streamID));
173  return AssetManager::instance().wrap (*pP);
174  }
175 
176 
177 
178 }} // namespace asset
179 
180 
181 
182 
183  /**************************************************/
184  /* explicit instantiations of the factory methods */
185  /**************************************************/
186 
187 #include "steam/asset/pipe.hpp"
188 #include "steam/asset/procpatt.hpp"
189 #include "steam/asset/timeline.hpp"
190 #include "steam/asset/sequence.hpp"
191 
192 
193 namespace steam {
194 namespace asset {
195  using PPipe = lib::P<Pipe>;
196 
201 
206 
207  template PPipe StructFactory::made4fake (Query<Pipe> const&);
211 
212 }} // namespace asset
Utilities to support working with predicate queries.
Steam-Layer Interface: Asset Lookup and Organisation.
Definition of a structural asset to express patterns of wiring or processing Processing patterns can ...
A "processing pipe" represented as Asset.
Basic and generic representation of an internal query.
the "front side" interface: the Steam-Layer code can use this QueryHandler to retrieve instances of t...
void normaliseID(string &id)
ensure standard format for a given id string.
Definition: query-util.cpp:61
Front-end for printf-style string template interpolation.
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.
This header is for including and configuring NoBug.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Definition of the concrete frontend for rule based configuration within the session.
structural asset corresponding to the part of the model forming a processing pipe for generating medi...
Definition: pipe.hpp:79
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
lib::P< STRU > newInstance(Symbol nameID="")
invoke the factory to create new Structural Asset.
Definition: struct.cpp:94
Implementation details, especially concerning how configuration queries are resolved and when to crea...
static StructFactory retrieve
storage for the static StructFactory instance
Definition: struct.hpp:116
lib::P< STRU > operator()(Query< STRU > const &query)
Retrieve a suitable Structural Asset instance, possibly create one.
Definition: struct.cpp:121
Structural building block of the session: a sequence of clips.
Token or Atom with distinct identity.
Definition: symbol.hpp:126
static lib::Depend< ConfigResolver > instance
Singleton factory instance, configured with the actual implementation type.
StructFactory()
using private implementation detail class
Definition: struct.cpp:76
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...
Private implementation details of creating various structural assets.
lib::P< Pipe > newPipe(string pipeID, string streamID)
Factory method for creating Pipes explicitly.
Definition: struct.cpp:167
lib::P< STRU > made4fake(Query< STRU > const &query)
special backdoor for fake-configrules.hpp This allows to simulate creation of objects triggered by ru...
Definition: struct.cpp:149
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:80
user-visible Interface to the ConfigRules subsystem.
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44
Asset representation of structural elements within the model.
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition: query.hpp:279
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:255
Top level structural element within the session.