const double* LinkedObj::getDoublePtr( const QString &nm, int *lt, const LinkedObj **targ, int lev ) const { static int clt; int *plt = lt ? lt : &clt; if( nm.isEmpty() ) { *plt = LinkNone; return nullptr; } if( isIgnored() ) { *plt = LinkBad; return nullptr; } QString nmf = nm, first, rest; int idx; NameType nm_type = splitName( nmf, first, rest, idx ); if( nm_type == badName ) { *plt = LinkBad; qWarning() << "bad source name " << nmf << NWHE; return nullptr; } HolderData *ho = getObj( first ); if( !ho ) { *plt = LinkBad; // qWarning() << "elem" << first << "not found, nmf= " << nmf << NWHE; return nullptr; } if( nm_type == simpleName ) { // -- simple name ----- first only ----- LinkedObj *ds= qobject_cast<LinkedObj*>(ho); if( ds ) { return ds->getDoublePtr( QSL("out0"), plt, targ, lev+1 ); // default output } HolderDouble *hod = qobject_cast<HolderDouble*>(ho); if( hod ) { *plt = ( lev == 1 ) ? LinkElm : LinkSpec; if( targ ) { *targ = this; } return hod->caddr(); } auto *hoda = qobject_cast<HolderDoubleArray*>(ho); // array special case if( hoda ) { int na = hoda->arrSize(); if( idx >= na ) { qWarning() << "Bad index " << idx << " while access to " << hoda->getFullName() << " size " << na << NWHE; *plt = LinkBad; return nullptr; } *plt = ( lev == 1 ) ? LinkElm : LinkSpec; if( targ ) { *targ = this; } return & ( hoda->operator[](idx) ); } return nullptr; } // -------------------- simple name end ---------------------------- // both part of name exists LinkedObj *ds = qobject_cast<LinkedObj*>(ho); if( !ds ) { *plt = LinkBad; qWarning() << "Complex name " << nm << " is given for simple object " << ho->getFullName() << NWHE; return nullptr; } return ds->getDoublePtr( rest, plt, targ, lev+1 ); // pass to child }