/** Destructor. */ Component::~Component() { DEBUGINFO(this, "Component::~Component() (\""+name+"\")"); // Remove all slots... while(slots.begin()!=slots.end()) { removeSlot(slots.begin()->first); } }
/** Return the slot with the given name. A EKeyError exception is thrown if there's no slot with the specified name. \param name The name of the slot that should be returned. \return Slot. */ ISlot& Component::slot(const string& name) const { DEBUGINFO(this, "Component::slot(\""+name+"\")"); SlotIterator it = slots.find(name); if (it==slots.end()) { throw EKeyError("Slot \""+name+"\" does not exist."); } else { return it->second->getSlot(); } }
/* Periodic Callback Function */ void checkEvent(const struct timeval curTimeval) { char* data = "hallo world!\n"; char recvdata[1024] = {0}; int datalen = strlen(data); int sum; int* pFd = NULL; commGetAliveLinks("Udp-2", &sum, &pFd); if(pFd && (*pFd > 0)) { commSend(*pFd, data, &datalen, NULL); DEBUGINFO("send <%d> bytes~", datalen); } #ifdef WIN32 Sleep(2000); #else sleep(2); #endif return; }
string jstringTostring(JNIEnv* env, jstring jstr) { char* rtn = NULL; jclass clsstring = env->FindClass("java/lang/String"); //jstring strencode = env->NewStringUTF("GB2312"); jstring strencode = (env)->NewStringUTF("UTF8"); jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); jbyteArray barr= (jbyteArray)env->CallObjectMethod(jstr,mid,strencode); jsize alen = env->GetArrayLength(barr); jbyte* ba = env->GetByteArrayElements(barr,JNI_FALSE); if(alen>0) { rtn = (char*)malloc(alen+1); //new char[alen+1]; memcpy(rtn,ba,alen); rtn[alen]=0; DEBUGINFO("in %s: translate to %s\n", __func__, rtn); } env->ReleaseByteArrayElements(barr,ba,0); string stemp(rtn); free(rtn); return stemp; }
void Plugin_Search ( void ) { DmSearchStateType searchState; UInt16 tempCardNo; MemHandle tempPlugInResH; // handle to our plug-in resource Boolean newSearch = true; LocalID tempPlugInDbID = 0; Err theErr = 0; UInt8 curPlug = 0; MemHandle nameH; Char *nameP; Plug_ParamBlock plugInParamBlock; do { DEBUGINFO("Top of loop."); theErr = DmGetNextDatabaseByTypeCreator(newSearch, &searchState, kPlugInFileType, kPlugInFileCreator, false /* all versions */, &tempCardNo, &tempPlugInDbID); newSearch = false; DEBUGINFO("After search."); if ( !theErr ) { DEBUGINFO("No error."); DEBUGINFO("abba 6"); PluginListP[curPlug] = (Plug_InternalRef *)MemPtrNew(sizeof(Plug_InternalRef)); DEBUGINFO("abba 7"); PluginListP[curPlug]->gPlugInDbRef = DmOpenDatabase(tempCardNo, tempPlugInDbID, dmModeReadOnly); DEBUGINFO("abba 3"); tempPlugInResH = DmGetResource(kPlugInResourceType, kFirstPlugInResID); DEBUGINFO("abba 4"); if ( !tempPlugInResH ) continue; DEBUGINFO("abba 5"); // Get a lock on the code resource. DEBUGINFO("abba"); PluginListP[curPlug]->gPlugInResP = (Plug_Main *)MemHandleLock(tempPlugInResH); DEBUGINFO("abba"); // Get the plugin's long name. DEBUGINFO("abba"); nameH = DmGet1Resource ( 'tAIN', 1000 ); DEBUGINFO("abba"); if ( nameH ) { DEBUGINFO("abba"); nameP = MemHandleLock(nameH); DEBUGINFO(nameP); StrCopy ( PluginListP[curPlug]->longname, nameP ); MemHandleUnlock ( nameH ); } DEBUGINFO("blorg"); // Get the plugin's short (list) name. DEBUGINFO("abba"); nameH = DmGet1Resource ( 'tSTR', 1 ); DEBUGINFO("abba"); if ( nameH ) { DEBUGINFO("abba"); nameP = MemHandleLock(nameH); DEBUGINFO(nameP); StrCopy ( PluginListP[curPlug]->shortname, nameP ); MemHandleUnlock ( nameH ); } DEBUGINFO("shnee"); // Send the plugin a startup event... plugInParamBlock.eType = cmdStartup; theErr = (*PluginListP[curPlug]->gPlugInResP) (&plugInParamBlock); DEBUGINFO("whoot"); if ( theErr ) theErr = 0; } } while (!theErr); }