void test_inserting_node_at_depth_two(){ Tree tree = createTree(cmpInt); void * element; Iterator it; int element1 = 10,element2 = 20,element3 = 30,element4 = 40; insertTreeNode(&tree,NULL,&element1); insertTreeNode(&tree,&element1,&element2); insertTreeNode(&tree,&element2,&element3); insertTreeNode(&tree,&element2,&element4); it = getChildren(&tree,&element2); ASSERT(element4 == *(int*)it.next(&it)); ASSERT(element3 == *(int*)it.next(&it)); disposeTree(&tree); };
void AdvisorsWindow::showAdvisor( const AdvisorType type ) { if( type >= ADV_COUNT ) return; Widget::Widgets children = getChildren(); foreach( Widget* child, children ) { if( PushButton* btn = safety_cast< PushButton* >( child ) ) { btn->setPressed( btn->getID() == type ); } } if( _d->advisorPanel ) { _d->advisorPanel->deleteLater(); _d->advisorPanel = 0; } switch( type ) { case ADV_EMPLOYERS: _d->advisorPanel = new AdvisorEmployerWindow( _d->city, this, ADV_EMPLOYERS ); break; case ADV_LEGION: _d->advisorPanel = new AdvisorLegionWindow( this, ADV_LEGION ); break; case ADV_EMPIRE: { AdvisorEmperorWindow* wnd = new AdvisorEmperorWindow( this, _d->city->getPlayer()->getMoney(), ADV_EMPIRE ); _d->advisorPanel = wnd; CONNECT( wnd, onSendMoney(), _d.data(), Impl::sendMoney2City ); } break; case ADV_RATINGS: _d->advisorPanel = new AdvisorRatingsWindow( this, ADV_RATINGS, _d->city ); break; case ADV_TRADING: { AdvisorTradeWindow* wnd = new AdvisorTradeWindow( _d->city, this, ADV_TRADING ); _d->advisorPanel = wnd; CONNECT( wnd, onEmpireMapRequest(), _d.data(), Impl::showEmpireMapWindow ); } break; case ADV_EDUCATION: _d->advisorPanel = new AdvisorEducationWindow( _d->city, this, -1 ); break; case ADV_HEALTH: _d->advisorPanel = new AdvisorHealthWindow( _d->city, this, -1 ); break; case ADV_ENTERTAINMENT: _d->advisorPanel = new AdvisorEntertainmentWindow( _d->city, this, -1 ); break; case ADV_RELIGION: _d->advisorPanel = new AdvisorReligionWindow( _d->city, this, -1 ); break; case ADV_FINANCE: _d->advisorPanel = new AdvisorFinanceWindow( _d->city, this, -1 ); break; default: break; } }
void test_inserting_three_nodes_one_after_the_other(){ Tree tree = createTree(cmpInt); Iterator it; int element1 = 10,element2 = 20,element3 = 30,element4 = 40; insertTreeNode(&tree,NULL,&element1); insertTreeNode(&tree,&element1,&element2); insertTreeNode(&tree,&element1,&element3); insertTreeNode(&tree,&element1,&element4); it = getChildren(&tree,&element1); ASSERT(element4 == *(int*)it.next(&it)); ASSERT(element3 == *(int*)it.next(&it)); ASSERT(element2 == *(int*)it.next(&it)); disposeTree(&tree); };
void UIWidget::setBright(bool bright, bool containChild) { setBright(bright); if (containChild) { ccArray* childrenArray = getChildren()->data; int length = childrenArray->num; for (int i=0; i<length; ++i) { UIWidget* child = (UIWidget*)childrenArray->arr[i]; child->setBright(bright,containChild); } } }
void CX3DHAnimSiteNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); char *nodeName = getNodeName(); if (nodeName) { float x, y, z, rot; int i, n; CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); fprintf(fp, "children\n"); MFNode *nodes = getChildren(); n = nodes->count(); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); getCenter()->getValue(x, y, z); fprintf(fp, "center : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getRotation()->getValue(x, y, z, rot); fprintf(fp, "rotation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getScale()->getValue(x, y, z); fprintf(fp, "scale : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getScaleOrientation()->getValue(x, y, z, rot); fprintf(fp, "scaleOrientation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getTranslation()->getValue(x, y, z); fprintf(fp, "translation : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); fprintf(fp, "name (%s)\n", m_name.getValue()); } }
void ListBox::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Rect cpos = getChildrenBounds(); UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; cpos.h = child->getPreferredSize().h; child->setBounds(cpos); cpos.y += child->getBounds().h + this->childSpacing(); }
uint64_t N::getChildren(const N *node, uint8_t start, uint8_t end, std::tuple<uint8_t, N *> children[], uint32_t &childrenCount) { switch (node->getType()) { case NTypes::N4: { auto n = static_cast<const N4 *>(node); return n->getChildren(start, end, children, childrenCount); } case NTypes::N16: { auto n = static_cast<const N16 *>(node); return n->getChildren(start, end, children, childrenCount); } case NTypes::N48: { auto n = static_cast<const N48 *>(node); return n->getChildren(start, end, children, childrenCount); } case NTypes::N256: { auto n = static_cast<const N256 *>(node); return n->getChildren(start, end, children, childrenCount); } } assert(false); __builtin_unreachable(); }
void UIWidget::setTouchEnable(bool enabled, bool containChildren) { setTouchEnabled(enabled); if (containChildren) { ccArray* childrenArray = getChildren()->data; int length = childrenArray->num; for (int i=0; i<length; ++i) { UIWidget* child = (UIWidget*)childrenArray->arr[i]; child->setTouchEnable(enabled,true); } } }
static void loopOnChildCount(ClassRegister *cReg, char *cn, int *i, int ignprov) { UtilList *ul = getChildren(cReg,cn); char *child; _SFCB_ENTER(TRACE_PROVIDERS, "loopOnChildCount"); if (ul) for (child = (char *) ul->ft->getFirst(ul); child; child=(char*)ul->ft->getNext(ul)) { if (ignprov || repCandidate(cReg, child)) *i=(*i)+1; loopOnChildCount(cReg, child,i,ignprov); } _SFCB_EXIT(); }
std::string Node::getString() const { std::string toReturn; if ( isTextNode() ) { toReturn = text; } else if ( isCharacterData() ) { toReturn = "<![CDATA["; toReturn += text; toReturn += "]]>"; } else { toReturn = "<"; toReturn += name; for ( auto it = attributes.begin(); it != attributes.end(); ++it ) { toReturn += " "; toReturn += it->getString(); } if ( isSelfClosing() ) { toReturn += " />"; } else { toReturn += ">"; for ( auto it = children.begin(); it != children.end(); ++it ) { toReturn += "\r\n"; toReturn += ( * it )->getString(); } if ( getChildren().size() != 0 ) { toReturn += "\r\n"; } toReturn += "</"; toReturn += name; toReturn += ">"; } } return toReturn; }
void MultiDocumentPanel::componentNameChanged (Component&) { if (mode == FloatingWindows) { for (auto* child : getChildren()) if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) dw->setName (dw->getContentComponent()->getName()); } else if (tabComponent != nullptr) { for (int i = tabComponent->getNumTabs(); --i >= 0;) tabComponent->setTabName (i, tabComponent->getTabContentComponent (i)->getName()); } }
MenuItem* PopupMenu::getItem(const UInt32& Index) { if(Index < getMFChildren()->size()) { UInt32 ItemCount(0); for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { if(getChildren(i)->getType() != Separator::getClassType()) { if(ItemCount == Index) { break; } ++ItemCount; } } if(ItemCount < getMFChildren()->size()) { return dynamic_cast<MenuItem*>(getChildren(ItemCount)); } } return NULL; }
void PopupMenu::mouseDragged(const MouseEventUnrecPtr e) { UInt32 i(0); while (i<getMFChildren()->size() && !getChildren(i)->isContained(e->getLocation(), true)) { ++i; } if(i<getMFChildren()->size() && getSelectionModel()->getSelectedIndex() != i) { getSelectionModel()->setSelectedIndex(i); } ComponentContainer::mouseDragged(e); }
void VCWidgetSelection::updateWidgetsTree() { VCFrame *contents = VirtualConsole::instance()->contents(); m_widgetsList = getChildren(contents); foreach (QObject *object, m_widgetsList) { VCWidget *widget = qobject_cast<VCWidget *>(object); QTreeWidgetItem *item = new QTreeWidgetItem(m_tree); item->setText(KColumnName, widget->caption()); item->setIcon(KColumnName, VCWidget::typeToIcon(widget->type())); item->setText(KColumnType, VCWidget::typeToString(widget->type())); }
void test_removing_node_from_depth_two(){ Iterator it; Tree tree = createTree(cmpInt); int element1 = 10,element2 = 20,element3 = 30,element4 = 40; insertTreeNode(&tree,NULL,&element1); insertTreeNode(&tree,&element1,&element2); insertTreeNode(&tree,&element2,&element3); insertTreeNode(&tree,&element2,&element4); ASSERT(1 == removeTreeNode(&tree,&element3)); it = getChildren(&tree,&element2); ASSERT(element4 == *(int*)it.next(&it)); ASSERT(NULL == it.next(&it)); disposeTree(&tree); };
void IncludeComponent::loadChildren(const string& sourcePath) { //build the view on a clean new root for safety auto root = make_shared<Component>(); /* add it as a temporary child so elements built from this component * properly behave as children */ link(getSelf(), root); auto includeFile = requestContext().getResourceResolver()->getResource( sourcePath); auto view = requestContext().getView(); Component::load(*includeFile, sourcePath, root, nullptr); if (root->getChildren().size() == 1) { /*the expected format for an include is a single outer root *component (ie <html>) with namespace declarations that is *removed after the view is built. in effect, all children of the *root in the included document become children of the <include> *tag*/ auto docRoot = *root->getChildren().begin(); /*getChildren().assign(docRoot->getChildren().begin(), docRoot->getChildren().end());*/ getChildren().clear(); auto newChildren = docRoot->getChildren(); for (auto newChild : newChildren) { link(getParent(), newChild); } } else { //is this check necessary? would libxml even load the document? throw IllegalStateException("Included document must not contain" " more than one root element"); } }
static CMPIStatus ClassProviderDeleteClass(CMPIClassMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop) { ClassRegister *cReg; CMPIConstClass *cl; int rc; CMPIStatus st = { CMPI_RC_OK, NULL }; _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderDeleteClass"); cReg = getNsReg(cop, &rc); if (cReg == NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; _SFCB_RETURN(st); } char *cn = (char *) cop->ft->getClassName(cop, NULL)->hdl; cl = getClass(cReg, cn); if (cl == NULL) { st.rc = CMPI_RC_ERR_NOT_FOUND; _SFCB_RETURN(st); } UtilList *ul = getChildren(cReg, cn); if (ul && ul->ft->size(ul)) { // char *child; // for (child =(char*)ul->ft->getFirst(ul); child; // child=(char*)ul->ft->getNext(ul)) // printf("child: %s\n",child); st.rc = CMPI_RC_ERR_CLASS_HAS_CHILDREN; _SFCB_RETURN(st); } char *pn = (char *) cl->ft->getCharSuperClassName(cl); cReg->ft->wLock(cReg); if (pn) removeChild(cReg, pn, cn); removeClass(cReg, cn); cReg->ft->wUnLock(cReg); _SFCB_RETURN(st); }
HRootLayer *HUILayer::findWithClass(const std::string &className) { CCArray *children = getChildren(); int count = children->count(); int i = 0; for (i = 0; i < count; ++i) { HRootLayer *layer = (HRootLayer *)children->objectAtIndex(i); if (layer->isKindOf(className)) return layer; } count = m_pQueneRootLayers->count(); for (i = 0; i < count; ++i) { HRootLayer *layer = (HRootLayer *)m_pQueneRootLayers->objectAtIndex(i); if (layer->isKindOf(className)) return layer; } return NULL; }
void SchedulerUpdate::removeUpdates(ccTime dt) { CCArray* children = getChildren(); CCNode* pNode; CCObject* pObject; CCARRAY_FOREACH(children, pObject) { pNode = (CCNode*)pObject; if (! pNode) { break; } pNode->unscheduleAllSelectors(); }
_TDL_TreeNode * _TDL_TreeNodeBranch::getChildWithArrayIndex ( int4 theArrayIndex ) const { _TDL_Dnode * child; for ( child = getChildren() -> getFirstNode(); child != (_TDL_Dnode *) NULL; child = child -> getNextNode() ) { if ( theArrayIndex == ((_TDL_TreeNode *) child) -> getArrayIndex() ) return (_TDL_TreeNode *) child; } return (_TDL_TreeNode *) NULL; }
unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element) { if (!ATK_IS_OBJECT(m_element.get())) return 0; Vector<RefPtr<AccessibilityUIElement> > children; getChildren(children); unsigned count = children.size(); for (unsigned i = 0; i < count; i++) if (children[i]->isEqual(element)) return i; return 0; }
void GUIFileSelectMenu::removeChildren() { const core::list<gui::IGUIElement*> &children = getChildren(); core::list<gui::IGUIElement*> children_copy; for (core::list<gui::IGUIElement*>::ConstIterator i = children.begin(); i != children.end(); i++) { children_copy.push_back(*i); } for (core::list<gui::IGUIElement*>::Iterator i = children_copy.begin(); i != children_copy.end(); i++) { (*i)->remove(); } }
void View::update() { if(_transform.update(_frame, _anchor, _rotation, _scale)) { _inverseDirty = true; _rootTransformDirty = true; _rootInverseDirty = true; getRootTransform(); for(Child& child : getChildren()) { child.first->parentTransformChanged(); } } BaseView::update(); }
void PopupMenu::removeAllItems(void) { std::deque<UInt32> RemoveIndecies; for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { if(getChildren(i)->getType() != Separator::getClassType()) { RemoveIndecies.push_front(i); } } for(UInt32 i(0) ; i<RemoveIndecies.size() ; ++i) { removeItem(RemoveIndecies[i]); } }
AABB Sprite3D::getAABBRecursively() { AABB aabb; const auto children = getChildren(); for (const auto iter: children) { Sprite3D* child = dynamic_cast<Sprite3D*>(iter); if(child) { aabb.merge(child->getAABBRecursively()); } } aabb.merge(getAABB()); return aabb; }
vector< shared_ptr<MediaHolder> > LibraryManager::getMedia(shared_ptr<Ontology> _ont){ vector< shared_ptr<StoreObject> > & vc = getChildren(_ont); vector< shared_ptr<MediaHolder> > c; for (int i=0; i<vc.size(); i++) { if( vc[i]->getType()=="media" || vc[i]->getType()=="clip" || vc[i]->getType()=="sample" || vc[i]->getType()=="text" ) c.push_back(dynamic_pointer_cast<MediaHolder>(vc[i])); } return c; }
void StGLSwitchTextured::stglDraw(unsigned int theView) { if(!isVisible()) { return; } int32_t anActiveValue = myTrackValue->getValue(); StGLRadioButtonTextured* aRadioBtn = NULL; for(StGLWidget* aChild = getChildren()->getStart(); aChild != NULL;) { /// TODO (Kirill Gavrilov#9) - adding children with another type is not allowed /// hovewer not protected thus this cast is not thread-safe! aRadioBtn = (StGLRadioButtonTextured* )aChild; aChild = aChild->getNext(); // show only active item if(anActiveValue == aRadioBtn->getValueOn()) { aRadioBtn->stglDraw(theView); return; } } // show first item anyway StGLWidget* aChild = getChildren()->getStart(); if(aChild != NULL) { aChild->stglDraw(theView); } }
void Toolbar::removeAllSeparators(void) { std::deque<UInt32> RemoveIndecies; for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { if(getChildren(i)->getType() == Separator::getClassType()) { RemoveIndecies.push_front(i); } } for(UInt32 i(0) ; i<RemoveIndecies.size() ; ++i) { removeSeparator(RemoveIndecies[i]); } }
void Parallel::onFailure(Behavior* behavior) { // Clear the corresponding flags for the behavior. const uint32_t idx = indexOf(behavior); const bool wasFailed = anyChildrenFailed(); mCodes[idx] = ReturnCodeFailure; if(!wasFailed) { // End all remaining, active parallel tasks. for(std::vector<Behavior*>::const_iterator it = getChildren().begin(); it != getChildren().end(); ++it) { if((*it)->getStatus() == StatusRunning || (*it)->getStatus() == StatusWaiting) { (*it)->terminate(); } } // Signal the failure of this node to the parent node. notifyFailure(); } }
void Toolbar::setOrientation(BoxLayout::Orientation TheOrientation) { dynamic_cast<BoxLayout*>(getLayout())->setOrientation(TheOrientation); Separator::Orientation Or; if(TheOrientation == BoxLayout::VERTICAL_ORIENTATION) { Or = Separator::HORIZONTAL_ORIENTATION; } else { Or = Separator::VERTICAL_ORIENTATION; } for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { if(getChildren(i)->getType() == Separator::getClassType()) { dynamic_cast<Separator*>(getChildren(i))->setOrientation(Or); } } updateSeparatorSizes(); }