本文整理汇总了C++中KstScalarPtr::update方法的典型用法代码示例。如果您正苦于以下问题:C++ KstScalarPtr::update方法的具体用法?C++ KstScalarPtr::update怎么用?C++ KstScalarPtr::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstScalarPtr
的用法示例。
在下文中一共展示了KstScalarPtr::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doUpdates
bool UpdateThread::doUpdates(bool force, bool *gotData) {
KstObject::UpdateType U = KstObject::NO_CHANGE;
_updatedCurves.clear(); // HACK
if (gotData) {
*gotData = false;
}
#if UPDATEDEBUG > 0
if (force) {
qDebug() << "Forced update!" << endl;
}
#endif
_updateCounter++;
if (_updateCounter < 1) {
_updateCounter = 1; // check for wrap around
}
#if UPDATEDEBUG > 2
qDebug() << "UPDATE: counter=" << _updateCounter << endl;
#endif
{
// Must make a copy to avoid deadlock
KstBaseCurveList cl;
KstDataObjectList dol;
kstObjectSplitList<KstDataObject, KstBaseCurve>(KST::dataObjectList, cl, dol);
qSort(cl);
qSort(dol);
// Update all curves
for (uint i = 0; i < cl.count(); ++i) {
KstBaseCurvePtr bcp = cl[i];
bcp->writeLock();
assert(bcp.data());
#if UPDATEDEBUG > 1
qDebug() << "updating curve: " << (void*)bcp << " - " << bcp->tagName() << endl;
#endif
KstObject::UpdateType ut = bcp->update(_updateCounter);
bcp->unlock();
if (ut == KstObject::UPDATE) { // HACK
_updatedCurves.append(bcp);
}
if (U != KstObject::UPDATE) {
U = ut;
if (U == KstObject::UPDATE) {
#if UPDATEDEBUG > 0
qDebug() << "Curve " << bcp->tagName() << " said UPDATE" << endl;
#endif
}
}
if (_done || (_paused && !force)) {
#if UPDATEDEBUG > 1
qDebug() << "5 Returning from scan with U=" << (int)U << endl;
#endif
return U == KstObject::UPDATE;
}
}
// Update all data objects
for (uint i = 0; i < dol.count(); ++i) {
KstDataObjectPtr dp = dol[i];
dp->writeLock();
assert(dp.data());
#if UPDATEDEBUG > 1
qDebug() << "updating data object: " << (void*)dp << " - " << dp->tagName() << endl;
#endif
dp->update(_updateCounter);
dp->unlock();
if (_done || (_paused && !force)) {
#if UPDATEDEBUG > 1
qDebug() << "5 Returning from scan with U=" << (int)U << endl;
#endif
return U == KstObject::UPDATE;
}
}
}
// Update the files
if (!_paused) { // don't update even if paused && force
KST::dataSourceList.lock().readLock();
unsigned cnt = KST::dataSourceList.count();
for (uint i = 0; i < cnt; ++i) {
KstDataSourcePtr dsp = KST::dataSourceList[i];
dsp->writeLock();
dsp->update(_updateCounter);
dsp->unlock();
if (_done) {
KST::dataSourceList.lock().unlock();
return false;
}
}
//.........这里部分代码省略.........
示例2: update
KstObject::UpdateType KstCPlugin::update(int update_counter) {
Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
if (!isValid()) {
return setLastUpdateResult(NO_CHANGE);
}
if (recursed()) {
return setLastUpdateResult(NO_CHANGE);
}
bool force = dirty();
setDirty(false);
if (KstObject::checkUpdateCounter(update_counter) && !force) {
return lastUpdateResult();
}
#define CLEANUP() do {\
for (unsigned i = 0; i < _outStringCnt; ++i) { \
if (_outStrings[i]) { \
free(_outStrings[i]); \
_outStrings[i] = 0L; \
} \
} \
for (unsigned i = 0; i < _inStringCnt; ++i) { \
if (_inStrings[i]) { \
free(_inStrings[i]); \
_inStrings[i] = 0L; \
} \
} \
} while(0)
writeLockInputsAndOutputs();
const QValueList<Plugin::Data::IOValue>& itable = _plugin->data()._inputs;
const QValueList<Plugin::Data::IOValue>& otable = _plugin->data()._outputs;
int itcnt = 0, vitcnt = 0, sitcnt = 0;
bool doUpdate = force;
// Populate the input scalars and vectors
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) {
if (!_inputVectors.contains((*it)._name)) {
KstDebug::self()->log(i18n("Input vector [%1] for plugin %2 not found. Unable to continue.").arg((*it)._name).arg(tagName()), KstDebug::Error);
CLEANUP();
return setLastUpdateResult(NO_CHANGE);
}
KstVectorPtr iv = _inputVectors[(*it)._name];
if (!iv) {
kstdFatal() << "Input vector \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
}
doUpdate = (UPDATE == iv->update(update_counter)) || doUpdate;
_inVectors[vitcnt] = iv->value();
_inArrayLens[vitcnt++] = iv->length();
} else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
KstScalarPtr is = _inputScalars[(*it)._name];
if (!is) {
kstdFatal() << "Input scalar \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
}
doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
_inScalars[itcnt++] = is->value();
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
KstStringPtr is = _inputStrings[(*it)._name];
if (!is) {
kstdFatal() << "Input string \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
}
doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
// Maybe we should use UTF-8 instead?
_inStrings[sitcnt++] = strdup(is->value().latin1());
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
_inScalars[itcnt++] = getpid();
}
}
if (!doUpdate) {
CLEANUP();
unlockInputsAndOutputs();
return setLastUpdateResult(NO_CHANGE);
}
vitcnt = 0;
// Populate the output vectors
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin();
it != otable.end();
++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) {
if (!_outputVectors.contains((*it)._name)) {
KstDebug::self()->log(i18n("Output vector [%1] for plugin %2 not found. Unable to continue.").arg((*it)._name).arg(tagName()), KstDebug::Error);
CLEANUP();
unlockInputsAndOutputs();
return setLastUpdateResult(NO_CHANGE);
}
_outVectors[vitcnt] = _outputVectors[(*it)._name]->value();
_outArrayLens[vitcnt++] = _outputVectors[(*it)._name]->length();
}
}
if (_outStringCnt > 0) {
//.........这里部分代码省略.........