当前位置: 首页>>代码示例>>C++>>正文


C++ SoType::isBad方法代码示例

本文整理汇总了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;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:28,代码来源:SoType.cpp

示例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
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:29,代码来源:SoAction.cpp

示例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;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:46,代码来源:SoForeignFileKit.cpp

示例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;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:38,代码来源:SoAction.cpp


注:本文中的SoType::isBad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。