129 lines
2.4 KiB
C++
129 lines
2.4 KiB
C++
#ifndef _GUITAR_INSTRUMENT_HPP_
|
|
#define _GUITAR_INSTRUMENT_HPP_
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BLOCK_HPP_
|
|
#include <common/block.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_GUITAR_HPP_
|
|
#include <guitar/guitar.hpp>
|
|
#endif
|
|
|
|
class Instrument
|
|
{
|
|
public:
|
|
Instrument(const String &description,int program);
|
|
~Instrument();
|
|
const String &description(void)const;
|
|
void description(const String &description);
|
|
int program(void)const;
|
|
void program(int program);
|
|
static Instrument fromString(const String &instrument);
|
|
String toString(void)const;
|
|
bool isOkay(void)const;
|
|
private:
|
|
String mDescription;
|
|
int mProgram;
|
|
};
|
|
|
|
inline
|
|
Instrument::Instrument(const String &description,int program)
|
|
: mDescription(description), mProgram(program)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Instrument::~Instrument()
|
|
{
|
|
}
|
|
|
|
inline
|
|
const String &Instrument::description(void)const
|
|
{
|
|
return mDescription;
|
|
}
|
|
|
|
inline
|
|
void Instrument::description(const String &description)
|
|
{
|
|
mDescription=description;
|
|
}
|
|
|
|
inline
|
|
int Instrument::program(void)const
|
|
{
|
|
return mProgram;
|
|
}
|
|
|
|
inline
|
|
void Instrument::program(int program)
|
|
{
|
|
mProgram=program;
|
|
}
|
|
|
|
inline
|
|
Instrument Instrument::fromString(const String &strInstrument)
|
|
{
|
|
if(strInstrument.isNull())return Instrument("",-1);
|
|
return Instrument(strInstrument.betweenString(';',0),strInstrument.betweenString(0,';').toInt());
|
|
}
|
|
|
|
inline
|
|
String Instrument::toString()const
|
|
{
|
|
return String().fromInt(mProgram)+String(";")+mDescription;
|
|
}
|
|
|
|
inline
|
|
bool Instrument::isOkay(void)const
|
|
{
|
|
if(mDescription.isNull() || -1==mProgram)return false;
|
|
return true;
|
|
}
|
|
|
|
class Instruments : public Block<Instrument>
|
|
{
|
|
public:
|
|
enum {StartOrdinal=STRING_INSTRUMENT1,EndOrdinal=STRING_INSTRUMENT175};
|
|
Instruments();
|
|
virtual ~Instruments();
|
|
int getProgram(int index);
|
|
const Instrument &getInstrument(int index);
|
|
private:
|
|
void loadInstruments(void);
|
|
};
|
|
|
|
inline
|
|
Instruments::Instruments()
|
|
{
|
|
loadInstruments();
|
|
}
|
|
|
|
inline
|
|
Instruments::~Instruments()
|
|
{
|
|
}
|
|
|
|
inline
|
|
void Instruments::loadInstruments(void)
|
|
{
|
|
for(int index=StartOrdinal;index<=EndOrdinal;index++)
|
|
{
|
|
String strInstrument=String(index);
|
|
insert(&Instrument(String(strInstrument.betweenString(';',0).betweenString(';',0)),strInstrument.betweenString(0,';').toInt()));
|
|
}
|
|
}
|
|
|
|
inline
|
|
int Instruments::getProgram(int index)
|
|
{
|
|
return operator[](index).program();
|
|
}
|
|
|
|
inline
|
|
const Instrument &Instruments::getInstrument(int index)
|
|
{
|
|
return operator[](index);
|
|
}
|
|
#endif |