Mercurial > hg > soniczoomios
view eventLogger.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
// // eventLogger.h // oscSenderExample // // Created by Robert Tubb on 05/11/2012. // // // This class handle everything to do with loggin user actions, // uploading logs to server, and storing locally if not uploaded #ifndef __oscSenderExample__eventLogger__ #define __oscSenderExample__eventLogger__ #include "ofMain.h" #include "ofxiPhone.h" #include "2dvector.h" #include "ofxiPhoneExtras.h" #include <sys/time.h> #include <iostream> #include <string> #include <map> #include "2dvector.h" enum leventType {SAVE_PRESET, SAVE_DESET, SCROLL, SCROLL_STOPPED, ZOOM, CHANGE_SLIDER, SWAP_VIEW, SET_MIN_ZOOM, SET_MAX_ZOOM}; class lEvent{ public: // try and make this as compact as possible. leventType eventType; double val1; // x coord, scale if zoom double val2; // y coord, 0 if zoom int sliderID; lEvent(leventType eType, double v1, double v2 = 0.0,int sID = 0){ eventType = eType; val1 = v1; val2 = v2; sliderID = sID; } }; //--------------------------------------------------------------------------- inline istream& operator>>(istream & is, lEvent& e){ is.setf(ios_base::fixed,ios_base::floatfield); is.precision(1); char delim; int eType; is >> eType >> delim >> e.val1 >> delim >> e.val2 >> delim >> e.sliderID; e.eventType = (leventType)eType; return is; } //--------------------------------------------------------------------------- inline ostream& operator<<(ostream & os, const lEvent& e){ os.setf(ios_base::fixed,ios_base::floatfield); os.precision(1); os << e.eventType << ',' << e.val1 << ',' << e.val2 << ',' << e.sliderID << '\n'; return os; } //--------------------------------------------------------------------------- class EventLogger{ public: // what we need... /* time, type, value */ bool loggingEnabled; vector<lEvent> theEvents; unsigned int deviceID; // get something from hardware?? unsigned int totalInteractionTime, sessionTime, sessionStartTime; string userName; EventLogger(); void init(); void logEvent(const leventType& evtType,const TwoVector& centre = TwoVector(), const double& scale = 1.0, const int& sliderID = -1, const double& sliderVal = 0.0); void logEvent(const leventType& evtType,const int& sliderID, const double& sliderVal); void sendHttp(); void checkLogFile(); void attemptUpload(); void firstEverAppOpen(); void exitAndSave(); void printAll(){ cout << "ALL LOGGED EVENTS!: \n"; vector<lEvent>::iterator evIter; for(evIter = theEvents.begin(); evIter < theEvents.end(); evIter++){ cout << *evIter; } }; }; #endif /* defined(__oscSenderExample__eventLogger__) */