Big Mouth Billy Bass automation library
song.hpp
- Committer:
- bikeNomad
- Date:
- 2013-06-18
- Revision:
- 1:9b1f3eb204ac
- Parent:
- 0:84aaade0de8f
- Child:
- 2:eaba75af0f0d
File content as of revision 1:9b1f3eb204ac:
#ifndef __included_song_hpp #define __included_song_hpp #include <DirHandle.h> #include "billybass.hpp" #include "config.hpp" #include "action.hpp" class Song { public: typedef std::vector<Action> actions_t; // _name is relative to BASS_DIRECTORY // return a pointer to a fully read-in Song if valid // also adds new song to songs static Song *newSong(char const *_name); Song() : sequenceNumber(0), whichFish(NO_FISH), basename(0), extension(0) { fullname[0] = 0; actions.reserve(MAX_ACTIONS_PER_SONG); } bool isValid() const { return basename != 0 && whichFish != NO_FISH; } bool parseFilename(char const *_name); bool readActions(); unsigned getSequenceNumber() const { return sequenceNumber; } unsigned getWhichFish() const { return whichFish; } char const *getSampleFileName() { if (!extension) return 0; strcpy(extension, sampleExtension); return fullname; } char const *getTextFileName() { if (!extension) return 0; strcpy(extension, textExtension); return fullname; } actions_t const &getActions() const { return actions; } void print(Serial &pc) { pc.printf("%s fish=%u seq=%u\r\n", getSampleFileName(), whichFish, sequenceNumber); for (actions_t::const_iterator action_it = actions.begin(); action_it != actions.end(); action_it++) { Action const &action = *action_it; pc.printf("%0.02f %s %d\r\n", action.actionTime, action.outputName, action.desiredState ? 1 : 0); } } protected: static char const directoryName[ BASS_DIRECTORY_LENGTH + 1 ]; static unsigned const NO_FISH; static char const *textExtension; static char const *sampleExtension; unsigned sequenceNumber; // 0-relative unsigned whichFish; // 0-relative char fullname[ MAX_PATH_LEN ]; // with directory name char *basename; // points into fullname char *extension; // points into fullname actions_t actions; }; #endif // __included_song_hpp