Mercurial > hg > soniczoomios
view presetManager.h @ 4:7541aeaebcdc
presest store locally. bit crap still though.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 04 Dec 2012 18:36:00 +0000 |
parents | 43df75088d85 |
children | 5ee5ef99e117 |
line wrap: on
line source
// // presetManager.h // oscSenderExample // // Created by Robert Tubb on 07/11/2012. // // #ifndef __oscSenderExample__presetManager__ #define __oscSenderExample__presetManager__ #include <iostream> #include "ofMain.h" #include "ofxiPhone.h" #include "ofxiPhoneExtras.h" #include "2dvector.h" #include "grid.h" //--------------------------------------------------------------------------- class Preset{ public: int presetID; string name; long long savetime; double timemsd = [NSDate timeIntervalSinceReferenceDate]; TwoVector coordinates; Preset(TwoVector acoord, string aname,int aID){ coordinates = acoord; name = aname; presetID = aID; timemsd = [NSDate timeIntervalSinceReferenceDate]; savetime = (long long)(timemsd*1000); }; Preset(int aID){ coordinates.setCoord(0.0,0.0); name = "Blank"; presetID = aID; timemsd = [NSDate timeIntervalSinceReferenceDate]; savetime = (long long)(timemsd*1000); }; Preset(TwoVector acoord, string aname,int aID, long long stime){ coordinates = acoord; name = aname; presetID = aID; savetime = stime; }; }; //--------------------------------------------------------------------------- class PresetManager{ public: int nextID; int timesOpened; // names values // check if already there // find and return all(?) presets within a certain coordinate range vector<Preset *> thePresets; // we want vector ? or list? pointers using new? int addPreset(TwoVector coord, string name); // returns id or negative error number int loadPreset(const TwoVector coord, const string name, long long stime); TwoVector recallPreset(int presetID); // by name ? id? TwoVector recallPreset(string name); // by name ? id? vector<TwoVector > getPresetsInRange(TwoVector min, TwoVector max); void printAll(); void startupLoadAll(); // get stuff from XML void exitAndSaveAll(); // save to XML, delete presets array (?) void deleteAll(); PresetManager(); }; //--------------------------------------------------------------------------- inline ostream& operator<<(ostream & os, const Preset& p){ os.setf(ios_base::fixed,ios_base::floatfield); os.precision(1); os << p.savetime << ',' << p.coordinates.x << ',' << p.coordinates.y << '\n'; return os; } //--------------------------------------------------------------------------- inline istream& operator>>(istream & is, PresetManager& p) { //um string pname = "BLANK"; char delim; double px, py; long long stime; is.setf(ios_base::fixed,ios_base::floatfield); is.precision(1); is >> stime >> delim >> px >> delim >> py; if(!is){ cout << "problem reading preset file"; return(is); } TwoVector pcoord(px,py); int n = p.loadPreset(pcoord, pname, stime); cout << "read preset : " << n << '\n'; return(is); } #endif /* defined(__oscSenderExample__presetManager__) */