Mercurial > hg > soniczoomios
diff 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 diff
--- a/presetManager.h Mon Dec 03 18:29:07 2012 +0000 +++ b/presetManager.h Tue Dec 04 18:36:00 2012 +0000 @@ -23,18 +23,34 @@ 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; }; @@ -42,20 +58,6 @@ //--------------------------------------------------------------------------- -inline ostream& operator<<(ostream & os, const Preset& p) -{ - os << "Name:" << p.name << "|"; - os << "Coord:" << p.coordinates << "\n"; - - return(os); -} -//--------------------------------------------------------------------------- -inline istream& operator>>(istream & is, Preset& p) -{ - //um - return(is); -} -//--------------------------------------------------------------------------- class PresetManager{ public: int nextID; @@ -66,14 +68,53 @@ 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__) */