本文整理汇总了C++中SoType::isBad方法的典型用法代码示例。如果您正苦于以下问题:C++ SoType::isBad方法的具体用法?C++ SoType::isBad怎么用?C++ SoType::isBad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoType
的用法示例。
在下文中一共展示了SoType::isBad方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
SbBool
SoType::isDerivedFrom(const SoType parent) const
{
assert(!this->isBad());
if (parent.isBad()) {
#if COIN_DEBUG
SoDebugError::postWarning("SoType::isDerivedFrom",
"can't compare type '%s' against an invalid type",
this->getName().getString());
#endif // COIN_DEBUG
return FALSE;
}
SoType type = *this;
do {
#if COIN_DEBUG && 0 // debug
SoDebugError::postInfo("SoType::isDerivedFrom",
"this: '%s' parent: '%s'",
type.getName().getString(),
parent.getName().getString());
#endif // debug
if (type == parent) return TRUE;
type = (*SoType::typedatalist)[(int)type.getKey()]->parent;
} while (!type.isBad());
return FALSE;
}
示例2: if
void
SoEnabledElementsList::enable(SoType elementType, int stackIndex)
//
////////////////////////////////////////////////////////////////////////
{
SoType prev = elements[stackIndex];
// If not enabled before or if enabled before but we are now
// enabling a more-specific subclass, add the element.
if (prev.isBad() ||
(elementType != prev && elementType.isDerivedFrom(prev))) {
elements.set(stackIndex, elementType);
// Increment global counter to indicate that lists have changed
counter++;
}
#ifdef DEBUG
// If we aren't enabling a more general super-class (and therefore
// don't need to do anything), error:
else if (! prev.isDerivedFrom(elementType)) {
const char *eltName = elementType.getName().getString();
SoDebugError::post("SoAction::enableElement",
"Cannot enable element %s because element %s "
"is already enabled",
eltName, prev.getName().getString());
}
#endif
}
示例3: ext
/*!
Creates an instance of a suitable SoForeignFileKit subtype.
Returns NULL on failure or a kit with refcount of 1 on success.
*/
static SoForeignFileKit *create_foreignfilekit(const char *filename, SbBool exhaust)
{
assert(SoForeignFileKitP::fileexts != NULL);
const char * extptr = strrchr(filename, '.');
if (extptr) {
extptr++;
SbName ext(SbString(extptr).lower());
SoType handler = SoType::badType();
if (SoForeignFileKitP::fileexts->get(ext.getString(), handler)) {
SoForeignFileKit * foreignfile = (SoForeignFileKit *)handler.createInstance();
foreignfile->ref();
if (foreignfile->canReadFile(filename)) {
return foreignfile;
}
else {
foreignfile->unref();
}
}
else {
// We try to synthesize a classname from the extension (e.g. SoFBXFileKit),
// and load it using the SoType autoloader feature.
SbString filekitname;
filekitname.sprintf("So%sFileKit", SbString(ext.getString()).upper().getString());
SoType filekittype = SoType::fromName(SbName(filekitname));
if (!filekittype.isBad()) return create_foreignfilekit(filename, exhaust);
// FIXME: Some filekits supports more than one file format/extension (e.g. FBX).
// We need a way of mapping extensions to library, or a way of loading
// each external kit and testing for support.
// FIXME: Temporary hack: Load SoFBXFileKit
filekitname = "SoFBXFileKit";
filekittype = SoType::fromName(SbName(filekitname));
if (!filekittype.isBad()) return create_foreignfilekit(filename, exhaust);
}
}
if (exhaust) {
// FIXME: Implement
// SoForeignFileKitP::fileexts->apply()
}
return NULL;
}
示例4:
const SoTypeList &
SoEnabledElementsList::getElements() const
//
////////////////////////////////////////////////////////////////////////
{
// Cast const away
SoEnabledElementsList *This = (SoEnabledElementsList *)this;
// We only need to merge with our parent's list if some element
// has been enabled since the last time we merged.
if (setUpCounter != counter) {
// We may enable new things here which could increment the
// enabled elements counter. But all of these elements were already
// enabled once by the parent class. So we'll store the counter
// now and restore it after this loop...
This->setUpCounter = counter;
SoEnabledElementsList *parentList = parent;
while (parentList) {
int i;
SoType t;
for (i = 0; i < parentList->elements.getLength(); i++) {
t = parentList->elements[i];
if (! t.isBad())
This->enable(t, i);
}
parentList = parentList->parent;
}
// restore the counter...
counter = This->setUpCounter;
}
return elements;
}