Lumiera  0.pre.03
»edityourfreedom«
diagnostic-buffer-provider.cpp
Go to the documentation of this file.
1 /*
2  DiagnosticBufferProvider - helper for testing against the BufferProvider interface
3 
4  Copyright (C) Lumiera.org
5  2011, 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 
32 #include "lib/error.hpp"
33 #include "lib/meta/function.hpp"
34 
37 
38 
39 namespace proc {
40 namespace engine {
41 
42 
45 
46 
47 
48 
50  : pImpl_()
51  { }
52 
54 
55 
58  {
59  return diagnostics().reset();
60  }
61 
62 
65  {
66  if (!diagnostics().isCurrent (provider))
67  throw error::Invalid("given Provider doesn't match (current) diagnostic data record."
68  "This might be an lifecycle error. Did you build() this instance beforehand?");
69 
70  return diagnostics();
71  }
72 
73 
74 
75 
78  {
79  pImpl_.reset(new TrackingHeapBlockProvider());
80  return *pImpl_;
81  }
82 
83  bool
85  {
86  return &implInstance == pImpl_.get();
87  }
88 
89 
90 
91 
92 
93  /* === diagnostic API === */
94 
95  bool
97  {
98  return pImpl_->access_emitted(bufferID).was_used();
99  }
100 
101 
102  bool
104  {
105  return pImpl_->access_emitted(bufferID).was_closed();
106  }
107 
108 
109  void*
111  {
112  return pImpl_->access_emitted(bufferID).accessMemory();
113  }
114 
115 
116 }} // namespace engine
simple BufferProvider implementation with additional allocation tracking.
LumieraError< LERR_(INVALID)> Invalid
Definition: error.hpp:216
Helper for unit tests: Buffer provider reference implementation.
Interface: a facility providing and managing working buffers for media calculations.
std::unique_ptr< TrackingHeapBlockProvider > pImpl_
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
static DiagnosticBufferProvider & access(BufferProvider const &)
access the diagnostic API of the buffer provider
static lib::Depend< DiagnosticBufferProvider > diagnostics
Storage for the diagnostics frontend.
static BufferProvider & build()
build a new Diagnostic Buffer Provider instance, discard the existing one.
Metaprogramming tools for transforming functor types.
Dummy implementation of the BufferProvider interface to support writing unit tests.
Lumiera error handling (C++ interface).
A facility for writing unit-tests targeting the BufferProvider interface.
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63