sidbuilder.h
/*
* This file is part of libsidplayfp, a SID player engine.
*
* Copyright 2011-2019 Leandro Nini <drfiemost@users.sourceforge.net>
* Copyright 2007-2010 Antti Lankila
* Copyright 2000-2001 Simon White
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SIDBUILDER_H
#define SIDBUILDER_H
#include <set>
#include <string>
#include "sidplayfp/SidConfig.h"
namespace libsidplayfp
{
class sidemu;
class EventScheduler;
}
class sidbuilder
{
protected:
typedef std::set<libsidplayfp::sidemu*> emuset_t;
private:
const char * const m_name;
protected:
std::string m_errorBuffer;
emuset_t sidobjs;
bool m_status;
protected:
template<class Temu, typename Tparam>
class applyParameter
{
protected:
Tparam m_param;
void (Temu::*m_method)(Tparam);
public:
applyParameter(void (Temu::*method)(Tparam), Tparam param) :
m_param(param),
m_method(method) {}
void operator() (libsidplayfp::sidemu *e) { (static_cast<Temu*>(e)->*m_method)(m_param); }
};
public:
sidbuilder(const char * const name) :
m_name(name),
m_errorBuffer("N/A"),
m_status(true) {}
virtual ~sidbuilder() {}
unsigned int usedDevices() const { return sidobjs.size(); }
virtual unsigned int availDevices() const = 0;
virtual unsigned int create(unsigned int sids) = 0;
libsidplayfp::sidemu *lock(libsidplayfp::EventScheduler *scheduler, SidConfig::sid_model_t model, bool digiboost);
void unlock(libsidplayfp::sidemu *device);
void remove();
const char *name() const { return m_name; }
const char *error() const { return m_errorBuffer.c_str(); }
bool getStatus() const { return m_status; }
virtual const char *credits() const = 0;
virtual void filter(bool enable) = 0;
};
#endif // SIDBUILDER_H
SidConfig::sid_model_t
sid_model_t
SID chip model.
Definition SidConfig.h:51
libsidplayfp::EventScheduler
Definition EventScheduler.h:62
libsidplayfp::sidemu
Definition sidemu.h:47
sidbuilder::applyParameter
Definition sidbuilder.h:61
sidbuilder
Definition sidbuilder.h:41
sidbuilder::getStatus
bool getStatus() const
Definition sidbuilder.h:143
sidbuilder::create
virtual unsigned int create(unsigned int sids)=0
sidbuilder::error
const char * error() const
Definition sidbuilder.h:136
sidbuilder::unlock
void unlock(libsidplayfp::sidemu *device)
Definition sidbuilder.cpp:51
sidbuilder::usedDevices
unsigned int usedDevices() const
Definition sidbuilder.h:85
sidbuilder::filter
virtual void filter(bool enable)=0
sidbuilder::lock
libsidplayfp::sidemu * lock(libsidplayfp::EventScheduler *scheduler, SidConfig::sid_model_t model, bool digiboost)
Definition sidbuilder.cpp:31
sidbuilder::availDevices
virtual unsigned int availDevices() const =0
sidbuilder::remove
void remove()
Definition sidbuilder.cpp:63
sidbuilder::name
const char * name() const
Definition sidbuilder.h:129
sidbuilder::credits
virtual const char * credits() const =0