Created
July 11, 2012 11:51
-
-
Save joernroeder/3089877 to your computer and use it in GitHub Desktop.
AppConnector.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AppConnector.h | |
* appConnector | |
* | |
* Created by Jonathan Pirnay & Jörn Röder. | |
* Copyright 2012 jj. All rights reserved. | |
* | |
*/ | |
#include "ofMain.h" | |
#include "ofxJansson.h" | |
#include "RequestHandler.h" | |
#include <tr1/unordered_map> | |
#include "connectedApp.h" | |
#ifndef APPCONNECTOR_H_INCLUDED | |
#define APPCONNECTOR_H_INCLUDED | |
#define APPCONNECTOR_VERSION 0.2 | |
class connectedApp; | |
typedef void (connectedApp::*setter)(string); | |
typedef string (connectedApp::*getter)(void); | |
typedef std::tr1::unordered_map<string, string> MapStringString; | |
typedef std::tr1::unordered_map<string, getter> MapStringGetter; | |
typedef std::tr1::unordered_map<string, setter> MapStringSetter; | |
typedef std::tr1::unordered_map<string, MapStringSetter> MapStringMapStringSetter; | |
class AppConnector : public ofThread { | |
public: | |
void init(string appKey); | |
void setup(); | |
void exit(); | |
void threadedFunction(); | |
void setDebugResponse(bool val); | |
bool getDebugResponse(); | |
void setDebug(bool val); | |
bool isDebug(); | |
bool available(); | |
bool isRunning(); | |
void publish(string name, string desc, getter g); | |
void sync(); | |
void sync(string appName, string name, setter s); | |
private: | |
void loaded(); | |
void start(); | |
long getDelay(int t); | |
json_t* publishMethods(); | |
json_t* publishMethod(string name, getter g); | |
setter getMethodForSyncKey(const char* appName, const char* varName); | |
void setMethods(json_t* data); | |
json_t* getSyncMethodsToJSON(); | |
bool checkCurrentAppVersion(string version); | |
bool _isDebug, _available, _running; | |
int interval, reloadInterval; | |
MapStringGetter _publishMethods; | |
MapStringMapStringSetter _syncMethods; | |
json_t* _publishDescriptions; | |
ofxJansson JSONParser; | |
RequestHandler handler; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment