From bc4e506e48785ce448f18098b96c0d7333abb801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gl=C3=B6ckner?= Date: Tue, 29 Mar 2016 15:36:53 +0200 Subject: API Refactoring for class Drumkit --- src/drumgizmo.cc | 10 ++++----- src/drumkit.cc | 65 ++++++++++++++++++++++++++++---------------------------- src/drumkit.h | 45 +++++++++++++++++++-------------------- 3 files changed, 60 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 4ce45ba..0570114 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -101,7 +101,7 @@ bool DrumGizmo::loadkit(std::string file) #ifdef WITH_RESAMPLER for(int i = 0; i < MAX_NUM_CHANNELS; ++i) { - resampler[i].setup(kit.samplerate(), Conf::samplerate); + resampler[i].setup(kit.getSamplerate(), Conf::samplerate); } #endif/*WITH_RESAMPLER*/ @@ -167,7 +167,7 @@ void DrumGizmo::handleMessage(Message *msg) EngineSettingsMessage *msg = new EngineSettingsMessage(); msg->midimapfile = mmapfile; msg->midimap_loaded = mmap_loaded; - msg->drumkitfile = kit.file(); + msg->drumkitfile = kit.getFile(); msg->drumkit_loaded = loader.isDone(); msg->enable_velocity_modifier = Conf::enable_velocity_modifier; msg->velocity_modifier_falloff = Conf::velocity_modifier_falloff; @@ -646,7 +646,7 @@ void DrumGizmo::setSamplerate(int samplerate) #ifdef WITH_RESAMPLER for(int i = 0; i < MAX_NUM_CHANNELS; ++i) { - resampler[i].setup(kit.samplerate(), Conf::samplerate); + resampler[i].setup(kit.getSamplerate(), Conf::samplerate); } if(resampler[0].getRatio() != 1) { @@ -688,7 +688,7 @@ std::string DrumGizmo::configString() return "\n" - " " + kit.file() + "\n" + " " + kit.getFile() + "\n" " " + mmapfile + "\n" " " + bool2str(Conf::enable_velocity_modifier) + "\n" @@ -752,7 +752,7 @@ bool DrumGizmo::setConfigString(std::string cfg) } std::string newkit = p.value("drumkitfile"); - if(newkit != "" && kit.file() != newkit) + if(newkit != "" && kit.getFile() != newkit) { /* if(!loadkit(p.values["drumkitfile"])) diff --git a/src/drumkit.cc b/src/drumkit.cc index d8596c7..1b95c87 100644 --- a/src/drumkit.cc +++ b/src/drumkit.cc @@ -28,63 +28,64 @@ DrumKit::DrumKit() { - magic = this; + magic = this; } DrumKit::~DrumKit() { - magic = NULL; - clear(); + magic = NULL; + clear(); } void DrumKit::clear() { - Instruments::iterator i = instruments.begin(); - while(i != instruments.end()) { - delete *i; - i++; - } - instruments.clear(); - - channels.clear(); - - _name = ""; - _description = ""; - _samplerate = 44100; + Instruments::iterator i = instruments.begin(); + while(i != instruments.end()) + { + delete *i; + i++; + } + instruments.clear(); + + channels.clear(); + + _name = ""; + _description = ""; + _samplerate = 44100; } -bool DrumKit::isValid() +bool DrumKit::isValid() const { - return this == magic; + return this == magic; } -std::string DrumKit::file() +std::string DrumKit::getFile() const { - return _file; + return _file; } -std::string DrumKit::name() +std::string DrumKit::getName() const { - return _name; + return _name; } -std::string DrumKit::description() +std::string DrumKit::getDescription() const { - return _description; + return _description; } -size_t DrumKit::samplerate() +size_t DrumKit::getSamplerate() const { - return _samplerate; + return _samplerate; } #ifdef TEST_DRUMKIT -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: +// Additional dependency files +// deps: +// Required cflags (autoconf vars may be used) +// cflags: +// Required link options (autoconf vars may be used) +// libs: #include "test.h" TEST_BEGIN; @@ -93,4 +94,4 @@ TEST_BEGIN; TEST_END; -#endif/*TEST_DRUMKIT*/ +#endif /*TEST_DRUMKIT*/ diff --git a/src/drumkit.h b/src/drumkit.h index 24fce99..1ceef3e 100644 --- a/src/drumkit.h +++ b/src/drumkit.h @@ -24,8 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_DRUMKIT_H__ -#define __DRUMGIZMO_DRUMKIT_H__ +#pragma once #include #include @@ -35,36 +34,36 @@ #include "versionstr.h" class DrumKitParser; -class DrumKit { - friend class DrumKitParser; +class DrumKit +{ + friend class DrumKitParser; + public: - DrumKit(); - ~DrumKit(); + DrumKit(); + ~DrumKit(); + + std::string getFile() const; - std::string file(); + std::string getName() const; + std::string getDescription() const; - std::string name(); - std::string description(); - - Instruments instruments; - Channels channels; - - void clear(); + Instruments instruments; + Channels channels; - bool isValid(); + void clear(); - size_t samplerate(); + bool isValid() const; + + size_t getSamplerate() const; private: - void *magic{nullptr}; + void* magic{nullptr}; - std::string _file; + std::string _file; - std::string _name; - std::string _description; + std::string _name; + std::string _description; size_t _samplerate{0}; - VersionStr _version; + VersionStr _version; }; - -#endif/*__DRUMGIZMO_DRUMKIT_H__*/ -- cgit v1.2.3