ÕâÆª½Ì³ÌC++ tsº¯Êý´úÂëʾÀýдµÃºÜʵÓã¬Ï£ÍûÄܰﵽÄú¡£
±¾ÎÄÕûÀí»ã×ÜÁËC++ÖÐtsº¯ÊýµÄµäÐÍÓ÷¨´úÂëʾÀý¡£Èç¹ûÄúÕý¿àÓÚÒÔÏÂÎÊÌ⣺C++ tsº¯ÊýµÄ¾ßÌåÓ÷¨£¿C++ tsÔõôÓã¿C++ tsʹÓõÄÀý×Ó£¿ÄÇô¹§Ï²Äú, ÕâÀᆱѡµÄº¯Êý´úÂëʾÀý»òÐí¿ÉÒÔΪÄúÌṩ°ïÖú¡£ ÔÚÏÂÎÄÖÐÒ»¹²Õ¹Ê¾ÁËtsº¯ÊýµÄ24¸ö´úÂëʾÀý£¬ÕâЩÀý×ÓĬÈϸù¾ÝÊÜ»¶Ó³Ì¶ÈÅÅÐò¡£Äú¿ÉÒÔΪϲ»¶»òÕ߸оõÓÐÓõĴúÂëµãÔÞ£¬ÄúµÄÆÀ¼Û½«ÓÐÖúÓÚÎÒÃǵÄÏµÍ³ÍÆ¼ö³ö¸ü°ôµÄC++´úÂëʾÀý¡£ ʾÀý1: mountPathTQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) { int internal_retcode; if (!retcode) { retcode = &internal_retcode; } TQString ret = mountPath(); // Device is already mounted if (!ret.isNull()) { return ret; } TQString command; TQString devNode = deviceNode(); devNode.replace("'", "'//''"); mediaName.replace("'", "'//''");#if defined(WITH_UDISKS2) || defined(WITH_UDISKS) // Prepare filesystem options for mount TQStringList udisksOptions; TQString optionString; if (mountOptions["ro"] == "true") { udisksOptions.append("ro"); } if (mountOptions["atime"] != "true") { udisksOptions.append("noatime"); } if (mountOptions["sync"] == "true") { udisksOptions.append("sync"); } if( (mountOptions["filesystem"] == "fat") || (mountOptions["filesystem"] == "vfat") || (mountOptions["filesystem"] == "msdos") || (mountOptions["filesystem"] == "umsdos") ) { if (mountOptions.contains("shortname")) { udisksOptions.append(TQString("shortname=%1").arg(mountOptions["shortname"])); } } if( (mountOptions["filesystem"] == "jfs")) { if (mountOptions["utf8"] == "true") { // udisks/udisks2 for now does not support option iocharset= for jfs // udisksOptions.append("iocharset=utf8"); } } if( (mountOptions["filesystem"] == "ntfs-3g") ) { if (mountOptions.contains("locale")) { udisksOptions.append(TQString("locale=%1").arg(mountOptions["locale"])); } } if( (mountOptions["filesystem"] == "ext3") || (mountOptions["filesystem"] == "ext4") ) { if (mountOptions.contains("journaling")) { // udisks/udisks2 for now does not support option data= for ext3/ext4 // udisksOptions.append(TQString("data=%1").arg(mountOptions["journaling"])); } } for (TQStringList::Iterator it = udisksOptions.begin(); it != udisksOptions.end(); ++it) { optionString.append(","); optionString.append(*it); } if (!optionString.isEmpty()) { optionString.remove(0, 1); }#endif // defined(WITH_UDISKS2) || defined(WITH_UDISKS)#ifdef WITH_UDISKS2 if(command.isEmpty()) { // Try to use UDISKS v2 via DBUS, if available TQString errorString; TQString fileSystemType; if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { fileSystemType = mountOptions["filesystem"]; } int uDisks2Ret = mountDriveUDisks2(devNode, fileSystemType, optionString, &errorString); if (uDisks2Ret == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; } else if (uDisks2Ret == -1) { if (errRet) { *errRet = errorString; }//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:Fat-Zer£¬ÏîÄ¿Ãû³Æ:tdelibs£¬´úÂëÐÐÊý:101£¬
ʾÀý2: whileRTC::ReturnCode_t ControlEducatorVehicle::onExecute(RTC::UniqueId ec_id){ if (m_target_velocity_inIn.isNew()) { m_target_velocity_inIn.read(); vx = m_target_velocity_in.data.vx; vy = m_target_velocity_in.data.vy; va = m_target_velocity_in.data.va; } if (m_touchIn.isNew()) { while(m_touchIn.isNew())m_touchIn.read(); if (m_touch.data.length() >= 2) { touch_r = m_touch.data[0]; touch_l = m_touch.data[1]; if (vx > 0) { if (m_touch.data[0]) { stop_robot(); back_move(); rotate_move(true); } else if (m_touch.data[1]) { stop_robot(); back_move(); rotate_move(false); } } } } if (m_ultrasonicIn.isNew()) { while(m_ultrasonicIn.isNew())m_ultrasonicIn.read(); if (m_ultrasonic.ranges.length() >= 1) { range = m_ultrasonic.ranges[0]; if (vx > 0) { if (m_ultrasonic.ranges[0] > m_sensor_height) { stop_flag = true; stop_robot(); m_angle.data = 0; setTimestamp(m_angle); m_angleOut.write(); double a = 0; bool ret = search_ground(a); m_angle.data = 0; setTimestamp(m_angle); m_angleOut.write(); if (ret) { turn_move(a); } coil::TimeValue ts(2, 0); coil::sleep(ts); } else { stop_flag = false; } } } } if(m_light_reflectIn.isNew()) { while(m_light_reflectIn.isNew())m_light_reflectIn.read(); if(m_light_reflect.data < 1) { stop_flag = true; } else { stop_flag = false; } } if (vx <= 0) { stop_flag = false; } if (stop_flag)//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:Nobu19800£¬ÏîÄ¿Ãû³Æ:ControlEducatorVehicle£¬´úÂëÐÐÊý:101£¬
ʾÀý3: nThreadsvoid ConvToMDEventsWS::runConversion(API::Progress *pProgress) { // Get the box controller Mantid::API::BoxController_sptr bc = m_OutWSWrapper->pWorkspace()->getBoxController(); size_t lastNumBoxes = bc->getTotalNumMDBoxes(); size_t nEventsInWS = m_OutWSWrapper->pWorkspace()->getNPoints(); // Is the access to input events thread-safe? // bool MultiThreadedAdding = m_EventWS->threadSafe(); // preprocessed detectors insure that each detector has its own spectra size_t nValidSpectra = m_NSpectra; //--->>> Thread control stuff Kernel::ThreadSchedulerFIFO *ts(nullptr); int nThreads(m_NumThreads); if (nThreads < 0) nThreads = 0; // negative m_NumThreads correspond to all cores used, 0 no // threads and positive number -- nThreads requested; bool runMultithreaded = false; if (m_NumThreads != 0) { runMultithreaded = true; // Create the thread pool that will run all of these. It will be deleted by // the threadpool ts = new Kernel::ThreadSchedulerFIFO(); // it will initiate thread pool with number threads or machine's cores (0 in // tp constructor) pProgress->resetNumSteps(nValidSpectra, 0, 1); } Kernel::ThreadPool tp(ts, nThreads, new API::Progress(*pProgress)); //<<<-- Thread control stuff // if any property dimension is outside of the data range requested, the job // is done; if (!m_QConverter->calcGenericVariables(m_Coord, m_NDims)) return; size_t eventsAdded = 0; for (size_t wi = 0; wi < nValidSpectra; wi++) { size_t nConverted = this->conversionChunk(wi); eventsAdded += nConverted; nEventsInWS += nConverted; // Keep a running total of how many events we've added if (bc->shouldSplitBoxes(nEventsInWS, eventsAdded, lastNumBoxes)) { if (runMultithreaded) { // Now do all the splitting tasks m_OutWSWrapper->pWorkspace()->splitAllIfNeeded(ts); if (ts->size() > 0) tp.joinAll(); } else { m_OutWSWrapper->pWorkspace()->splitAllIfNeeded( nullptr); // it is done this way as it is possible trying to do // single // threaded split more efficiently } // Count the new # of boxes. lastNumBoxes = m_OutWSWrapper->pWorkspace() ->getBoxController() ->getTotalNumMDBoxes(); eventsAdded = 0; pProgress->report(wi); } } // Do a final splitting of everything if (runMultithreaded) { m_OutWSWrapper->pWorkspace()->splitAllIfNeeded(ts); tp.joinAll(); } else { m_OutWSWrapper->pWorkspace()->splitAllIfNeeded(nullptr); } // Recount totals at the end. m_OutWSWrapper->pWorkspace()->refreshCache(); // m_OutWSWrapper->refreshCentroid(); pProgress->report(); /// Set the special coordinate system flag on the output workspace. m_OutWSWrapper->pWorkspace()->setCoordinateSystem(m_coordinateSystem);}
¿ª·¢ÕßID:DanNixon£¬ÏîÄ¿Ãû³Æ:mantid£¬´úÂëÐÐÊý:80£¬
ʾÀý4: cvoid tst_Q3CString::acc_01(){ Q3CString a; Q3CString b; //b(10); Q3CString bb; //bb((int)0); Q3CString c("String C"); char tmp[10]; tmp[0] = 'S'; tmp[1] = 't'; tmp[2] = 'r'; tmp[3] = 'i'; tmp[4] = 'n'; tmp[5] = 'g'; tmp[6] = ' '; tmp[7] = 'D'; tmp[8] = 'X'; tmp[9] = '/0'; Q3CString d(tmp,8); Q3CString ca(a); Q3CString cb(b); Q3CString cc(c); Q3CString n; Q3CString e("String E"); Q3CString f; f = e; f.detach(); f[7]='F'; QCOMPARE(e,(Q3CString)"String E"); char text[]="String f"; f = text; text[7]='!'; QCOMPARE(f,(Q3CString)"String f"); f[7]='F'; QCOMPARE(text[7],'!');#if 0 a=""; a[0]='A'; Q3CString res = "A"; QCOMPARE(a,res); QCOMPARE(a.length(),(uint)1); compare(a.length(),(uint)1); a[1]='B'; QCOMPARE(a,(Q3CString)"AB"); QCOMPARE(a.length(),(uint)2); a[2]='C'; QCOMPARE(a,(Q3CString)"ABC"); QCOMPARE(a.length(),(uint)3); a = Q3CString(); QVERIFY(a.isNull()); a[0]='A'; QCOMPARE(a,(Q3CString)"A"); QCOMPARE(a.length(),(uint)1); a[1]='B'; QCOMPARE(a,(Q3CString)"AB"); QCOMPARE(a.length(),(uint)2); a[2]='C'; QCOMPARE(a,(Q3CString)"ABC"); QCOMPARE(a.length(),(uint)3);#endif a="123"; b="456"; a[0]=a[1]; QCOMPARE(a,(Q3CString)"223"); a[1]=b[1]; QCOMPARE(b,(Q3CString)"456"); QCOMPARE(a,(Q3CString)"253"); char t[]="TEXT"; a="A"; a=t; QCOMPARE(a,(Q3CString)"TEXT"); QCOMPARE(a,(Q3CString)t); a[0]='X'; QCOMPARE(a,(Q3CString)"XEXT"); QCOMPARE(t[0],'T'); t[0]='Z'; QCOMPARE(a,(Q3CString)"XEXT"); a="ABC"; QCOMPARE(((const char*)a)[1],'B'); QCOMPARE(strcmp(a,(Q3CString)"ABC"),0); a += "DEF"; QCOMPARE(a, (Q3CString)"ABCDEF"); a += 'G'; QCOMPARE(a, (Q3CString)"ABCDEFG"); a += ((const char*)(0)); QCOMPARE(a, (Q3CString)"ABCDEFG"); // non-member operators a="ABC"; b="ABC"; c="ACB"; d="ABCD"; QVERIFY(a==b); QVERIFY(!(a==d)); QVERIFY(!(a!=b)); QVERIFY(a!=d); QVERIFY(!(a<b));//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:mpvader£¬ÏîÄ¿Ãû³Æ:qt£¬´úÂëÐÐÊý:101£¬
|