libmanta
A cross-platform API for the Snyderphonics Manta
|
00001 #include "MantaMulti.h" 00002 #include <algorithm> 00003 #include <cstdarg> 00004 #include <cstdio> 00005 00006 MantaMulti::MantaMulti(MantaClient *client) : 00007 ReferenceCount(0) 00008 { 00009 AttachClient(client); 00010 } 00011 00012 void MantaMulti::AttachClient(MantaClient *client) 00013 { 00014 if(NULL != client) 00015 { 00016 ClientList.push_back(client); 00017 ++ReferenceCount; 00018 } 00019 } 00020 00021 void MantaMulti::DetachClient(MantaClient *client) 00022 { 00023 list<MantaClient *>::iterator foundIter; 00024 foundIter = find(ClientList.begin(), ClientList.end(), client); 00025 if(ClientList.end() != foundIter) 00026 { 00027 ClientList.erase(foundIter); 00028 --ReferenceCount; 00029 } 00030 } 00031 00032 int MantaMulti::GetReferenceCount() 00033 { 00034 return ReferenceCount; 00035 } 00036 00037 void MantaMulti::PadEvent(int row, int column, int id, int value) 00038 { 00039 for(list<MantaClient *>::iterator i = ClientList.begin(); 00040 i != ClientList.end(); ++i) 00041 { 00042 (*i)->PadEvent(row, column, id, value); 00043 } 00044 } 00045 00046 void MantaMulti::SliderEvent(int id, int value) 00047 { 00048 for(list<MantaClient *>::iterator i = ClientList.begin(); 00049 i != ClientList.end(); ++i) 00050 { 00051 (*i)->SliderEvent(id, value); 00052 } 00053 } 00054 00055 void MantaMulti::ButtonEvent(int id, int value) 00056 { 00057 for(list<MantaClient *>::iterator i = ClientList.begin(); 00058 i != ClientList.end(); ++i) 00059 { 00060 (*i)->ButtonEvent(id, value); 00061 } 00062 } 00063 00064 void MantaMulti::PadVelocityEvent(int row, int column, int id, int velocity) 00065 { 00066 for(list<MantaClient *>::iterator i = ClientList.begin(); 00067 i != ClientList.end(); ++i) 00068 { 00069 (*i)->PadVelocityEvent(row, column, id, velocity); 00070 } 00071 } 00072 00073 void MantaMulti::ButtonVelocityEvent(int id, int velocity) 00074 { 00075 for(list<MantaClient *>::iterator i = ClientList.begin(); 00076 i != ClientList.end(); ++i) 00077 { 00078 (*i)->ButtonVelocityEvent(id, velocity); 00079 } 00080 } 00081 00082 void MantaMulti::FrameEvent(uint8_t *frame) 00083 { 00084 for(list<MantaClient *>::iterator i = ClientList.begin(); 00085 i != ClientList.end(); ++i) 00086 { 00087 (*i)->FrameEvent(frame); 00088 } 00089 } 00090 00091 /* 00092 void MantaMulti::DebugPrint(const char *fmt, ...) 00093 { 00094 if(!ClientList.empty()) 00095 { 00096 va_list args; 00097 char string[256]; 00098 va_start(args, fmt); 00099 vsprintf(string, fmt, args); 00100 va_end (args); 00101 ClientList.front()->DebugPrint(string); 00102 } 00103 } 00104 */ 00105