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) Lumiera.org
5  2012, 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 
48 #include "lib/error.hpp"
49 #include "lib/format-string.hpp"
50 
51 namespace error = lumiera::error;
52 
53 
54 
55 /* =========== Advice System integrations ================== */
56 
57 #include "lib/time/timequant.hpp"
58 #include "lib/time/quantiser.hpp"
59 #include "lib/time/mutation.hpp"
60 #include "common/advice.hpp"
61 
62 
63 namespace lib {
64 namespace time {
65 
66  namespace { // implementation helper to access the Advice system...
67 
68  using util::_Fmt;
69 
70  namespace advice = lumiera::advice;
71 
72 
73  PQuant
74  retrieveQuantiser (Symbol gridID)
75  {
76  advice::Request<PQuant> query(gridID);
77  PQuant grid_found = query.getAdvice();
78  if (!grid_found)
79  throw error::Logic (_Fmt("unable to resolve the time quantisation grid with ID=\"%s\" -- was it already defined?")
80  % gridID
81  , LUMIERA_ERROR_UNKNOWN_GRID);
82  return grid_found;
83  }
84  }//(End) implementation helpers
85 
86 
95  : Time(raw)
96  , quantiser_(retrieveQuantiser (gridID))
97  { }
98 
99 
104  PQuant
106  {
107  return retrieveQuantiser (gridID);
108  }
109 
110 
118  Mutation::nudge (int adjustment, Symbol gridID)
119  {
120  return nudge (adjustment, Quantiser::retrieve(gridID));
121  }
122 
123 
124 
125 }} // namespace lib::time
Access point for the advised entity (client).
Definition: advice.hpp:437
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:308
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Token or Atom with distinct identity.
Definition: symbol.hpp:126
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:345
basic constant internal time value.
Definition: timevalue.hpp:142