bool GetFileList(const string &sStoragePath, string &sOutResponse) { START_FUNCTION_BOOL(); ASSERTE(!sStoragePath.empty()); const sizeint siStoragePathLength = sStoragePath.length(); string_v vsFilesList; sizeint siFilesCount = FileUtils::GetFileListRecursive(sStoragePath.c_str(), vsFilesList); string sResult; sizeint siEstimatedLength = (sStoragePath.length() + 1) * siFilesCount; sResult.reserve(siEstimatedLength); for (sizeint siIndex = 0; siIndex < siFilesCount; ++siIndex) { string &sCurrentFile = vsFilesList[siIndex]; ASSERTE(sCurrentFile.length() > siStoragePathLength); string sFileInfo; if (GetFileInfo(sCurrentFile, sFileInfo)) { string sCurrentFileItem = sCurrentFile.substr(siStoragePathLength) + sFileInfo; sResult.append(sCurrentFileItem); } } sOutResponse = sResult; END_FUNCTION_BOOL(); }
TopMenu::TopMenu() : m_thread(NULL) , m_stopEvent(CreateEvent(NULL, TRUE, FALSE, NULL)) { BOOL b; DWORD d; TopMenu_CSLock lock(s_cs); InterlockedIncrement((long*)&shared_instanceCount); WNDCLASS wndClass; ZeroMemory(&wndClass, sizeof(wndClass)); wndClass.lpszClassName = "TrayIconMonitor"; wndClass.hInstance = (HINSTANCE)&__ImageBase; wndClass.lpfnWndProc = TrayIconProc; d=RegisterClass(&wndClass); ASSERT(d != 0); char exePath[MAX_PATH]; d=GetModuleFileName(NULL, exePath, sizeof(exePath)); ASSERT(d != 0); d=ExtractIconEx(exePath, 0, NULL, &m_hProgIcon, 1); ASSERT(d == 1); ASSERTE(m_stopEvent); m_thread = CreateThread(NULL, 0, &TopMenu::beginRun, this, 0, NULL); ASSERTE(m_thread); if(!m_thread) { b=SetEnvironmentVariable("TopMenu_Plugin", "Loaded - cannot start monitor thread"); ASSERT(b); //lint !e534 JLD } else { b=SetEnvironmentVariable("TopMenu_Plugin", "Loaded"); ASSERT(b); //lint !e534 JLD } ASSERTE(!s_pInstance); s_pInstance = this; }
void CSmartServer::CreateIniSettings() { ASSERTE(GetIniSettings() == NULL); CIniSettings *pisIniSettings = new (nothrow) CIniSettings(); ASSERTE(pisIniSettings); SetIniSettings(pisIniSettings); }
void CSmartServer::CreateMusicPlayer() { ASSERTE(GetMusicPlayer() == NULL); CMusicPlayer *pmpMusicPlayer = new (nothrow) CMusicPlayer(); ASSERTE(pmpMusicPlayer); SetMusicPlayer(pmpMusicPlayer); }
void CSmartServer::CreateArduinoDevice() { ASSERTE(GetArduinoDevice() == NULL); CArduinoDevice *padArduinoDevoce = new (nothrow) CArduinoDevice(); ASSERTE(padArduinoDevoce); SetArduinoDevice(padArduinoDevoce); }
void CSmartServer::CreateDBLogger() { ASSERTE(GetDBLogger() == NULL); CDBLogger *pdlDBLogger = new (nothrow) CDBLogger(); ASSERTE(pdlDBLogger); SetDBLogger(pdlDBLogger); }
/////////////////////////////////////////////////////////////////// // Computing FFT-512 using fixed-point arithmetic // This is the C equivalent of the FFT_Fwd512 Assembly Code int FFT_Fwd512( vec<cmplx<int > > &X, // input array vec<cmplx<int > > &Y, // output array vec<cmplx<char > > &W1_512, // table of coefficients vec<cmplx<char > > &W2_512, // table of coefficients int Shr1, // 1-st shiftr normalization int Shr2 // 2-nd shiftr normalization ) { ASSERTE(X.size==512); ASSERTE(Y.size==512); vec<cmplx<int > > S(512); vec<cmplx<int > > T(512); int l,p,i,j,n; // first 2-point fft for (n=0;n<256;n++) { S[n] =X[n]+X[n+256]; S[n+256] =X[n]-X[n+256]; } // second 16-point fft cmplx<int > Summ; for (i=0;i<16;i++) { int idx=0; //k=0 for (p=0;p<16;p++) { Summ=0; for (j=0;j<16;j++,idx++) Summ+=W1_512[idx]*S[256*0+16*j+i]; T[256*0+16*p+i]=Summ; } //k=1 for (p=0;p<16;p++) { Summ=0; for (j=0;j<16;j++,idx++) Summ+=W1_512[idx]*S[256*1+16*j+i]; T[256*1+16*p+i]=Summ; } } if (Shr1>0) { // Not implemented in FFT_Inv512 //------- Roundation ----------------- vec<cmplx<int > > VcRound(512); cmplx<int >OneHalf(1<<(Shr1-1),1<<(Shr1-1)); VcRound=OneHalf; T+=VcRound; //----------------------------------- T>>=Shr1; }
bool CSmartServer::InitCommandReceiver() { ushort usPort = 0; string sBindAddress; GetConfigInt(ECO_BIND_PORT, usPort); ASSERTE(usPort); GetConfigString(ECO_BIND_ADDRESS, sBindAddress); ASSERTE(!sBindAddress.empty()); bool bResult = Start(usPort, sBindAddress); return bResult; }
CSocketHeadLenChanger::CSocketHeadLenChanger(CSocket *psSocket, bool bSetUseHeaderLen /*= false*/): m_psSocket(psSocket), m_bSetUseHeaderLen(bSetUseHeaderLen) { ASSERTE(psSocket); psSocket->SetUseHeaderLen(m_bSetUseHeaderLen); }
const string CSmartServer::GetBinaryDir() const { string sLocationPath; GetConfigString(ECO_LOCATION_PATH, sLocationPath); ASSERTE(!sLocationPath.empty()); return sLocationPath; }
void CreateCommandLineParamsVactor(int argc, char *argv[], string_v &vsOutParams) { ASSERTE(argv && argc); string_v vsParams; for (int idx = 0; idx < argc; ++idx) { vsParams.push_back(argv[idx]); } vsOutParams.swap(vsParams); }
void CreateCommandLineParamsVactor(char *szCommandLine, string_v &vsOutParams) { ASSERTE(szCommandLine); string_v vsParams; bool bInQuotes = false; sizeint siCommandLineLen = strlen(szCommandLine); char *pszStartPos = const_cast<char *>(szCommandLine); for (sizeint siIndex = 0; siIndex < siCommandLineLen; ++siIndex) { if (szCommandLine[siIndex] == QUOTE) { bInQuotes = !bInQuotes; } if (!bInQuotes && (szCommandLine[siIndex] == SPACE || szCommandLine[siIndex] == TAB)) { if (pszStartPos == szCommandLine + siIndex) { ++pszStartPos; } else { szCommandLine[siIndex] = 0; vsParams.push_back(pszStartPos); pszStartPos = szCommandLine + siIndex + 1; } } } if (strlen(pszStartPos)) { vsParams.push_back(pszStartPos); } vsOutParams.swap(vsParams); }
/*static */ void display_t::save_screen(const char *szFileName) { ASSERTE(szFileName); int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); HWND hDesktopWnd = GetDesktopWindow(); HDC hDesktopDC = GetDC(hDesktopWnd); HDC hCaptureDC = CreateCompatibleDC(hDesktopDC); HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight); SelectObject(hCaptureDC, hCaptureBitmap); BitBlt(hCaptureDC, 0, 0, nScreenWidth, nScreenHeight, hDesktopDC, 0, 0, SRCCOPY | CAPTUREBLT); save_bitmap(szFileName, hCaptureBitmap); ReleaseDC(hDesktopWnd,hDesktopDC); DeleteDC(hCaptureDC); DeleteObject(hCaptureBitmap); }
void CConfigFile::SetOptionValue(const string& sSection, const string& sParam, const string& sValue) { CIniSettingStorage::iterator itMap = m_issStorage.find(sSection); if (itMap == m_issStorage.end()) { CSectionData *psdSectionData = new (nothrow) CSectionData(); ASSERTE(psdSectionData); const pair<CIniSettingStorage::iterator, bool>& insResult = m_issStorage.insert(CIniSettingStorage::value_type(sSection, psdSectionData)); itMap = insResult.first; } CSectionData& sdSectionData = *(itMap->second); CSectionData::iterator itSubMup = sdSectionData.find(sParam); if (itSubMup == sdSectionData.end()) { sdSectionData.insert(CSectionData::value_type(sParam, sValue)); } else { itSubMup->second = sValue; } }
ssl_socket &BaseClient::remote_socket() { ASSERTE(this->mp_remote_socket, uniproxy::error::socket_invalid, ""); return *this->mp_remote_socket; }
void SIG_Resample(nm8s* pSrcVec, int nSrcVecSize, int nP, int nQ, int nK, int nWindow, nm16s* pDstVec) { const double PI=3.1415926535897932384626433832795; double fP=nP; double v; int k,i,j; int nFixpoint=64; if (nP>=nQ) { nmvec16s vKernel(nP*nK+1); vec<double> vHamming(nP*nK+1); vec<double> vImpulse(nP*nK+1); vec<double> vEnergy(nP); if(nK==1) { vImpulse.reset(); for(k=0;k<vKernel.size-1;k++) { vImpulse[k]=1; } } else { ASSERTE(nK%2==0); // Impulse function generation vImpulse[vImpulse.size/2]=1; for(k=1;k<=vKernel.size/2;k++) { v=sin(PI*double(k)/fP)/(PI*k/fP); //1.0/nP* vImpulse[vImpulse.size/2+k]=v; vImpulse[vImpulse.size/2-k]=v; } vEnergy.reset(); for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vEnergy[i]+=vImpulse[k]; if (nWindow) { // Hamming window function generation for(k=0;k<vHamming.size;k++) { vHamming[k]=0.54-0.46*cos(2*PI*k/(vHamming.size-1)); } // multiplication of impulse response by Hamming window for(k=0;k<vImpulse.size;k++) { vImpulse[k]*=vHamming[k]; } } } vEnergy.reset(); for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vEnergy[i]+=vImpulse[k]; for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vImpulse[k]/=vEnergy[i]; vEnergy.reset(); for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vEnergy[i]+=vImpulse[k]; // Filxed point kernel coefficient initialization for(k=0;k<vImpulse.size;k++) vKernel[k]=floor(vImpulse[k]*nFixpoint+0.5); // Up-resampling by nP times nmvec8s vSrcUpsample(nSrcVecSize*nP,nP*nK); // Up-Resampled vSrcVec by nP times nmvec16s vDstUpsample(nSrcVecSize*nP); // Filtered vSrcUpsample vSrcUpsample.reset(); for(i=0;i<nSrcVecSize;i++) { vSrcUpsample[i*nP]=pSrcVec[i]; } // Filtration for(i=0;i<vDstUpsample.size;i++) { nmvec8s vLocalSrcUpsample(vSrcUpsample.m_data+i-vKernel.size/2,vKernel.size); vDstUpsample[i]=vLocalSrcUpsample*vKernel; } // Decimation by 4 //for(i=0,j=0;i<vSrcUpsample.size;i+=nQ,j++) for(i=0,j=0;j<nSrcVecSize*nP/nQ;i+=nQ,j++) { pDstVec[j]=vDstUpsample[i].m_value; } } }
const string &EncodeCloudCommand(ECLOUDCOMMAND ecCommand) { ASSERTE(IN_RANGE(ecCommand, ECC__MIN, ECC__MAX)); return g_asCloudCommands[ecCommand]; }
void SIG_VResample(nm8s* pSrcImg, int nSrcStride, int nSrcWidth, int nSrcHeight, int nP, int nQ, int nK, int nWindow, nm16s* pDstImg) { nmmtr8s mSrcImg(pSrcImg,nSrcHeight,nSrcWidth); nmmtr16s mDstImg(pDstImg,nSrcHeight*nP/nQ,nSrcWidth); const double PI=3.1415926535897932384626433832795; double fP=nP; double v; int k,i,j; int nFixpoint=64; if (nP>=nQ) { nmvec16s vKernel(nP*nK+1); vec<double> vHamming(nP*nK+1); vec<double> vImpulse(nP*nK+1); vec<double> vEnergy(nP); if(nK==1) { vImpulse.reset(); for(k=0;k<vKernel.size-1;k++) { vImpulse[k]=1; } } else { ASSERTE(nK%2==0); // Impulse function generation vImpulse[vImpulse.size/2]=1; for(k=1;k<=vKernel.size/2;k++) { v=sin(PI*double(k)/fP)/(PI*k/fP); //1.0/nP* vImpulse[vImpulse.size/2+k]=v; vImpulse[vImpulse.size/2-k]=v; } if (nWindow) { // Hamming window function generation for(k=0;k<vHamming.size;k++) { vHamming[k]=0.54-0.46*cos(2*PI*k/(vHamming.size-1)); } // multiplication of impulse response by Hamming window for(k=0;k<vImpulse.size;k++) { vImpulse[k]*=vHamming[k]; } } } vEnergy.reset(); for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vEnergy[i]+=vImpulse[k]; for(i=0;i<nP;i++) for(k=i;k<vImpulse.size;k+=nP) vImpulse[k]/=vEnergy[i]; // Filxed point kernel coefficient initialization for(k=0;k<vImpulse.size;k++) vKernel[k]=floor(vImpulse[k]*nFixpoint+0.5); nmvec8s vSrcUpsample(nSrcHeight*nP,nP*nK); // Up-Resampled vSrcVec by nP times nmvec16s vDstUpsample(nSrcHeight*nP); // Filtered vSrcUpsample vSrcUpsample.reset(); for(int x=0;x<nSrcWidth;x++) { int y; // Up-resampling by nP times for( y=0;y<nSrcHeight;y++) { vSrcUpsample[y*nP]= mSrcImg[y][x]; } // Filtration for(i=0;i<vSrcUpsample.size;i++) { nmvec8s vLocalSrcUpsample(vSrcUpsample.m_data+i-vKernel.size/2,vKernel.size); vDstUpsample[i]=vLocalSrcUpsample*vKernel; } // Decimation by 4 for(y=0,i=0;y<mDstImg.m_height;i+=nQ,y++) { mDstImg[y][x]=vDstUpsample[i].m_value; } } } }