Lumiera  0.pre.03
»edit your freedom«
common-services.cpp
Go to the documentation of this file.
1 /*
2  CommonServices - integrate some library facilities with common system services
3 
4  Copyright (C)
5  2012, 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 
39 #include "lib/error.hpp"
40 #include "lib/format-string.hpp"
41 
42 namespace error = lumiera::error;
43 
44 
45 
46 /* =========== Advice System integrations ================== */
47 
48 #include "lib/time/timequant.hpp"
49 #include "lib/time/quantiser.hpp"
50 #include "lib/time/mutation.hpp"
51 #include "common/advice.hpp"
52 
53 
54 namespace lib {
55 namespace time {
56 
57  namespace { // implementation helper to access the Advice system...
58 
59  using util::_Fmt;
60 
61  namespace advice = lumiera::advice;
62 
63 
64  PQuant
65  retrieveQuantiser (Symbol gridID)
66  {
67  advice::Request<PQuant> query(gridID);
68  PQuant grid_found = query.getAdvice();
69  if (!grid_found)
70  throw error::Logic (_Fmt("unable to resolve the time quantisation grid with ID=\"%s\" -- was it already defined?")
71  % gridID
72  , LUMIERA_ERROR_UNKNOWN_GRID);
73  return grid_found;
74  }
75  }//(End) implementation helpers
76 
77 
86  : Time(raw)
87  , quantiser_(retrieveQuantiser (gridID))
88  { }
89 
90 
95  PQuant
97  {
98  return retrieveQuantiser (gridID);
99  }
100 
101 
109  Mutation::nudge (int adjustment, Symbol gridID)
110  {
111  return nudge (adjustment, Quantiser::retrieve(gridID));
112  }
113 
114 
115 
116 }} // namespace lib::time
Access point for the advised entity (client).
Definition: advice.hpp:428
Modifying time and timecode values.
static PQuant retrieve(Symbol gridID)
Access an existing grid definition or quantiser, known by the given symbolic ID.
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
QuTime(TimeValue raw, Symbol gridID)
build a quantised time value, referring the time grid by-name.
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Expecting Advice and giving Advice: a cross-cutting collaboration of loosely coupled participants...
Template to build polymorphic value objects.
Lumiera error handling (C++ interface).
Support library to represent grid-aligned time specifications This is part of Lumiera&#39;s time and time...
Library functions to support the formation of grid-aligned time values.
static EncapsulatedMutation nudge(int adjustment)
build a time mutation to nudge the target time value by an offset, defined as number of steps on an i...
Definition: mutation.cpp:336
basic constant internal time value.
Definition: timevalue.hpp:133