summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-06-23 09:02:37 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-08-12 11:11:49 +0200
commit592f05fa549c7e680e502f569c27e71177361ad6 (patch)
tree31e884348253086cdc8ce9bd1aaee938e4d74374 /src
parentd6ba6aac44a2a30920be6938bb61a6ff234729f8 (diff)
Remove the old instrument and drumkit parser code as well as version 1.0 kit handling (velocity range maps).
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/drumgizmo.cc1
-rw-r--r--src/drumkitparser.cc263
-rw-r--r--src/drumkitparser.h65
-rw-r--r--src/instrument.cc41
-rw-r--r--src/instrument.h3
-rw-r--r--src/instrumentparser.cc274
-rw-r--r--src/instrumentparser.h64
-rw-r--r--src/rangemap.h98
9 files changed, 7 insertions, 806 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 960f17c..14da4d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,11 +30,9 @@ nodist_libdg_la_SOURCES = \
drumgizmo.cc \
drumkit.cc \
drumkitloader.cc \
- drumkitparser.cc \
events.cc \
inputprocessor.cc \
instrument.cc \
- instrumentparser.cc \
latencyfilter.cc \
midimapparser.cc \
midimapper.cc \
@@ -72,12 +70,10 @@ EXTRA_DIST = \
drumgizmo.h \
drumkit.h \
drumkitloader.h \
- drumkitparser.h \
events.h \
inputfilter.h \
inputprocessor.h \
instrument.h \
- instrumentparser.h \
latencyfilter.h \
midimapparser.h \
midimapper.h \
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 5048e35..d389cc2 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -38,7 +38,6 @@
#include <hugin.hpp>
-#include "drumkitparser.h"
#include "audioinputenginemidi.h"
DrumGizmo::DrumGizmo(Settings& settings,
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
deleted file mode 100644
index 7966d06..0000000
--- a/src/drumkitparser.cc
+++ /dev/null
@@ -1,263 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * drumkitparser.cc
- *
- * Tue Jul 22 16:24:59 CEST 2008
- * Copyright 2008 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "drumkitparser.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <hugin.hpp>
-
-#include "cpp11fix.h"
-#include "instrumentparser.h"
-#include "path.h"
-#include "drumgizmo.h"
-
-DrumKitParser::DrumKitParser(Settings& settings, DrumKit& k, Random& rand)
- : kit(k)
- , refs(REFSFILE)
- , settings(settings)
- , rand(rand)
-{
-}
-
-int DrumKitParser::parseFile(const std::string& filename)
-{
- settings.has_bleed_control.store(false);
-
- auto edited_filename(filename);
-
- if(refs.load())
- {
- if((filename.size() > 1) && (filename[0] == '@'))
- {
- edited_filename = refs.getValue(filename.substr(1));
- }
- }
- else
- {
- WARN(drumkitparser, "Error reading refs.conf");
- }
-
- path = getPath(edited_filename);
- auto result = SAXParser::parseFile(edited_filename);
-
- if(result == 0)
- {
- kit._file = edited_filename;
- }
-
- return result;
-}
-
-void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
-{
- if(name == "drumkit")
- {
- if(attr.find("name") != attr.end())
- {
- kit._name = attr.at("name");
- }
-
- if(attr.find("samplerate") != attr.end())
- {
- kit._samplerate = std::stoi(attr.at("samplerate"));
- }
- else
- {
- // If 'samplerate' attribute is missing, assume 44k1Hz
- // TODO: Ask instrument what samplerate is in the audiofiles...
- kit._samplerate = 44100;
- }
-
- if(attr.find("description") != attr.end())
- {
- kit._description = attr.at("description");
- }
-
- if(attr.find("version") != attr.end())
- {
- try
- {
- kit._version = VersionStr(attr.at("version"));
- }
- catch(const char *err)
- {
- ERR(kitparser, "Error parsing version number: %s, using 1.0\n", err);
- kit._version = VersionStr(1,0,0);
- }
- }
- else
- {
- WARN(kitparser, "Missing version number, assuming 1.0\n");
- kit._version = VersionStr(1,0,0);
- }
- }
-
- if(name == "channels")
- {
-
- }
-
- if(name == "channel")
- {
- if(attr.find("name") == attr.end())
- {
- ERR(kitparser, "Missing channel name.\n");
- return;
- }
-
- Channel c(attr.at("name"));
- c.num = kit.channels.size();
- kit.channels.push_back(c);
- }
-
- if(name == "instruments")
- {
-
- }
-
- if(name == "instrument")
- {
- if(attr.find("name") == attr.end())
- {
- ERR(kitparser, "Missing name in instrument tag.\n");
- return;
- }
-
- if(attr.find("file") == attr.end())
- {
- ERR(kitparser, "Missing file in instrument tag.\n");
- return;
- }
-
- instr_name = attr.at("name");
- instr_file = attr.at("file");
- if(attr.find("group") != attr.end())
- {
- instr_group = attr.at("group");
- }
- else
- {
- instr_group = "";
- }
- }
-
- if(name == "channelmap")
- {
- if(attr.find("in") == attr.end())
- {
- ERR(kitparser, "Missing 'in' in channelmap tag.\n");
- return;
- }
-
- if(attr.find("out") == attr.end())
- {
- ERR(kitparser, "Missing 'out' in channelmap tag.\n");
- return;
- }
-
- channel_attribute_t cattr{attr.at("out"), main_state_t::unset};
- if(attr.find("main") != attr.end())
- {
- cattr.main_state = (attr.at("main") == "true") ?
- main_state_t::is_main : main_state_t::is_not_main;
- if(cattr.main_state == main_state_t::is_main)
- {
- settings.has_bleed_control.store(true);
- }
- }
-
- channelmap[attr.at("in")] = cattr;
- }
-}
-
-void DrumKitParser::endTag(const std::string& name)
-{
- if(name == "instrument")
- {
- {
- // Scope the std::unique_ptr 'ptr' so we don't accidentally use it after
- // it is std::move'd to the instruments list.
- auto ptr = std::make_unique<Instrument>(settings, rand);
- ptr->setGroup(instr_group);
-
- InstrumentParser parser(*ptr, settings);
- parser.parseFile(path + "/" + instr_file);
-
- // Transfer ownership to the DrumKit object.
- kit.instruments.emplace_back(std::move(ptr));
- }
-
- auto& instrument = *kit.instruments.back();
-
- // Only use main attribute from drumkit file if at least one exists.
- main_state_t default_main_state = main_state_t::unset;
- for(const auto& channel: channelmap)
- {
- if(channel.second.main_state != main_state_t::unset)
- {
- default_main_state = main_state_t::is_not_main;
- }
- }
-
- // Assign kit channel numbers to instruments channels and reset
- // main_state attribute as needed.
- for(auto& instrument_channel: instrument.instrument_channels)
- {
- channel_attribute_t cattr{instrument_channel.name, main_state_t::unset};
- if(channelmap.find(instrument_channel.name) != channelmap.end())
- {
- cattr = channelmap[instrument_channel.name];
- }
-
- if(cattr.main_state == main_state_t::unset)
- {
- cattr.main_state = default_main_state;
- }
-
- if(cattr.main_state != main_state_t::unset)
- {
- instrument_channel.main = cattr.main_state;
- }
-
- for(auto cnt = 0u; cnt < kit.channels.size(); ++cnt)
- {
- if(kit.channels[cnt].name == cattr.cname)
- {
- instrument_channel.num = kit.channels[cnt].num;
- }
- }
-
- if(instrument_channel.num == NO_CHANNEL)
- {
- ERR(kitparser, "Missing channel '%s' in instrument '%s'\n",
- instrument_channel.name.c_str(), instrument.getName().c_str());
- }
- }
-
- channelmap.clear();
- }
-}
diff --git a/src/drumkitparser.h b/src/drumkitparser.h
deleted file mode 100644
index c77b1ff..0000000
--- a/src/drumkitparser.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * drumkitparser.h
- *
- * Tue Jul 22 16:24:58 CEST 2008
- * Copyright 2008 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#pragma once
-
-#include <string>
-
-#include "saxparser.h"
-#include "drumkit.h"
-#include "configfile.h"
-
-class DrumKitParser
- : public SAXParser
-{
-public:
- DrumKitParser(Settings& settings, DrumKit& kit, Random& rand);
- virtual ~DrumKitParser() = default;
-
- virtual int parseFile(const std::string& filename) override;
-
-protected:
- void startTag(const std::string& name, const attr_t& attributes) override;
- void endTag(const std::string& name) override;
-
-private:
- DrumKit& kit;
- std::string path;
-
- struct channel_attribute_t
- {
- std::string cname;
- main_state_t main_state;
- };
- std::unordered_map<std::string, channel_attribute_t> channelmap;
- std::string instr_file;
- std::string instr_name;
- std::string instr_group;
-
- ConfigFile refs;
- Settings& settings;
- Random& rand;
-};
diff --git a/src/instrument.cc b/src/instrument.cc
index c1cd4aa..05ac17d 100644
--- a/src/instrument.cc
+++ b/src/instrument.cc
@@ -56,46 +56,19 @@ bool Instrument::isValid() const
Sample* Instrument::sample(level_t level, size_t pos)
{
- Sample *sample = nullptr;
-
- if(version >= VersionStr("2.0"))
- {
- // Version 2.0
- sample = powerlist.get(level * mod);
- }
- else
- {
- // Version 1.0
- std::vector<Sample*> s = samples.get(level * mod);
- if(s.size() == 0)
- {
- return nullptr;
- }
-
- sample = rand.choose(s);
- }
-
- return sample;
-}
-
-void Instrument::addSample(level_t a, level_t b, Sample* s)
-{
- samples.insert(a, b, s);
+ return powerlist.get(level * mod);
}
void Instrument::finalise()
{
- if(version >= VersionStr("2.0"))
+ std::vector<Sample*>::iterator s = samplelist.begin();
+ while(s != samplelist.end())
{
- std::vector<Sample*>::iterator s = samplelist.begin();
- while(s != samplelist.end())
- {
- powerlist.add(*s);
- s++;
- }
-
- powerlist.finalise();
+ powerlist.add(*s);
+ s++;
}
+
+ powerlist.finalise();
}
const std::string& Instrument::getName() const
diff --git a/src/instrument.h b/src/instrument.h
index 20bcae4..ff33d6e 100644
--- a/src/instrument.h
+++ b/src/instrument.h
@@ -31,7 +31,6 @@
#include <memory>
#include <deque>
-#include "rangemap.h"
#include "powerlist.h"
#include "sample.h"
@@ -85,8 +84,6 @@ private:
VersionStr version;
- RangeMap<level_t, Sample*> samples;
-
void addSample(level_t a, level_t b, Sample* s);
void finalise(); ///< Signal instrument that no more samples will be added.
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
deleted file mode 100644
index 9a5e36d..0000000
--- a/src/instrumentparser.cc
+++ /dev/null
@@ -1,274 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * instrumentparser.cc
- *
- * Wed Mar 9 13:22:24 CET 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "instrumentparser.h"
-
-#include <string.h>
-#include <stdio.h>
-
-#include <hugin.hpp>
-
-#include "settings.h"
-#include "cpp11fix.h"
-#include "path.h"
-
-#include "nolocale.h"
-
-InstrumentParser::InstrumentParser(Instrument& instrument, Settings& settings)
- : instrument(instrument)
- , settings(settings)
-{
-
-}
-
-int InstrumentParser::parseFile(const std::string& filename)
-{
- path = getPath(filename);
-
- return SAXParser::parseFile(filename);
-}
-
-void InstrumentParser::startTag(const std::string& name, const attr_t& attr)
-{
- if(name == "instrument")
- {
- if(attr.find("name") != attr.end())
- {
- instrument._name = attr.at("name");
- }
-
- if(attr.find("description") != attr.end())
- {
- instrument._description = attr.at("description");
- }
-
- if(attr.find("version") != attr.end())
- {
- try
- {
- instrument.version = VersionStr(attr.at("version"));
- }
- catch(const char* err)
- {
- ERR(instrparser, "Error parsing version number: %s, using 1.0\n", err);
- instrument.version = VersionStr(1,0,0);
- }
- }
- else
- {
- WARN(instrparser, "Missing version number, assuming 1.0\n");
- instrument.version = VersionStr(1,0,0);
- }
- }
-
- if(name == "channels")
- {
- }
-
- if(name == "channel")
- {
- if(attr.find("name") == attr.end())
- {
- ERR(instrparser,"Missing channel required attribute 'name'.\n");
- return;
- }
-
- InstrumentChannel* channel = addOrGetChannel(attr.at("name"));
- channel->main = main_state_t::is_not_main;
- if(attr.find("main") != attr.end())
- {
- channel->main = (attr.at("main") == "true") ?
- main_state_t::is_main : main_state_t::is_not_main;
- if(channel->main == main_state_t::is_main)
- {
- settings.has_bleed_control.store(true);
- }
- }
- }
-
- if(name == "samples")
- {
- }
-
- if(name == "sample")
- {
- if(attr.find("name") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'name'.\n");
- return;
- }
-
- float power;
- if(attr.find("power") == attr.end())
- {
- power = -1;
- }
- else
- {
- power = atof_nol(attr.at("power").c_str());
- DEBUG(instrparser, "Instrument power set to %f\n", power);
- }
-
- // TODO get rid of new or delete it properly
- sample = new Sample(attr.at("name"), power);
- }
-
- if(name == "audiofile")
- {
- if(sample == nullptr)
- {
- ERR(instrparser,"Missing Sample!\n");
- return;
- }
-
- if(attr.find("file") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'file'.\n");
- return;
- }
-
- if(attr.find("channel") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'channel'.\n");
- return;
- }
-
- std::size_t filechannel = 1; // default, override with optional attribute
- if(attr.find("filechannel") != attr.end())
- {
- filechannel = std::stoi(attr.at("filechannel"));
- if(filechannel < 1)
- {
- ERR(instrparser,"Invalid value for attribute 'filechannel'.\n");
- filechannel = 1;
- }
- }
-
- filechannel = filechannel - 1; // 1-based in file but zero-based internally.
-
- InstrumentChannel *instrument_channel = addOrGetChannel(attr.at("channel"));
-
- auto audio_file =
- std::make_unique<AudioFile>(path + "/" + attr.at("file"),
- filechannel,
- instrument_channel);
-
- sample->addAudioFile(instrument_channel, audio_file.get());
-
- // Transfer audio_file ownership to the instrument.
- instrument.audiofiles.push_back(std::move(audio_file));
- }
-
- if(name == "velocities")
- {
- }
-
- if(name == "velocity")
- {
- if(attr.find("lower") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'lower'.\n");
- return;
- }
-
- if(attr.find("upper") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'upper'.\n");
- return;
- }
-
- lower = atof_nol(attr.at("lower").c_str());
- upper = atof_nol(attr.at("upper").c_str());
- }
-
- if(name == "sampleref")
- {
- if(attr.find("name") == attr.end())
- {
- ERR(instrparser,"Missing required attribute 'name'.\n");
- return;
- }
-
- Sample* sample_ref = nullptr;
- for(auto& sample : instrument.samplelist)
- {
- if(sample->name == attr.at("name"))
- {
- sample_ref = sample;
- break;
- }
- }
-
- if(sample_ref == nullptr)
- {
- ERR(instrparser,"Sampleref pointed at non-existing sample.\n");
- return;
- }
-
- if(instrument.version == VersionStr("1.0"))
- {
- // Old "velocity group" algorithm needs this
- instrument.addSample(lower, upper, sample_ref);
- }
- }
-}
-
-void InstrumentParser::endTag(const std::string& name)
-{
- if(name == "sample")
- {
- if(sample == nullptr)
- {
- ERR(instrparser,"Missing Sample.\n");
- return;
- }
-
- instrument.samplelist.push_back(sample);
-
- sample = nullptr;
- }
-
- if(name == "instrument") {
- instrument.finalise();
- }
-}
-
-InstrumentChannel* InstrumentParser::addOrGetChannel(const std::string& name)
-{
- for(auto& channel : instrument.instrument_channels)
- {
- if(channel.name == name)
- {
- return &channel;
- }
- }
-
- instrument.instrument_channels.emplace_back(name);
- InstrumentChannel& channel = instrument.instrument_channels.back();
- channel.main = main_state_t::unset;
-
- return &channel;
-}
diff --git a/src/instrumentparser.h b/src/instrumentparser.h
deleted file mode 100644
index a40a184..0000000
--- a/src/instrumentparser.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * instrumentparser.h
- *
- * Wed Mar 9 13:22:24 CET 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#pragma once
-
-#include "saxparser.h"
-#include "instrument.h"
-
-#include <memory>
-#include <vector>
-
-struct Settings;
-
-class InstrumentParser
- : public SAXParser
-{
-public:
- InstrumentParser(Instrument &instrument, Settings& settings);
- virtual ~InstrumentParser() = default;
-
- virtual int parseFile(const std::string& filename) override;
-
- std::vector<InstrumentChannel> channellist;
-
-protected:
- virtual void startTag(const std::string& name, const attr_t& attr) override;
- virtual void endTag(const std::string& name) override;
-
-private:
- InstrumentChannel* addOrGetChannel(const std::string& name);
-
- Instrument& instrument;
- Sample* sample{nullptr};
-
- std::string path;
-
- level_t lower{0};
- level_t upper{0};
-
- Settings& settings;
-};
diff --git a/src/rangemap.h b/src/rangemap.h
deleted file mode 100644
index e53cbe8..0000000
--- a/src/rangemap.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * rangemap.h
- *
- * Wed Sep 22 19:17:49 CEST 2010
- * Copyright 2010 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of DrumGizmo.
- *
- * DrumGizmo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DrumGizmo 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with DrumGizmo; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#pragma once
-
-#include <vector>
-#include <map>
-
-template <typename T1, typename T2> class RangeMap
-{
-public:
- void insert(T1 from, T1 to, T2 value);
- std::vector<T2> get(T1 from, T1 to);
- std::vector<T2> get(T1 at);
-
-private:
- friend class InstrumentParserTest;
- std::multimap<std::pair<T1, T1>, T2> values;
-};
-
-template <typename T1, typename T2>
-void RangeMap<T1, T2>::insert(T1 from, T1 to, T2 value)
-{
- if(from < to)
- {
- values.insert(std::make_pair(std::make_pair(from, to), value));
- }
- else
- {
- values.insert(std::make_pair(std::make_pair(to, from), value));
- }
-}
-
-template <typename T1, typename T2>
-std::vector<T2> RangeMap<T1, T2>::get(T1 from, T1 to)
-{
- std::vector<T2> res;
-
- typename std::multimap<std::pair<T1, T1>, T2>::iterator i = values.begin();
- while(i != values.end())
- {
- T1 a = i->first.first;
- T1 b = i->first.second;
- if((from >= a && to <= b) || // inside
- (from <= a && to >= b) || // containing
- (from <= a && to >= a && to <= b) || // overlapping lower
- (from >= a && from <= b && to >= b) // overlapping upper
- )
- {
- res.push_back(i->second);
- }
- i++;
- }
-
- return res;
-}
-
-template <typename T1, typename T2> std::vector<T2> RangeMap<T1, T2>::get(T1 at)
-{
- std::vector<T2> res;
-
- typename std::multimap<std::pair<T1, T1>, T2>::iterator i = values.begin();
- while(i != values.end())
- {
- T1 a = i->first.first;
- T1 b = i->first.second;
- if(at >= a && at <= b)
- {
- res.push_back(i->second);
- }
- i++;
- }
-
- return res;
-}