Files
Work/guitar/NoteType.hpp
2024-08-07 09:16:27 -04:00

87 lines
1.5 KiB
C++

#ifndef _GUITAR_NOTETYPE_HPP_
#define _GUITAR_NOTETYPE_HPP_
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
class NoteType
{
public:
enum TypeNote{WholeNote=1,HalfNote=2,QuarterNote=4,EighthNote=8,
SixteenthNote=16,ThirtySecondNote=32,SixtyFourthNote=64};
NoteType(TypeNote noteType=QuarterNote);
virtual ~NoteType();
const NoteType &operator++(void);
NoteType operator++(int postfix);
const NoteType &operator--(void);
NoteType operator--(int postfix);
TypeNote getNoteType(void)const;
int toInt(void)const;
NoteType &fromInt(int noteType);
NoteType &fromString(const String &stringRep);
void setNoteType(TypeNote noteType);
String toString(void)const;
static Array<String> enumerate(void);
static String toString(TypeNote noteType);
private:
int mNoteType;
};
inline
NoteType::NoteType(TypeNote noteType)
: mNoteType(noteType)
{
}
inline
NoteType::~NoteType()
{
}
inline
NoteType NoteType::operator++(int postfix)
{
NoteType noteType(*this);
operator++();
return noteType;
}
inline
NoteType NoteType::operator--(int postfix)
{
NoteType noteType(*this);
operator--();
return noteType;
}
inline
int NoteType::toInt(void)const
{
return (int)mNoteType;
}
inline
NoteType &NoteType::fromInt(int noteType)
{
mNoteType=(TypeNote)noteType;
return *this;
}
inline
NoteType::TypeNote NoteType::getNoteType(void)const
{
return (TypeNote)mNoteType;
}
inline
void NoteType::setNoteType(TypeNote noteType)
{
mNoteType=noteType;
}
#endif