Lumiera  0.pre.03
»edit your freedom«
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 steam {
40 namespace engine {
41 
42 
45 
46 
47 
48 
49  DiagnosticBufferProvider::DiagnosticBufferProvider()
50  : pImpl_()
51  { }
52 
53  DiagnosticBufferProvider::~DiagnosticBufferProvider() { }
54 
55 
56  BufferProvider&
57  DiagnosticBufferProvider::build()
58  {
59  return diagnostics().reset();
60  }
61 
62 
64  DiagnosticBufferProvider::access (BufferProvider const& provider)
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 
77  DiagnosticBufferProvider::reset()
78  {
79  pImpl_.reset(new TrackingHeapBlockProvider());
80  return *pImpl_;
81  }
82 
83  bool
84  DiagnosticBufferProvider::isCurrent (BufferProvider const& implInstance)
85  {
86  return &implInstance == pImpl_.get();
87  }
88 
89 
90 
91 
92 
93  /* === diagnostic API === */
94 
95  bool
96  DiagnosticBufferProvider::buffer_was_used (uint bufferID) const
97  {
98  return pImpl_->access_emitted(bufferID).was_used();
99  }
100 
101 
102  bool
103  DiagnosticBufferProvider::buffer_was_closed (uint bufferID) const
104  {
105  return pImpl_->access_emitted(bufferID).was_closed();
106  }
107 
108 
109  void*
110  DiagnosticBufferProvider::accessMemory (uint bufferID) const
111  {
112  return pImpl_->access_emitted(bufferID).accessMemory();
113  }
114 
115 
116 }} // namespace engine
Helper for unit tests: Buffer provider reference implementation.
static lib::Depend< DiagnosticBufferProvider > diagnostics
Storage for the diagnostics frontend.
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Metaprogramming tools for transforming functor types.
Dummy implementation of the BufferProvider interface to support writing unit tests.
simple BufferProvider implementation with additional allocation tracking.
Lumiera error handling (C++ interface).
A facility for writing unit-tests targeting the BufferProvider interface.
Interface: a facility providing and managing working buffers for media calculations.