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)
5  2011, 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 
23 #include "lib/error.hpp"
24 #include "lib/meta/function.hpp"
25 
28 
29 
30 namespace steam {
31 namespace engine {
32 
33 
36 
37 
38 
39 
40  DiagnosticBufferProvider::DiagnosticBufferProvider()
41  : pImpl_()
42  { }
43 
44  DiagnosticBufferProvider::~DiagnosticBufferProvider() { }
45 
46 
47  BufferProvider&
48  DiagnosticBufferProvider::build()
49  {
50  return diagnostics().reset();
51  }
52 
53 
55  DiagnosticBufferProvider::access (BufferProvider const& provider)
56  {
57  if (!diagnostics().isCurrent (provider))
58  throw error::Invalid("given Provider doesn't match (current) diagnostic data record."
59  "This might be an lifecycle error. Did you build() this instance beforehand?");
60 
61  return diagnostics();
62  }
63 
64 
65 
66 
68  DiagnosticBufferProvider::reset()
69  {
70  pImpl_.reset(new TrackingHeapBlockProvider());
71  return *pImpl_;
72  }
73 
74  bool
75  DiagnosticBufferProvider::isCurrent (BufferProvider const& implInstance)
76  {
77  return &implInstance == pImpl_.get();
78  }
79 
80 
81 
82 
83 
84  /* === diagnostic API === */
85 
86  bool
87  DiagnosticBufferProvider::buffer_was_used (uint bufferID) const
88  {
89  return pImpl_->access_emitted(bufferID).was_used();
90  }
91 
92 
93  bool
94  DiagnosticBufferProvider::buffer_was_closed (uint bufferID) const
95  {
96  return pImpl_->access_emitted(bufferID).was_closed();
97  }
98 
99 
100  void*
101  DiagnosticBufferProvider::accessMemory (uint bufferID) const
102  {
103  return pImpl_->access_emitted(bufferID).accessMemory();
104  }
105 
106 
107 }} // 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:280
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
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.