1 /*
2  * Author: Harry van Haaren 2013
3  *         harryhaaren@gmail.com
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "state.hxx"
20 
21 #include <iostream>
22 #include "../event.hxx"
23 #include "../eventhandler.hxx"
24 
25 #include "../jack.hxx"
26 
27 extern Jack* jack;
28 
29 using namespace std;
30 
State()31 State::State()
32 {
33 }
34 
registerStately(Stately * s)35 void State::registerStately(Stately* s)
36 {
37 	statelys.push_back( s );
38 }
39 
save()40 void State::save()
41 {
42 	for( unsigned int i = 0; i < statelys.size(); i++) {
43 		statelys.at(i)->save();
44 	}
45 }
46 
reset()47 void State::reset()
48 {
49 	for( unsigned int i = 0; i < statelys.size(); i++) {
50 		statelys.at(i)->reset();
51 	}
52 
53 	jack->getGridLogic()->updateState();
54 }
55 
finish()56 void State::finish()
57 {
58 	// trigger the GUI to write the metadata to disk, as each component of the
59 	// engine is done saving
60 
61 	EventStateSaveFinish e;
62 	writeToGuiRingbuffer( &e );
63 
64 }
65 
getNumStatelys()66 int State::getNumStatelys()
67 {
68 	return statelys.size();
69 }
70