|
|
@@ -22,7 +22,7 @@ |
|
|
|
#include <pthread.h> |
|
|
|
#include <string> |
|
|
|
#include <map> |
|
|
|
#include <iostream.h> |
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
class ChannelHandler |
|
|
|
{ |
|
|
@@ -35,20 +35,20 @@ public: |
|
|
|
// only call these from the audio thread |
|
|
|
|
|
|
|
// don't call Register*() when the audio thread is running |
|
|
|
void RegisterData(const string &ID, Type t, void *pData, int size); |
|
|
|
void Register(const string &ID, bool* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void RegisterData(const std::string &ID, Type t, void *pData, int size); |
|
|
|
void Register(const std::string &ID, bool* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(bool*)pData,sizeof(bool)); } |
|
|
|
void Register(const string &ID, char* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, char* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(char*)pData,sizeof(char)); } |
|
|
|
void Register(const string &ID, int* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, int* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(int*)pData,sizeof(int)); } |
|
|
|
void Register(const string &ID, long* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, long* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(long*)pData,sizeof(long)); } |
|
|
|
void Register(const string &ID, short* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, short* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(short*)pData,sizeof(short)); } |
|
|
|
void Register(const string &ID, float* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, float* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(float*)pData,sizeof(float)); } |
|
|
|
void Register(const string &ID, double* pData, Type t=ChannelHandler::INPUT) |
|
|
|
void Register(const std::string &ID, double* pData, Type t=ChannelHandler::INPUT) |
|
|
|
{ RegisterData(ID, t,(double*)pData,sizeof(double)); } |
|
|
|
|
|
|
|
void UpdateDataNow(); |
|
|
@@ -61,23 +61,23 @@ public: |
|
|
|
|
|
|
|
// only call these from the gui thread |
|
|
|
// the ID comes from the order the channel is registered in |
|
|
|
void GetData(const string &ID, void *data); |
|
|
|
const bool GetBool(const string &ID) { bool t; GetData(ID,&t); return t; } |
|
|
|
const char GetChar(const string &ID) { char t; GetData(ID,&t); return t; } |
|
|
|
const int GetInt(const string &ID) { int t; GetData(ID,&t); return t; } |
|
|
|
const long GetLong(const string &ID) { long t; GetData(ID,&t); return t; } |
|
|
|
const short GetShort(const string &ID) { short t; GetData(ID,&t); return t; } |
|
|
|
const float GetFloat(const string &ID) { float t; GetData(ID,&t); return t; } |
|
|
|
const double GetDouble(const string &ID) { double t; GetData(ID,&t); return t; } |
|
|
|
void GetData(const std::string &ID, void *data); |
|
|
|
const bool GetBool(const std::string &ID) { bool t; GetData(ID,&t); return t; } |
|
|
|
const char GetChar(const std::string &ID) { char t; GetData(ID,&t); return t; } |
|
|
|
const int GetInt(const std::string &ID) { int t; GetData(ID,&t); return t; } |
|
|
|
const long GetLong(const std::string &ID) { long t; GetData(ID,&t); return t; } |
|
|
|
const short GetShort(const std::string &ID) { short t; GetData(ID,&t); return t; } |
|
|
|
const float GetFloat(const std::string &ID) { float t; GetData(ID,&t); return t; } |
|
|
|
const double GetDouble(const std::string &ID) { double t; GetData(ID,&t); return t; } |
|
|
|
|
|
|
|
void SetData(const string &ID, void *s); |
|
|
|
void Set(const string &ID, const bool& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const char& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const int& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const long& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const short& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const float& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const string &ID, const double& s) { SetData(ID,(void*)&s); } |
|
|
|
void SetData(const std::string &ID, void *s); |
|
|
|
void Set(const std::string &ID, const bool& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const char& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const int& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const long& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const short& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const float& s) { SetData(ID,(void*)&s); } |
|
|
|
void Set(const std::string &ID, const double& s) { SetData(ID,(void*)&s); } |
|
|
|
|
|
|
|
void SetCommand(char command); |
|
|
|
|
|
|
@@ -89,7 +89,7 @@ public: |
|
|
|
// as it will block until complete, and for larger amounts of data, as |
|
|
|
// it won't be doing the copy every update. |
|
|
|
|
|
|
|
void RequestChannelAndWait(const string &ID); |
|
|
|
void RequestChannelAndWait(const std::string &ID); |
|
|
|
|
|
|
|
/////////////////////////////////////////// |
|
|
|
// Use for copying large variable sized data very infrequently. |
|
|
@@ -99,7 +99,7 @@ public: |
|
|
|
// to complete, depending on the size of the buffer channel and the |
|
|
|
// total size of the transfer. |
|
|
|
|
|
|
|
void BulkTransfer(const string &ID, void *dest, int size); |
|
|
|
void BulkTransfer(const std::string &ID, void *dest, int size); |
|
|
|
|
|
|
|
// delays for one or more updates. use for syncing commands |
|
|
|
void Wait(); |
|
|
@@ -119,7 +119,7 @@ private: |
|
|
|
bool updated; |
|
|
|
}; |
|
|
|
|
|
|
|
map<string,Channel*> m_ChannelMap; |
|
|
|
std::map<std::string,Channel*> m_ChannelMap; |
|
|
|
char m_Command[2]; |
|
|
|
|
|
|
|
bool m_UpdateIndicator; |
|
|
@@ -128,7 +128,7 @@ private: |
|
|
|
|
|
|
|
int m_BulkSize; |
|
|
|
int m_BulkPos; |
|
|
|
string m_BulkID; |
|
|
|
std::string m_BulkID; |
|
|
|
|
|
|
|
pthread_mutex_t* m_Mutex; |
|
|
|
}; |
|
|
|