/* -----------------------------------------------------------------------------
 *
 * Giada - Your Hardcore Loopmachine
 *
 * -----------------------------------------------------------------------------
 *
 * Copyright (C) 2010-2021 Giovanni A. Zuliani | Monocasual
 *
 * This file is part of Giada - Your Hardcore Loopmachine.
 *
 * Giada - Your Hardcore Loopmachine 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 3 of the License, or (at your option) any later version.
 *
 * Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * -------------------------------------------------------------------------- */

#ifndef G_RANGE_H
#define G_RANGE_H

#include <cassert>

namespace giada
{
template <typename T>
class Range
{
public:
	Range()
	: m_a(0)
	, m_b(0)
	{
	}
	Range(T a, T b)
	: m_a(a)
	, m_b(b)
	{
		assert(a < b);
	}

	T getBegin() const { return m_a; }
	T getEnd() const { return m_b; }
	T getLength() const { return m_b - m_a; }

	bool contains(T t) const
	{
		return t >= m_a && t < m_b;
	}

  private:
	T m_a;
	T m_b;
};
} // namespace giada

#endif
