libsidplayfp 2.7.1
sidbuilder.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2019 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2000-2001 Simon White
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef SIDBUILDER_H
24#define SIDBUILDER_H
25
26#include <set>
27#include <string>
28
29#include "sidplayfp/SidConfig.h"
30
31namespace libsidplayfp
32{
33class sidemu;
34class EventScheduler;
35}
36
41{
42protected:
43 typedef std::set<libsidplayfp::sidemu*> emuset_t;
44
45private:
46 const char * const m_name;
47
48protected:
49 std::string m_errorBuffer;
50
51 emuset_t sidobjs;
52
53 bool m_status;
54
55protected:
59 template<class Temu, typename Tparam>
61 {
62 protected:
63 Tparam m_param;
64 void (Temu::*m_method)(Tparam);
65
66 public:
67 applyParameter(void (Temu::*method)(Tparam), Tparam param) :
68 m_param(param),
69 m_method(method) {}
70 void operator() (libsidplayfp::sidemu *e) { (static_cast<Temu*>(e)->*m_method)(m_param); }
71 };
72
73public:
74 sidbuilder(const char * const name) :
75 m_name(name),
76 m_errorBuffer("N/A"),
77 m_status(true) {}
78 virtual ~sidbuilder() {}
79
85 unsigned int usedDevices() const { return sidobjs.size(); }
86
92 virtual unsigned int availDevices() const = 0;
93
100 virtual unsigned int create(unsigned int sids) = 0;
101
111
117 void unlock(libsidplayfp::sidemu *device);
118
122 void remove();
123
129 const char *name() const { return m_name; }
130
136 const char *error() const { return m_errorBuffer.c_str(); }
137
143 bool getStatus() const { return m_status; }
144
150 virtual const char *credits() const = 0;
151
157 virtual void filter(bool enable) = 0;
158};
159
160#endif // SIDBUILDER_H
sid_model_t
SID chip model.
Definition SidConfig.h:51
Definition EventScheduler.h:62
Definition sidemu.h:47
Definition sidbuilder.h:61
Definition sidbuilder.h:41
bool getStatus() const
Definition sidbuilder.h:143
virtual unsigned int create(unsigned int sids)=0
const char * error() const
Definition sidbuilder.h:136
void unlock(libsidplayfp::sidemu *device)
Definition sidbuilder.cpp:51
unsigned int usedDevices() const
Definition sidbuilder.h:85
virtual void filter(bool enable)=0
libsidplayfp::sidemu * lock(libsidplayfp::EventScheduler *scheduler, SidConfig::sid_model_t model, bool digiboost)
Definition sidbuilder.cpp:31
virtual unsigned int availDevices() const =0
void remove()
Definition sidbuilder.cpp:63
const char * name() const
Definition sidbuilder.h:129
virtual const char * credits() const =0