2013-12-08 22:44:43 +01:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-09-03 18:29:10 +02:00
|
|
|
|
2013-09-06 01:28:11 +02:00
|
|
|
#ifndef LUPPP_STATELY_H
|
|
|
|
#define LUPPP_STATELY_H
|
2013-09-03 18:29:10 +02:00
|
|
|
|
2013-09-06 01:28:11 +02:00
|
|
|
/** Stately
|
|
|
|
* This class is inherited from by all classes that have state.
|
2013-09-03 18:29:10 +02:00
|
|
|
*
|
2013-09-06 01:28:11 +02:00
|
|
|
* save() should be overriden if the object needs to save its state
|
|
|
|
* reset() should be overriden if the object can clear its state
|
|
|
|
*
|
|
|
|
* The flexibility allows eg LooperClips to request buffers to tranfser audio
|
2013-09-03 18:29:10 +02:00
|
|
|
* data into the GUI thread for disk serialization, and scales for future
|
|
|
|
* classes which also need to request memory in order to save in a RT safe way.
|
|
|
|
**/
|
2013-09-06 01:28:11 +02:00
|
|
|
class Stately
|
2013-09-03 18:29:10 +02:00
|
|
|
{
|
|
|
|
public:
|
2013-09-06 01:28:11 +02:00
|
|
|
Stately();
|
2013-09-03 18:29:10 +02:00
|
|
|
|
2013-09-06 00:48:47 +02:00
|
|
|
/// this function being called resets the state of the instance to blank
|
|
|
|
virtual void reset();
|
|
|
|
|
2013-09-03 18:29:10 +02:00
|
|
|
/// this function is called when the user initiates a save action
|
|
|
|
virtual void save();
|
2013-09-03 21:06:11 +02:00
|
|
|
|
|
|
|
/// this function *must* be called by each sub-class when it is *finished*
|
2013-11-13 13:03:24 +01:00
|
|
|
/// a successful save action. Once each Stately is done, the final save is OK-ed.
|
2013-11-14 14:29:22 +01:00
|
|
|
static void success();
|
2013-11-13 13:03:24 +01:00
|
|
|
|
|
|
|
/// this function notes that a stately could *not* successfully save: buffer
|
|
|
|
/// size mismatch in LooperClip for example.
|
2013-11-14 14:29:22 +01:00
|
|
|
static void error(const char* errorString);
|
2013-09-03 21:06:11 +02:00
|
|
|
|
|
|
|
private:
|
2013-11-14 14:29:22 +01:00
|
|
|
/// holds the amount of successful / error-full saves. Used by success()
|
|
|
|
/// and error()
|
|
|
|
static int saveSuccess;
|
|
|
|
static int saveErrors;
|
|
|
|
|
|
|
|
static void checkCompletedSave();
|
2013-09-03 18:29:10 +02:00
|
|
|
};
|
|
|
|
|
2013-09-06 01:28:11 +02:00
|
|
|
#endif // LUPPP_STATELY_H
|
2013-09-03 18:29:10 +02:00
|
|
|
|