2011-09-17 01:50:11 +02:00
|
|
|
/*
|
|
|
|
|
DIAGNOSTIC-BUFFER-PROVIDER.hpp - helper for testing against the BufferProvider interface
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file diagnostic-buffer-provider.hpp
|
2011-12-08 23:02:19 +01:00
|
|
|
** A facility for writing unit-tests targeting the BufferProvider interface.
|
2011-09-17 01:50:11 +02:00
|
|
|
**
|
|
|
|
|
** @see buffer-provider-protocol-test.cpp
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_ENGINE_DIAGNOSTIC_BUFFR_PROVIDER_H
|
|
|
|
|
#define PROC_ENGINE_DIAGNOSTIC_BUFFR_PROVIDER_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2013-10-20 03:19:36 +02:00
|
|
|
#include "lib/depend.hpp"
|
2011-09-20 00:54:01 +02:00
|
|
|
#include "lib/util.hpp"
|
2011-11-26 00:09:59 +01:00
|
|
|
#include "proc/engine/type-handler.hpp"
|
2011-09-17 01:50:11 +02:00
|
|
|
#include "proc/engine/buffer-provider.hpp"
|
|
|
|
|
|
2011-09-20 00:54:01 +02:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2011-09-17 01:50:11 +02:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 16:10:03 +01:00
|
|
|
namespace proc {
|
2011-09-17 01:50:11 +02:00
|
|
|
namespace engine {
|
|
|
|
|
|
2011-09-20 00:54:01 +02:00
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
2011-09-17 01:50:11 +02:00
|
|
|
|
2011-11-07 00:07:53 +01:00
|
|
|
/**
|
|
|
|
|
* simple BufferProvider implementation
|
|
|
|
|
* with additional allocation tracking
|
|
|
|
|
*/
|
|
|
|
|
class TrackingHeapBlockProvider;
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
/****************************************************************//**
|
2011-09-17 01:50:11 +02:00
|
|
|
* Helper for unit tests: Buffer provider reference implementation.
|
|
|
|
|
*
|
|
|
|
|
* @todo write type comment
|
|
|
|
|
*/
|
|
|
|
|
class DiagnosticBufferProvider
|
2011-09-20 00:54:01 +02:00
|
|
|
: boost::noncopyable
|
2011-09-17 01:50:11 +02:00
|
|
|
{
|
2011-09-19 01:42:37 +02:00
|
|
|
|
2011-11-07 00:07:53 +01:00
|
|
|
boost::scoped_ptr<TrackingHeapBlockProvider> pImpl_;
|
2013-10-20 03:19:36 +02:00
|
|
|
static lib::Depend<DiagnosticBufferProvider> diagnostics;
|
2011-09-19 01:42:37 +02:00
|
|
|
|
2011-09-20 00:54:01 +02:00
|
|
|
|
2011-11-07 00:07:53 +01:00
|
|
|
TrackingHeapBlockProvider& reset();
|
2011-09-20 00:54:01 +02:00
|
|
|
bool isCurrent (BufferProvider const&);
|
2011-09-19 01:42:37 +02:00
|
|
|
|
|
|
|
|
|
2011-10-19 02:47:11 +02:00
|
|
|
DiagnosticBufferProvider();
|
|
|
|
|
~DiagnosticBufferProvider();
|
|
|
|
|
|
2013-10-20 21:51:28 +02:00
|
|
|
friend class lib::DependencyFactory;
|
2011-10-19 02:47:11 +02:00
|
|
|
|
2011-09-17 01:50:11 +02:00
|
|
|
public:
|
|
|
|
|
/** build a new Diagnostic Buffer Provider instance,
|
|
|
|
|
* discard the existing one. Use the static query API
|
|
|
|
|
* for investigating collected data. */
|
2011-09-20 00:54:01 +02:00
|
|
|
static BufferProvider& build();
|
2011-09-17 01:50:11 +02:00
|
|
|
|
2011-09-19 01:42:37 +02:00
|
|
|
|
|
|
|
|
/** access the diagnostic API of the buffer provider
|
|
|
|
|
* @throw error::Invalid if the given provider doesn't allow
|
|
|
|
|
* for diagnostic access or wasn't registered beforehand.
|
|
|
|
|
*/
|
|
|
|
|
static DiagnosticBufferProvider&
|
2011-09-21 02:23:12 +02:00
|
|
|
access (BufferProvider const& );
|
2011-09-19 01:42:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === diagnostic API === */
|
|
|
|
|
|
2011-09-20 00:54:01 +02:00
|
|
|
bool buffer_was_used (uint bufferID) const;
|
2011-10-19 02:47:11 +02:00
|
|
|
bool buffer_was_closed (uint bufferID) const;
|
|
|
|
|
void* accessMemory (uint bufferID) const;
|
|
|
|
|
bool all_buffers_released() const;
|
2011-09-19 01:42:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-17 01:50:11 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 16:10:03 +01:00
|
|
|
}} // namespace proc::engine
|
2011-09-17 01:50:11 +02:00
|
|
|
#endif
|