-Jack has save, Save class implemented, SaveAbles register automatically

This commit is contained in:
Harry van Haaren 2013-09-03 17:44:43 +01:00
parent 9189dab96e
commit 6601dab3ff
6 changed files with 67 additions and 1 deletions

View file

@ -5,5 +5,6 @@ CFLAGS += -g -Wall -march=native -msse -mfpmath=sse -ffast-math
INCLUDES += `pkg-config --cflags jack sndfile cairomm-1.0 ntk ntk_images`
: foreach *.cxx observer/*.cxx cjson/*.c dsp/*.cxx controller/*.cxx |> g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> %B.o
: foreach *.cxx observer/*.cxx save/*.cxx cjson/*.c dsp/*.cxx controller/*.cxx \
|> g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> %B.o

View file

@ -22,6 +22,7 @@ Jack::Jack() :
client( jack_client_open ( "Luppp", JackNullOption , 0 , 0 ) ),
timeManager(),
controllerUpdater( new ControllerUpdater() ),
save( new Save() ),
clientActive(false)
{
jack = this;

View file

@ -9,6 +9,8 @@
#include <jack/midiport.h>
#include <jack/transport.h>
#include "save/save.hxx"
#include "logic.hxx"
#include "config.hxx"
#include "looper.hxx"
@ -41,6 +43,7 @@ class Jack
Looper* getLooper(int t);
TrackOutput* getTrackOutput(int t);
Save* getSave(){return save;}
Logic* getLogic(){return logic;}
Metronome* getMetronome(){return metronome;}
GridLogic* getGridLogic(){return gridLogic;}
@ -65,6 +68,7 @@ class Jack
Buffers buffers;
TimeManager timeManager;
Metronome* metronome;
Save* save;
Logic* logic;
GridLogic* gridLogic;
ControllerUpdater* controllerUpdater;

20
src/save/save.cxx Normal file
View file

@ -0,0 +1,20 @@
#include "save.hxx"
Save::Save()
{
}
void Save::registerSaveable(SaveAble* s)
{
saveables.push_back( s );
}
void Save::save()
{
for( unsigned int i = 0; i < saveables.size(); i++)
{
saveables.at(i)->save();
}
}

26
src/save/save.hxx Normal file
View file

@ -0,0 +1,26 @@
#ifndef LUPPP_SAVE_H
#define LUPPP_SAVE_H
#include <vector>
#include "saveable.hxx"
/** Save
* This class keeps a list of all SaveAble instances, and calls save on them
* when save() is called on this class.
**/
class Save
{
public:
Save();
void save();
void registerSaveable(SaveAble* s);
private:
std::vector<SaveAble*> saveables;
};
#endif // LUPPP_SAVE_H

14
src/save/saveable.cxx Normal file
View file

@ -0,0 +1,14 @@
#include "saveable.hxx"
#include "../jack.hxx"
#include "save.hxx"
extern Jack* jack;
SaveAble::SaveAble()
{
jack->getSave()->registerSaveable( this );
}
void SaveAble::save(){};