本文整理汇总了C++中KstDataSourcePtr::writeLock方法的典型用法代码示例。如果您正苦于以下问题:C++ KstDataSourcePtr::writeLock方法的具体用法?C++ KstDataSourcePtr::writeLock怎么用?C++ KstDataSourcePtr::writeLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstDataSourcePtr
的用法示例。
在下文中一共展示了KstDataSourcePtr::writeLock方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frameCount
KJS::Value KstBindDataSource::frameCount(KJS::ExecState *exec, const KJS::List& args) {
QString field;
if (args.size() == 1) {
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Number(0);
}
field = args[0].toString(exec).qstring();
} else if (args.size() != 0) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires at most one argument.");
exec->setException(eobj);
return KJS::Number(0);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Number(0);
}
s->writeLock();
int rc = s->frameCount(field);
s->unlock();
return KJS::Number(rc);
}
示例2: samplesPerFrame
KJS::Value KstBindDataSource::samplesPerFrame(KJS::ExecState *exec, const KJS::List& args) {
if (args.size() != 1) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
exec->setException(eobj);
return KJS::Number(0);
}
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Number(0);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Number(0);
}
s->writeLock();
int rc = s->samplesPerFrame(args[0].toString(exec).qstring());
s->unlock();
return KJS::Number(rc);
}
示例3: isValidField
KJS::Value KstBindDataSource::isValidField(KJS::ExecState *exec, const KJS::List& args) {
if (args.size() != 1) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
exec->setException(eobj);
return KJS::Boolean(false);
}
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Boolean(false);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Boolean(false);
}
s->writeLock();
bool rc = s->isValidField(args[0].toString(exec).qstring());
s->unlock();
return KJS::Boolean(rc);
}
示例4: loadMatrix
QString KstIfaceImpl::loadMatrix(const QString& name, const QString& file, const QString& field,
int xStart, int yStart, int xNumSteps, int yNumSteps,
int skipFrames, bool boxcarFilter) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
if (src->isEmpty()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().unlock();
// make sure field is valid
if (!src->isValidMatrix(field)) {
src->unlock();
return QString::null;
}
// make sure name is unique, else generate a unique one
KST::matrixList.lock().readLock();
QString matrixName;
if (name.isEmpty()) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
} else {
matrixName = name;
}
while (KstData::self()->matrixTagNameNotUnique(matrixName, false)) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
}
KST::matrixList.lock().unlock();
KstMatrixPtr p = new KstRMatrix(src, field, matrixName, xStart, yStart, xNumSteps, yNumSteps,
boxcarFilter, skipFrames > 0, skipFrames);
KST::addMatrixToList(p);
src->unlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}
示例5: sourceChanged
void KstChangeFileDialog::sourceChanged(const QString& text)
{
delete _configWidget;
_configWidget = 0L;
_configureSource->setEnabled(false);
_file = QString::null;
if (!text.isEmpty() && text != "stdin" && text != "-") {
KUrl url;
QString txt = _dataFile->completionObject()->replacedPath(text);
if (QFile::exists(txt) && QFileInfo(txt).isRelative()) {
url.setPath(txt);
} else {
url = KUrl::fromPathOrURL(txt);
}
if (!url.isLocalFile() && url.protocol() != "file" && !url.protocol().isEmpty()) {
_fileType->setText(QString::null);
return;
}
if (!url.isValid()) {
_fileType->setText(QString::null);
return;
}
QString file = txt;
KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(file);
QStringList fl;
QString fileType;
if (ds) {
ds->readLock();
fl = ds->fieldList();
fileType = ds->fileType();
ds->unlock();
ds = 0L;
} else {
bool complete = false;
fl = KstDataSource::fieldListForSource(file, QString::null, &fileType, &complete);
}
if (!fl.isEmpty() && !fileType.isEmpty()) {
if (ds) {
ds->writeLock();
_configWidget = ds->configWidget();
ds->unlock();
} else {
_configWidget = KstDataSource::configWidgetForSource(file, fileType);
}
}
_configureSource->setEnabled(_configWidget);
_file = file;
_fileType->setText(fileType.isEmpty() ? QString::null : tr("Data source of type: %1").arg(fileType));
} else {
_fileType->setText(QString::null);
}
}
示例6: changeDataFile
bool KstIfaceImpl::changeDataFile(const QString& vector, const QString& fileName, bool update) {
KST::vectorList.lock().readLock();
KstRVectorPtr rvp = kst_cast<KstRVector>(*KST::vectorList.findTag(vector));
KST::vectorList.lock().unlock();
if (!rvp) {
return false;
}
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(fileName);
KstDataSourcePtr file;
QString invalidSources;
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(fileName);
if (!file || !file->isValid() || file->isEmpty()) {
KST::dataSourceList.lock().unlock();
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
rvp->writeLock();
file->writeLock();
if (!file->isValidField(vector)) {
file->unlock();
rvp->unlock();
return false;
}
rvp->changeFile(file);
file->unlock();
bool rc = rvp->isValid();
rvp->unlock();
if (update) {
KstApp::inst()->forceUpdate();
}
return rc;
}
示例7: while
const QString& KstIfaceImpl::loadVector(const QString& file, const QString& field) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
if (src->isEmpty()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().unlock();
KST::vectorList.lock().readLock();
QString vname = "V" + QString::number(KST::vectorList.count() + 1);
while (KstData::self()->vectorTagNameNotUnique(vname, false)) {
vname = "V" + QString::number(KST::vectorList.count() + 1);
}
KST::vectorList.lock().unlock();
KstVectorPtr p = new KstRVector(src, field, vname, 0, -1, 0, false, false);
KST::addVectorToList(p);
src->unlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}
示例8: changeFile
KJS::Value KstBindDataVector::changeFile(KJS::ExecState *exec, const KJS::List& args) {
KstRVectorPtr v = makeDataVector(_d);
if (!v) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Undefined();
}
if (args.size() != 1) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
exec->setException(eobj);
return KJS::Undefined();
}
if (args[0].type() != KJS::ObjectType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Undefined();
}
KstBindDataSource *imp = dynamic_cast<KstBindDataSource*>(args[0].toObject(exec).imp());
if (!imp) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Undefined();
}
#define makeSource(X) dynamic_cast<KstDataSource*>(const_cast<KstObject*>(X.data()))
KstDataSourcePtr s = makeSource(imp->_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Undefined();
}
v->writeLock();
s->writeLock();
v->changeFile(s);
s->writeUnlock();
v->writeUnlock();
#undef makeSource
return KJS::Undefined();
}
示例9: 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;
}
}
//.........这里部分代码省略.........
示例10: editSingleObjectRV
bool KstVectorDialogI::editSingleObjectRV(KstVectorPtr vcPtr) {
KstRVectorPtr rvp = kst_cast<KstRVector>(vcPtr);
KstDataSourcePtr file;
if (_fileNameDirty) {
// if there is not an active KstFile, create one
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_w->FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_w->FileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file could not be opened."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
} else {
KstRVectorList vcList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (uint i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
if (_editMultipleWidget->_objectList->isSelected(i)) {
// get the pointer to the object
KstRVectorList::Iterator vcIter = vcList.findTag(_editMultipleWidget->_objectList->text(i));
if (vcIter == vcList.end()) {
return false;
}
KstRVectorPtr rvp = *vcIter;
rvp->readLock();
file = rvp->dataSource();
rvp->unlock();
}
}
}
file->writeLock();
if (rvp) {
QString pField;
if (_fileNameDirty) {
pField = _w->Field->currentText();
if (!file->isValidField(pField)) {
KMessageBox::sorry(this, i18n("The requested field is not defined for the requested file."));
file->unlock();
return false;
}
} else {
pField = rvp->field();
}
int f0 = 0, n = 0;
if (_f0Dirty) {
if (_w->_kstDataRange->isStartRelativeTime()) {
f0 = file->sampleForTime(_w->_kstDataRange->f0Value());
} else if (_w->_kstDataRange->isStartAbsoluteTime()) {
bool ok = false;
f0 = file->sampleForTime(_w->_kstDataRange->f0DateTimeValue(), &ok);
if (!ok) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field or file could not use the specified date."));
return false;
}
} else {
f0 = int(_w->_kstDataRange->f0Value());
}
}
if (_nDirty) {
if (_w->_kstDataRange->isRangeRelativeTime()) {
double nValStored = _w->_kstDataRange->nValue();
if (_w->_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = file->frameCount(_w->Field->currentText());
double msCount = file->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - file->sampleForTime(msCount - nValStored);
} else {
double fTime = file->relativeTimeForSample(f0);
n = file->sampleForTime(fTime + nValStored) - file->sampleForTime(fTime);
}
} else {
n = int(_w->_kstDataRange->nValue());
}
}
// use existing requested start and number of frames if not dirty
rvp->readLock();
if (!_f0Dirty) {
f0 = rvp->reqStartFrame();
}
if (!_nDirty) {
n = rvp->reqNumFrames();
}
// other parameters for multiple edit
bool pCountFromEnd, pReadToEnd, pDoSkip, pDoFilter;
int pSkip;
//.........这里部分代码省略.........