libsidplayfp 1.8.8
sidbuilder.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2013 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
31class sidemu;
32class EventContext;
33
38{
39protected:
40 typedef std::set<sidemu*> emuset_t;
41
42private:
43 const char * const m_name;
44
45protected:
46 std::string m_errorBuffer;
47
48 emuset_t sidobjs;
49
50 bool m_status;
51
52protected:
56 template<class Temu, typename Tparam>
58 {
59 protected:
60 Tparam m_param;
61 void (Temu::*m_method)(Tparam);
62
63 public:
64 applyParameter(void (Temu::*method)(Tparam), Tparam param) :
65 m_param(param),
66 m_method(method) {}
67 void operator() (sidemu *e) { (static_cast<Temu*>(e)->*m_method)(m_param); }
68 };
69
70public:
71 sidbuilder(const char * const name) :
72 m_name(name),
73 m_errorBuffer("N/A"),
74 m_status (true) {}
75 virtual ~sidbuilder() {}
76
82 unsigned int usedDevices() const { return sidobjs.size (); }
83
89 virtual unsigned int availDevices() const = 0;
90
96 virtual unsigned int create(unsigned int sids) = 0;
97
105 sidemu *lock(EventContext *env, SidConfig::sid_model_t model);
106
112 void unlock(sidemu *device);
113
115 void remove();
116
122 const char *name() const { return m_name; }
123
129 const char *error() const { return m_errorBuffer.c_str(); }
130
136 bool getStatus() const { return m_status; }
137
143 virtual const char *credits() const = 0;
144
150 virtual void filter(bool enable) = 0;
151};
152
153#endif // SIDBUILDER_H
Definition: event.h:108
Definition: sidbuilder.h:58
Definition: sidbuilder.h:38
bool getStatus() const
Definition: sidbuilder.h:136
virtual unsigned int create(unsigned int sids)=0
const char * error() const
Definition: sidbuilder.h:129
unsigned int usedDevices() const
Definition: sidbuilder.h:82
virtual void filter(bool enable)=0
virtual unsigned int availDevices() const =0
void remove()
Definition: sidbuilder.cpp:56
const char * name() const
Definition: sidbuilder.h:122
sidemu * lock(EventContext *env, SidConfig::sid_model_t model)
Definition: sidbuilder.cpp:27
virtual const char * credits() const =0
void unlock(sidemu *device)
Definition: sidbuilder.cpp:47
Definition: sidemu.h:40