Mercurial > hg > soniczoomios
view presetManager.h @ 7:845ea04f8e33
more logging, user id, preset info
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 06 Dec 2012 18:26:51 +0000 |
parents | 5ee5ef99e117 |
children | e2c6cfe8c6b7 |
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: string userName; int presetID; string name; long long savetime; vector<ofColor> pixVals; double timemsd = [NSDate timeIntervalSinceReferenceDate]; TwoVector coordinates; // from save button press Preset(TwoVector acoord, string aname,int aID, const vector<ofColor> & pixCols){ coordinates = acoord; name = aname; presetID = aID; timemsd = [NSDate timeIntervalSinceReferenceDate]; savetime = (long long)(timemsd*1000); pixVals = pixCols; }; Preset(int aID){ coordinates.setCoord(0.0,0.0); name = "Blank"; presetID = aID; timemsd = [NSDate timeIntervalSinceReferenceDate]; savetime = (long long)(timemsd*1000); }; // from file load Preset(TwoVector acoord, string aname,int aID, long long stime, const vector<ofColor> & pixCols){ coordinates = acoord; name = aname; presetID = aID; savetime = stime; pixVals = pixCols; }; void draw(); }; //--------------------------------------------------------------------------- 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<Preset *> getPresetsInRange(TwoVector min, TwoVector max); void drawPresetsInRange(const TwoVector min, const TwoVector max); vector<ofColor> makePresetPicture(TwoVector coord); void printAll(); void startupLoadAll(); // get stuff from XML void exitAndSaveAll(); // save to XML, delete presets array (?) void clearAll(); 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){ return(is); } TwoVector pcoord(px,py); p.loadPreset(pcoord, pname, stime); return(is); } #endif /* defined(__oscSenderExample__presetManager__) */