本文整理汇总了C++中DataRef::name方法的典型用法代码示例。如果您正苦于以下问题:C++ DataRef::name方法的具体用法?C++ DataRef::name怎么用?C++ DataRef::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataRef
的用法示例。
在下文中一共展示了DataRef::name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readClient
void TcpClient::readClient() {
while(_socket->canReadLine()) {
QByteArray lineBA = _socket->readLine();
QString line = QString(lineBA).trimmed();
DEBUG << "Client says: " << line;
// Split the command in strings
QStringList subLine = line.split(" ", QString::SkipEmptyParts);
QString command = subLine.value(0);
if(command == "disconnect") {
DEBUG << "killing this client connection";
deleteLater();
} else if(command == "sub") { // Subscribe command
if(subLine.length() >= 2) {
QString refName = subLine[1].trimmed();
double accuracy = 0;
if(subLine.length() >=3)
accuracy = subLine[2].toDouble();
DataRef *ref = getSubscribedRef(refName);
if(!ref) { // Ref not subscribed yet, try to subscribe
ref = _refProvider->subscribeRef(refName);
if(ref) { // Succesfully subscribed
connect(ref, SIGNAL(changed(DataRef*)), this, SLOT(refChanged(DataRef*)));
_subscribedRefs.insert(ref);
ref->setAccuracy(accuracy);
//TODO: why is ref->updateValue() not sufficient here?
if(ref->type() == xplmType_Float) {
_refValueF[ref] = qobject_cast<FloatDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Int) {
_refValueI[ref] = qobject_cast<IntDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Double) {
_refValueD[ref] = qobject_cast<DoubleDataRef*>(ref)->value();
} else if(ref->type() == xplmType_FloatArray) {
_refValueFA[ref] = qobject_cast<FloatArrayDataRef*>(ref)->value();
} else if(ref->type() == xplmType_IntArray) {
_refValueIA[ref] = qobject_cast<IntArrayDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Data) {
_refValueB[ref] = qobject_cast<DataDataRef*>(ref)->value();
}
INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy << ", type " << ref->typeString();
} else {
INFO << "Ref not found" << refName;
}
} else { // Ref already subscribed - update accuracy
示例2: subscribeRef
DataRef* XPlanePlugin::subscribeRef(QString name) {
DEBUG << name;
// Search in list of already subscribed datarefs - if found return that
foreach(DataRef *ref, refs) {
if(ref->name()==name) {
DEBUG << "Already subscribed to " << name;
ref->setSubscribers(ref->subscribers() + 1);
return ref;
}
}
// Not yet subscribed - create a new dataref
XPLMDataRef ref = XPLMFindDataRef(name.toLatin1());
if(ref) {
XPLMDataTypeID refType = XPLMGetDataRefTypes(ref);
DataRef *dr = 0;
if(refType & xplmType_Double) {
dr = new DoubleDataRef(this, name, ref);
} else if(refType & xplmType_Float) {
dr = new FloatDataRef(this, name, ref);
} else if(refType & xplmType_Int) {
dr = new IntDataRef(this, name, ref);
} else if (refType & xplmType_FloatArray) {
dr = new FloatArrayDataRef(this, name, ref);
} else if (refType & xplmType_IntArray) {
dr = new IntArrayDataRef(this, name, ref);
} else if (refType & xplmType_Data) {
dr = new DataDataRef(this, name, ref);
}
if(dr) {
dr->setSubscribers(1);
dr->setWritable(XPLMCanWriteDataRef(ref) != 0);
DEBUG << "Subscribed to ref " << dr->name() << ", type: " << dr->typeString() << ", writable:" << dr->isWritable();
refs.append(dr);
return dr;
} else {
INFO << "Dataref type " << refType << "not supported";
}
} else {
INFO << "Can't find dataref " << name;
}
return 0;
}
示例3: readClient
void TcpClient::readClient() {
while(_socket->canReadLine()) {
QByteArray lineBA = _socket->readLine();
QString line = QString(lineBA);
qDebug() << Q_FUNC_INFO << "Client says: " << line;
QStringList subLine = line.split(" ", QString::SkipEmptyParts);
QString command = subLine.value(0);
if(command == "disconnect") {
deleteLater();
} else if(command == "sub") {
if(subLine.length() >= 2) {
QString refName = subLine[1].trimmed();
double accuracy = 0;
if(subLine.length() >=3)
accuracy = subLine[2].toDouble();
DataRef *ref = getSubscribedRef(refName);
if(!ref) {
ref = _refProvider->subscribeRef(refName);
if(ref) {
connect(ref, SIGNAL(changed(DataRef*)), this, SLOT(refChanged(DataRef*)));
_subscribedRefs.insert(ref);
_refAccuracy[ref] = accuracy;
if(ref->type() == xplmType_Float) {
_refValueF[ref] = qobject_cast<FloatDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Int) {
_refValueI[ref] = qobject_cast<IntDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Double) {
_refValueD[ref] = qobject_cast<DoubleDataRef*>(ref)->value();
}
qDebug() << Q_FUNC_INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy;
} else {
qDebug() << Q_FUNC_INFO << "Ref not found" << refName;
}
} else {