sttx::pointer transactionmaster::fetch (shamapitem::ref item,
        shamaptreenode::tntype type,
        bool checkdisk, std::uint32_t ucommitledger)
{
    sttx::pointer  txn;
    transaction::pointer            itx = getapp().getmastertransaction ().fetch (item->gettag (), false);

    if (!itx)
    {

        if (type == shamaptreenode::tntransaction_nm)
        {
            serializeriterator sit (item->peekserializer ());
            txn = std::make_shared<sttx> (std::ref (sit));
        }
        else if (type == shamaptreenode::tntransaction_md)
        {
            serializer s;
            int length;
            item->peekserializer ().getvl (s.moddata (), 0, length);
            serializeriterator sit (s);

            txn = std::make_shared<sttx> (std::ref (sit));
        }
    }
    else
    {
        if (ucommitledger)
            itx->setstatus (committed, ucommitledger);

        txn = itx->getstransaction ();
    }

    return txn;
}
Пример #2
0
QTodoListItemsSorter::QTodoListItemsSorter(QPtrList<QWidget>* _input,const QTodoSortCriteriaMap* sort_criterias)
{	//FIXME: not yet section ready
	//1. get sub lists
	//2. sort sub lists
	//3. connect to big list
	//4. return it

	input = _input;

	std::map<int,QTodoItemSortPtrList* > lists;

	QPtrListIterator<QWidget> it(*input);
	int sub_counter = 0;

	for(;it.current() || it.atFirst();++it)
	{
		if(QTodoItemSortPtrList* sub_list = getSubList(it))
		{
			lists[sub_counter] = sub_list;
			++sub_counter;
		}
	}

	for(std::map<int,QTodoItemSortPtrList* >::iterator it = lists.begin(); it != lists.end(); ++it)
	{
		(*it).second->setSortCriterias(sort_criterias);
		(*it).second->sort();
	}

	QPtrList<QWidget>* big_list = new QPtrList<QWidget>;
	for(std::map<int,QTodoItemSortPtrList* >::iterator it = lists.begin(); it != lists.end(); ++it)
	{
		if(!(*it).second->top_item)
		{
			QPtrListIterator<QTodoItem> sit(*(*it).second);
			for(; sit.current(); ++sit)
				big_list->append(sit.current());
		}
		else
		{
			int pos = big_list->find((*it).second->top_item)+1;
			QPtrListIterator<QTodoItem> sit(*(*it).second);
			sit.toLast();
			for(; sit.current(); --sit)
				big_list->insert(pos,sit.current());
		}
	}
	output = big_list;
}
Пример #3
0
 inline
 std::basic_istream<CharT, Traits>&
 operator>>(std::basic_istream<CharT, Traits>& is, time_duration& td)
 {
   boost::io::ios_flags_saver iflags(is);
   typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
   if (strm_sentry) {
     try {
       typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
       std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
       if(std::has_facet<time_input_facet>(is.getloc())) {
         std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, td);
       }
       else {
         time_input_facet* f = new time_input_facet();
         std::locale l = std::locale(is.getloc(), f);
         is.imbue(l);
         f->get(sit, str_end, is, td);
       }
     }
     catch(...) {
       std::ios_base::iostate exception_mask = is.exceptions();
       if(std::ios_base::failbit & exception_mask) {
         try { is.setstate(std::ios_base::failbit); }
         catch(std::ios_base::failure&) {}
         throw; // rethrow original exception
       }
       else {
         is.setstate(std::ios_base::failbit);
       }
     }
   }
   return is;
 }
Пример #4
0
 static type make(const View& src, int n) {
     typedef typename type::xy_locator                             locator_t;
     typedef typename type::x_iterator                            x_iterator_t;
     typedef typename iterator_adaptor_get_base<x_iterator_t>::type x_iterator_base_t;
     x_iterator_t sit(x_iterator_base_t(&(src(0,0)[n])),src.pixels().pixel_size());
     return type(src.dimensions(),locator_t(sit, src.pixels().row_size()));
 }
Пример #5
0
bool glStaticMovesRobot::demo ( )
{
    static int  move_number = 5;
    switch (move_number)
    {
        case 5 :    stand( );                                break;
        case 6 :    sit  ( );                                break;
        case 7 :    squat( 90 );                             break;
        case 8 :    one_knee_kneel(true);                    break;
        case 9 :    kneel( );                                break;

        case 10 :    arms_down_by_side  (  );               break;
        case 11 :    w_question         (  );               break;
        case 12 :    hands_on_hip       (  );               break;
        case 13 :    folded_arms        (  );               break;
        case 14 :    zombie_arms        (  );               break;
        case 15 :    arm_straight_up    ( true  );          break;
        case 16 :    arm_straight_up    ( false );          break;
        case 17 :    wave_1             ( true );           break;
        case 18 :    wave_2             ( true );           break;
        case 19 :    arm_stretched_to_side_left (  );       break;
        case 20 :    arm_stretched_to_side_right(  );       break;
        case 21 :    attention_1        (  );               break;
        case 22 :    attention_2        (  );               break;
        case 23 :    move_number = 1.;    return true;      break;
        default:    break;
    }
    move_number++;
    return false;
}
Пример #6
0
void KviRegisteredChannelDataBase::load(const QString &filename)
{
	KviConfigurationFile cfg(filename,KviConfigurationFile::Read);

	qDeleteAll(*m_pChannelDict);
	m_pChannelDict->clear();

	KviConfigurationFileIterator it(*(cfg.dict()));

	while(KviConfigurationFileGroup * d = it.current())
	{
		QString szMask = it.currentKey();
		QString szChan = KviQString::leftToLast(szMask,QChar('@'),false);
		KviQString::cutToLast(szMask,QChar('@'),true);
		KviRegisteredChannel * c = new KviRegisteredChannel(szChan,szMask);
		add(c);
		KviConfigurationFileGroupIterator sit(*d);
		while(QString * s = sit.current())
		{
			c->setProperty(sit.currentKey(),*s);
			++sit;
		}
		++it;
	}
}
Пример #7
0
std::shared_ptr<STTx const>
sterilize (STTx const& stx)
{
    Serializer s;
    stx.add(s);
    SerialIter sit(s.slice());
    return std::make_shared<STTx const>(std::ref(sit));
}
Пример #8
0
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, local_date_time& ldt)
{
    boost::io::ios_flags_saver iflags(is);
    typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
    if (strm_sentry) {
        try {
            typedef typename local_date_time::utc_time_type utc_time_type;
            typedef typename date_time::time_input_facet<utc_time_type, CharT> time_input_facet;

            // intermediate objects
            std::basic_string<CharT> tz_str;
            utc_time_type pt(not_a_date_time);

            std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
            if(std::has_facet<time_input_facet>(is.getloc())) {
                std::use_facet<time_input_facet>(is.getloc()).get_local_time(sit, str_end, is, pt, tz_str);
            }
            else {
                time_input_facet* f = new time_input_facet();
                std::locale l = std::locale(is.getloc(), f);
                is.imbue(l);
                f->get_local_time(sit, str_end, is, pt, tz_str);
            }
            if(tz_str.empty()) {
                time_zone_ptr null_ptr;
                // a null time_zone_ptr creates a local_date_time that is UTC
                ldt = local_date_time(pt, null_ptr);
            }
            else {
                time_zone_ptr tz_ptr(new posix_time_zone(date_time::convert_string_type<CharT,char>(tz_str)));
                // the "date & time" constructor expects the time label to *not* be utc.
                // a posix_tz_string also expects the time label to *not* be utc.
                ldt = local_date_time(pt.date(), pt.time_of_day(), tz_ptr, local_date_time::EXCEPTION_ON_ERROR);
            }
        }
        catch(...) {
            // mask tells us what exceptions are turned on
            std::ios_base::iostate exception_mask = is.exceptions();
            // if the user wants exceptions on failbit, we'll rethrow our
            // date_time exception & set the failbit
            if(std::ios_base::failbit & exception_mask) {
                try {
                    is.setstate(std::ios_base::failbit);
                }
                catch(std::ios_base::failure&) {} // ignore this one
                throw; // rethrow original exception
            }
            else {
                // if the user want's to fail quietly, we simply set the failbit
                is.setstate(std::ios_base::failbit);
            }

        }
    }
    return is;
}
Пример #9
0
stledgerentry::stledgerentry (
    const serializer& s, uint256 const& index)
    : stobject (sfledgerentry), mindex (index), mmutable (true)
{
    // we know 's' isn't going away
    serializeriterator sit (const_cast<serializer&> (s));
    set (sit);
    setsletype ();
}
Пример #10
0
void FermionBase::copySPOs(spo_set_type& spos)
{
  spo_set_type::const_iterator sit(spos.begin());
  while (sit != spos.end())
  {
    addSPO((*sit).first, (*sit).second);
    ++sit;
  }
}
Пример #11
0
void FermionBase::resetSPOs(ParticleSet& P)
{
  map<string, SPOSetBasePtr>::iterator sit(mySPOSet.begin());
  while (sit != mySPOSet.end())
  {
    (*sit).second->resetTargetParticleSet(P);
    ++sit;
  }
}
Пример #12
0
void PhotoDialog::resetComments()
{
    QSetIterator<PhotoCommentItem*> sit(mComments);
    //QLayout* l = ui->scrollAreaWidgetContents->layout();
    while(sit.hasNext())
    {
        PhotoCommentItem* item = sit.next();
        ui->verticalLayout->insertWidget(0,item);
    }
}
Пример #13
0
void FermionBase::cloneSPOs(const spo_set_type& spos, ParticleSet& tqp)
{
  spo_set_type::const_iterator sit(spos.begin());
  while (sit != spos.end())
  {
    SPOSetBasePtr spo = (*sit).second;
    addSPO((*sit).first, spo->makeClone());
    ++sit;
  }
}
Пример #14
0
 value_type
 dereference() const override
 {
     value_type result;
     {
         SerialIter sit(
             iter_->second.first->slice());
         result.first = std::make_shared<
             STTx const>(sit);
     }
     if (metadata_)
     {
         SerialIter sit(
             iter_->second.second->slice());
         result.second = std::make_shared<
             STObject const>(sit, sfMetadata);
     }
     return result;
 }
Пример #15
0
int eServiceFS::getServiceTypeForExtension(const std::string &str)
{
	for (std::map<int, std::list<std::string> >::iterator sit(m_additional_extensions.begin()); sit != m_additional_extensions.end(); ++sit)
	{
		for (std::list<std::string>::iterator eit(sit->second.begin()); eit != sit->second.end(); ++eit)
		{
			if (*eit == str)
				return sit->first;
		}
	}
	return -1;
}
Пример #16
0
int eServiceCenter::getServiceTypeForExtension(const char *str)
{
	for (std::map<int, std::list<std::string> >::iterator sit(extensions.begin()); sit != extensions.end(); ++sit)
	{
		for (std::list<std::string>::iterator eit(sit->second.begin()); eit != sit->second.end(); ++eit)
		{
			if (*eit == str)
				return sit->first;
		}
	}
	return -1;
}
Пример #17
0
void PhotoDialog::clearComments()
{
    //QLayout* l = ui->scrollAreaWidgetContents->layout();
    QSetIterator<PhotoCommentItem*> sit(mComments);
    while(sit.hasNext())
    {
        PhotoCommentItem* item = sit.next();
        ui->verticalLayout->removeWidget(item);
        item->setParent(NULL);
        delete item;
    }

    mComments.clear();
}
Пример #18
0
RESULT eServiceCenter::removeServiceFactory(int id)
{
	for (std::map<std::string, int>::iterator sit(extensions_r.begin()); sit != extensions_r.end(); )
	{
		if (sit->second == id)
		{
			extensions_r.erase(sit++);
		}
		else
		{
			++sit;
		}
	}
	handler.erase(id);
	return 0;
}
Пример #19
0
Transaction::pointer Transaction::sharedTransaction(const std::vector<unsigned char>&vucTransaction, bool bValidate)
{
	try
	{
		Serializer			s(vucTransaction);
		SerializerIterator	sit(s);

		SerializedTransaction::pointer	st	= boost::make_shared<SerializedTransaction>(boost::ref(sit));

		return boost::make_shared<Transaction>(st, bValidate);
	}
	catch (...)
	{
		Log(lsWARNING) << "Exception constructing transaction";
		return boost::shared_ptr<Transaction>();
	}
}
Пример #20
0
std::string
debugTostr (SHAMap const& set)
{
    std::stringstream ss;
    for (auto const& item : set)
    {
        try
        {
            SerialIter sit(item.slice());
            auto const tx = std::make_shared<
                STTx const>(sit);
            ss << debugTxstr(tx) << ", ";
        }
        catch(std::exception const&)
        {
            ss << "THRO, ";
        }
    }
    return ss.str();
}
Пример #21
0
 inline
 std::basic_istream<CharT, Traits>&
 operator>>(std::basic_istream<CharT, Traits>& is, ptime& pt)
 {
   boost::io::ios_flags_saver iflags(is);
   typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false); 
   if (strm_sentry) {
     try {
       typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
       
       std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
       if(std::has_facet<time_input_facet>(is.getloc())) {
         std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, pt);
       }
       else {
         time_input_facet* f = new time_input_facet();
         std::locale l = std::locale(is.getloc(), f);
         is.imbue(l);
         f->get(sit, str_end, is, pt);
       }
     }
     catch(...) { 
       // mask tells us what exceptions are turned on
       std::ios_base::iostate exception_mask = is.exceptions();
       // if the user wants exceptions on failbit, we'll rethrow our 
       // date_time exception & set the failbit
       if(std::ios_base::failbit & exception_mask) {
         try { is.setstate(std::ios_base::failbit); } 
         catch(std::ios_base::failure&) {} // ignore this one
         throw; // rethrow original exception
       }
       else {
         // if the user want's to fail quietly, we simply set the failbit
         is.setstate(std::ios_base::failbit); 
       } 
           
     }
   }
   return is;
 }
Пример #22
0
void
OMR::SymbolReference::setAliasedTo(TR_BitVector &bv, TR::SymbolReferenceTable *symRefTab, bool symmetric)
   {
   TR::Compilation *comp = symRefTab->comp();

   TR_ASSERT(_useDefAliases, "this symref doesn't have its own aliasing bitvector");
   if (!symmetric)
      {
      *_useDefAliases |= bv;
      }
   else
      {
      // we must process one by one to ensure symmetric aliasing
      TR_SymRefIterator sit(bv, symRefTab);
      for (TR::SymbolReference *symRef = sit.getNext();
            symRef;
            symRef = sit.getNext())
         {
         self()->setAliasedTo(symRef, true);
         }
      }
   }
Пример #23
0
std::pair<std::shared_ptr<
    STTx const>, std::shared_ptr<
        STObject const>>
deserializeTxPlusMeta (SHAMapItem const& item)
{
    std::pair<std::shared_ptr<
        STTx const>, std::shared_ptr<
            STObject const>> result;
    SerialIter sit(item.slice());
    {
        SerialIter s(sit.getSlice(
            sit.getVLDataLength()));
        result.first = std::make_shared<
            STTx const>(s);
    }
    {
        SerialIter s(sit.getSlice(
            sit.getVLDataLength()));
        result.second = std::make_shared<
            STObject const>(s, sfMetadata);
    }
    return result;
}
Пример #24
0
void LWF::ExecMovieCommand()
{
	if (m_movieCommands.empty())
		return;

	vector<int> deletes;
	int i = 0;

	MovieCommands::iterator
		it(m_movieCommands.begin()), itend(m_movieCommands.end());
	for (; it != itend; ++it) {
		bool available = true;
		Movie *movie = rootMovie.get();

		vector<string>::iterator
			sit(it->first.begin()), sitend(it->first.end());
		for (; sit != sitend; ++sit) {
			movie = movie->SearchMovieInstance(*sit);
			if (!movie) {
				available = false;
				break;
			}
		}
		if (available) {
			it->second(movie);
			deletes.push_back(i);
		}
		++i;
	}
	for (vector<int>::reverse_iterator rit = deletes.rbegin();
			rit != deletes.rend(); ++rit) {
		it = m_movieCommands.begin();
		advance(it, *rit);
		m_movieCommands.erase(it);
	}
}
Пример #25
0
void Task::run() {
    QTcpSocket socket;
    QString answerID,type,lang;
    socket.setSocketDescriptor(this->socketDescriptor);
    socket.waitForReadyRead();
    data=socket.readAll();
    dateTime = QDateTime::currentDateTime();
    QStringList params;
    QFile file;
    token=QUuid::createUuid().toString();
    token=token.left(token.size()-1);
    token=token.right(token.size()-1);
    conName=cdb.connectionName()+QString::number(id);
    {
        QSqlDatabase db=QSqlDatabase(QSqlDatabase::cloneDatabase(cdb,conName));
        db.open();
        QSqlQuery query(db);

        sc = engine.evaluate("(" + QString(data) + ")");
        QScriptValueIterator it(sc);
        while (it.hasNext()) {
            it.next();
            if (it.name()=="program")
            {
                program_id=it.value().toString();
                token=token+"-"+program_id;
                params<<program_id;
                if (!params.at(0).isNull()||!params.at(0).isEmpty())
                {
                    query.exec("INSERT INTO math.answer (an_user_id, an_token, an_complete,  an_start_date, an_cp_id) VALUES (0, '"+token+"', 0,  '"+dateTime.toString("yyyy-MM-dd hh:mm:ss")+"', '"+program_id+"');");
                    query.exec("SELECT @an_id:=LAST_INSERT_ID();");
                    query.next();
                    answerID = query.value(0).toString();
                    params<<answerID;
                }
            }
            if (it.name()=="exec")
            {
                type=it.value().toString();
            }
            if (it.name()=="lang")
            {
                lang=it.value().toString();
                params<<lang;
            }
            if (it.value().isObject())
            {
                if (type=="execute")
                {
                    QScriptValueIterator sit(it.value());
                    while (sit.hasNext()) {
                        sit.next();
                        if (sit.value().isObject())//--- jeigu tai failas
                        {
                            QScriptValueIterator sits(sit.value());
                            while (sits.hasNext()) {
                                sits.next();
                                if (sits.value().toString()=="file")
                                {
                                    sits.next();

                                    query.exec("SELECT @pp_id:=pp_id FROM math.program_param_list,math.program_param WHERE ppl_pp_id=pp_id and ppl_cp_id="+program_id+" and pp_name='"+sits.name()+"'");
                                    cout << program_id.toStdString() << " program id \n";
                                    query.prepare("INSERT INTO math.answer_param_value (pv_value, pv_pp_id) VALUES (:val, @pp_id);");
                                    query.bindValue(":val",sits.value().toString());
                                    query.exec();
                                    query.exec("SELECT @pv_id:=LAST_INSERT_ID();");
                                    query.exec("INSERT INTO math.answer_param_list (anpl_an_id, anpl_pv_id) VALUES (@an_id, @pv_id)");
                                    query.exec("SELECT BD_DATA FROM math.big_data where BD_ID="+sits.value().toString());
                                    query.next();
                                    file.setFileName(this->binaryPath+"/binaries/"+program_id+"/"+sits.value().toString());
                                    params<<this->binaryPath+"/binaries/"+program_id+"/"+sits.value().toString();
                                    if (file.open(QIODevice::WriteOnly | QIODevice::Text))
                                    {
                                        QTextStream out(&file);
                                        out << query.value(0).toByteArray();
                                    }
                                    file.close();
                                }
                            }
                        }
                        else {
                            params<<sit.value().toString();
                            query.exec("SELECT @pp_id:=pp_id FROM math.program_param_list,math.program_param WHERE ppl_pp_id=pp_id and ppl_cp_id="+program_id+" and pp_name='"+sit.name()+"'");
                            query.prepare("INSERT INTO math.answer_param_value (pv_value, pv_pp_id) VALUES (:val, @pp_id);");
                            query.bindValue(":val",sit.value().toString());
                            query.exec();
                            query.exec("SELECT @pv_id:=LAST_INSERT_ID();");
                            query.exec("INSERT INTO math.answer_param_list (anpl_an_id, anpl_pv_id) VALUES (@an_id, @pv_id)");
                        }
                    }
                }
            }
        }
    }
    QSqlDatabase::removeDatabase(conName);
    if (type=="execute")
    {
        if (params.at(0).isNull()||params.at(0).isEmpty())
        {
            socket.write("Nurodykite programa");
            socket.waitForBytesWritten();
        }
        else  emit this->requestExecute(params);
    }
    if (type=="compile")
    {
        if (params.at(0).isNull()||params.at(0).isEmpty())
        {
            socket.write("Nurodykite programa");
            socket.waitForBytesWritten();
        }
        else  emit this->requestCompile(params);
    }
    // qDebug()<<QString(data);
    socket.write(token.toLatin1());
    socket.flush();
    socket.waitForBytesWritten();
    socket.waitForDisconnected();
    socket.close();

}
Пример #26
0
void  NetworkView::updateDisplay()
{
    if(!isVisible())
        return ;
    if(!_should_update)
        return ;

    /* add all friends */
    std::string ownGPGId = rsPeers->getGPGOwnId();
//#ifdef DEBUG_NETWORKVIEW
    std::cerr << "NetworkView::updateDisplay()" << std::endl;
//#endif

    std::deque<NodeInfo> nodes_to_treat ;						// list of nodes to be treated. Used as a queue. The int is the level of friendness
    std::set<std::string> nodes_considered ;					// list of nodes already considered. Eases lookup.

    nodes_to_treat.push_front(NodeInfo(ownGPGId,0)) ;		// initialize queue with own id.
    nodes_considered.insert(rsPeers->getOwnId()) ;

    // Put own id in queue, and empty the queue, treating all nodes.
    //
    while(!nodes_to_treat.empty())
    {
        NodeInfo info(nodes_to_treat.back()) ;
        nodes_to_treat.pop_back() ;
#ifdef DEBUG_NETWORKVIEW
        std::cerr << "  Poped out of queue: " << info.gpg_id << ", with level " << info.friend_level << std::endl ;
#endif
        GraphWidget::NodeType type ;
        GraphWidget::AuthType auth ;

        switch(info.friend_level)
        {
        case 0:
            type = GraphWidget::ELASTIC_NODE_TYPE_OWN ;
            break ;
        case 1:
            type = GraphWidget::ELASTIC_NODE_TYPE_FRIEND ;
            break ;
        case 2:
            type = GraphWidget::ELASTIC_NODE_TYPE_F_OF_F ;
            break ;
        default:
            type = GraphWidget::ELASTIC_NODE_TYPE_UNKNOWN ;
        }

        RsPeerDetails detail ;
        if(!rsPeers->getPeerDetails(info.gpg_id, detail))
            continue ;

        switch(detail.trustLvl)
        {
        case RS_TRUST_LVL_MARGINAL:
            auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ;
            break;
        case RS_TRUST_LVL_FULL:
        case RS_TRUST_LVL_ULTIMATE:
            auth = GraphWidget::ELASTIC_NODE_AUTH_FULL ;
            break;
        case RS_TRUST_LVL_UNKNOWN:
        case RS_TRUST_LVL_UNDEFINED:
        case RS_TRUST_LVL_NEVER:
        default:
            auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ;
            break ;
        }

        if(info.friend_level <= _max_friend_level && _node_ids.find(info.gpg_id) == _node_ids.end())
        {
            _node_ids[info.gpg_id] = ui.graphicsView->addNode("       "+detail.name, detail.name+"@"+detail.gpg_id,type,auth,"",info.gpg_id);
#ifdef DEBUG_NETWORKVIEW
            std::cerr << "  inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ;
#endif
        }

        std::list<std::string> friendList;
        rsDisc->getDiscGPGFriends(info.gpg_id, friendList);

#ifdef DEBUG_NETWORKVIEW
        std::cerr << "  Got a list of " << friendList.size() << " friends for this peer." << std::endl ;
#endif

        if(info.friend_level+1 <= _max_friend_level)
            for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit)
                if(nodes_considered.find(*sit) == nodes_considered.end())
                {
#ifdef DEBUG_NETWORKVIEW
                    std::cerr << "  adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
#endif
                    nodes_to_treat.push_front( NodeInfo(*sit,info.friend_level + 1) ) ;
                    nodes_considered.insert(*sit) ;
                }
    }

    /* iterate through all friends */

#ifdef DEBUG_NETWORKVIEW
    std::cerr << "NetworkView::insertSignatures()" << std::endl;
#endif

    for(std::map<std::string,GraphWidget::NodeId>::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++)
    {
        std::list<std::string> friendList ;

        if(rsDisc->getDiscGPGFriends(it->first,friendList))
            for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
            {
#ifdef DEBUG_NETWORKVIEW
                std::cerr << "NetworkView: Adding Edge: ";
                std::cerr << *sit << " <-> " << it->first;
                std::cerr << std::endl;
#endif

                if(_node_ids.find(*sit) != _node_ids.end())
                    ui.graphicsView->addEdge(_node_ids[*sit], it->second);
            }
    }

    _should_update = false ;
}
Пример #27
0
int main() {
    if ( init() == 0 ) {
        printf("aRobot init success !\n");
    } else {
        printf("aRobot init failed , and exit\n");
        return 0;
    }
    char raw[25];
    int lebal = 0;

    fgets(raw, 20, stdin);
    raw[strlen(raw)-1]='\0';

    while ( raw[0] == '\0' || strstr(AROBOT_EXIT, raw) == NULL) {
        lebal = 0;
        if (strcmp(raw, AROBOT_ACTION) == 0 ) {
            lebal = 1;
            action();
        }
        if (strcmp(raw, STAT_ACTION_SIT) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_SIT;
            sit();

        }
        if (strcmp(raw, STAT_ACTION_SLEEP) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_SLEEP;
            sleep();

        }
        if (strcmp(raw, STAT_ACTION_WALK) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_WALK;
            walk();

        }
        if (strcmp(raw, STAT_ACTION_RUN) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_RUN;
            run();

        }
        if (strncmp(raw, STAT_ACTION_EAT, strlen(STAT_ACTION_EAT)) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_EAT;
            eat(raw+strlen(STAT_ACTION_EAT));
        }
        if (strcmp(raw, STAT_ACTION_HEAR_AND_SAY) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_HEAR_AND_SAY;
            char word[255];
            dyf->hear(word, 255);
            dyf->say(word);
            //hearf(word, 255);
            //sayf(word);
        }
        if (strncmp(raw, STAT_ACTION_DRINK, strlen(STAT_ACTION_DRINK)) == 0 ) {
            lebal = 1;
            actionType = STAT_ACTION_DRINK;
            drink(raw + strlen(STAT_ACTION_DRINK) );

        }
        if ( ! lebal ) {
            wrong();
        }
        fgets(raw, 20, stdin);
        raw[strlen(raw)-1]='\0';

    }
    printf("Bye bye !\n");
    if (dlhandler) dlclose(dlhandler);
    return 0;

}
Пример #28
0
std::shared_ptr<STTx const>
deserializeTx (SHAMapItem const& item)
{
    SerialIter sit(item.slice());
    return std::make_shared<STTx const>(sit);
}
Пример #29
0
/// Undo moving several objects.
void UndoBuffer::undoMoveMultiple(Undo* u)
{
  Project* p;
  p = u->getProject();

//  QListIterator<GState> i(*u->getSList());
//  QList<GTransition>* tl = u->getTList();
//  GState* s;
//  GTransition* t;
  double x, y;
//  QList<GObject>* sellist;
  Selection* sel;
  QList<GState*>* ssellist;
  QList<GTransition*>* tsellist;
//  bool dragmultiple;
  ScrollView* sv;

  u->getMovedBy(x, y);

  sv = project->getMain()->getScrollView();
  sel = sv->getDrawArea()->getSelection();
  sel->deselectAll(project->machine);
  
  ssellist = u->getSList2();
  tsellist = u->getTList2();

  QListIterator<GState*> sit(*ssellist);
  for(;sit.hasNext();)
    sel->select(sit.next());

  QListIterator<GTransition*> tit(*tsellist);
  for(;tit.hasNext();)
    sel->select(tit.next());

  /*
  for(; i.current(); ++i)
  {
    s = i.current();
    s->move(-x, -y, project->getMain()->getScrollView(), project->machine, FALSE);
  }
  */
//  dragmultiple = sv->getDragMultiple();

  sel->move(-x, -y, project->getMain()->getScrollView()->getDrawArea(), p->machine);

  /*
  s = project->machine->getPhantomState();
  QListIterator<GTransition> j(s->tlist);

  for(; j.current(); ++j)
  {
    t = j.current();
    if (t->getEnd()==NULL && tl->containsRef(t))
      t->move(-x, -y);
  }
  */
  /*
  sit.toFirst();
  for(;sit.current(); ++sit)
    sel->deselect(sit.current());
    */
  sel->deselectAll(p->machine);
}
Пример #30
0
void tGraph::draw(QPainter & paint) {
    //QPainter paint(this);
    paint.save();

    int gx1 = hPadding() + _rect.x();
    int gy1 = vPadding() + _rect.y();
    int gx2 = _rect.x() + width() - hPadding();
    int gy2 = _rect.y() + height() - vPadding();

    //paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1);

    QFontMetrics fm(font());
    //QRect brect;

    // get the dimensions of the title label and then draw it
    if(title().length() > 0) {
        fm = QFontMetrics(titleFont());
        //brect = fm.boundingRect(title());
        paint.setFont(titleFont());
        paint.drawText(gx1, gy1, gx2 - gx1, fm.height(), titleAlignment(), title());
        gy1 += fm.height();
    }

    // we need to do some drawing that depends on some other elements having
    // already been placed... since those require that these have already been
    // placed we will just save the old value of gy2 and then calculate the
    // value that we should have after the other code runs without actually
    // drawing anything right now
    int gy2_old = gy2;
    if(dataLabel().length() > 0) {
        fm = QFontMetrics(dataLabelFont());
        gy2 -= fm.height();
    }
    fm = QFontMetrics(dataFont());
    double tlh = 0.0;
    
    QMapIterator<int, GReference> dlit(_data);
    while(dlit.hasNext())
    {
        dlit.next();
        tlh = QMAX(sin45deg * fm.width(dlit.value().first), tlh);
    }
    // don't change this variable as we use it later
    int th = (tlh == 0.0 ? 0 : (int)(tlh + (fm.height() * sin45deg)) + 2);
    gy2 -= th;


    // get the dimensions of the value label then draw it
    if(valueLabel().length() > 0) {
        fm = QFontMetrics(valueLabelFont());
        //brect = fm.boundingRect(valueLabel());
        paint.setFont(valueLabelFont());
        paint.save();
        paint.rotate(-90);
        paint.drawText(-gy2, gx1, gy2 - gy1, fm.height(), valueLabelAlignment(), valueLabel());
        paint.restore();
        gx1 += fm.height();
    }

    fm = QFontMetrics(valueFont());

    QString min_str = QString().sprintf("%-.0f",minValue());
    QString org_str = ( minValue() == 0.0 ? QString::null : QString("0") );
    QString max_str = QString().sprintf("%-.0f",maxValue());

    int width = QMAX(fm.width(min_str), fm.width(max_str));
    if(org_str.length() > 0) width = QMAX(width, fm.width(org_str));

    gx1 += width;

    int gy_max = gy1;
    int gy_min = gy2 - 1;
    int gy_org = gy_min;

    paint.setFont(valueFont());
    int tfa = Qt::AlignTop | Qt::AlignRight;
    paint.drawText(gx1 - fm.width(min_str), gy_min, fm.width(min_str), fm.height(), tfa, min_str);
    paint.drawLine(gx1 - 3, gy_min, gx1 + 2, gy_min);
    paint.drawText(gx1 - fm.width(max_str), gy_max, fm.width(max_str), fm.height(), tfa, max_str);
    paint.drawLine(gx1 - 3, gy_max, gx1 + 2, gy_max);
    int gheight = gy2 - gy1;
    double grng = maxValue() - minValue();
    if(org_str.length() > 0) {
        double perc = (0 - minValue()) / grng;
        gy_org = gy2 - (int)(perc * (double)gheight);
        paint.drawText(gx1 - fm.width(org_str), gy_org, fm.width(org_str), fm.height(), tfa, org_str);
        paint.drawLine(gx1 - 3, gy_org, gx1 + 2, gy_org);
    }

    gx1 += 3;

    // put the old value back so all the code to come draw correctly!
    gy2 = gy2_old;

    // get the dimensions of the data label then draw it
    if(dataLabel().length() > 0) {
        fm = QFontMetrics(dataLabelFont());
        //brect = fm.boundingRect(dataLabel());
        paint.setFont(dataLabelFont());
        gy2 -= fm.height();
        paint.drawText(gx1, gy2, gx2 - gx1, fm.height(), dataLabelAlignment(), dataLabel());
    }

    gy2 -= th;

    int ref_cnt = _data.count();
    int gwidth = gx2 - gx1;
    gheight = gy2 - gy1;

    if(ref_cnt > 0) {
        paint.save();
        fm = QFontMetrics(dataFont());
        paint.setFont(dataFont());
        int refwidth = QMAX(1, gwidth / ref_cnt);
        int buf = (int)(refwidth / 5);
        int buf2 = buf * 2;
        int pos = gx1 + (int)((gwidth - (refwidth * ref_cnt)) / 2);
        int bar_height;
        int fmheight = fm.height();
        int fmheight_div_2 = fmheight / 2;
        int refwidth_div_2 = refwidth / 2;
        int label_offset = (int)(fmheight_div_2 * cos45deg);
        int last_label_at = -1000;
        QMap<int, double> last_map;
        QMap<int, double> this_map;
        QMapIterator<int, GReference> rit(_data);
        while(rit.hasNext())
        {
            rit.next();
            GReference ref = rit.value();
            QString label = ref.first;
            if(label.length() > 0 && ((pos + refwidth_div_2) - last_label_at) > ((label_offset * 2) + 1)) {
                last_label_at = pos + refwidth_div_2;
                int lx = (int)(((pos + refwidth_div_2) * cos45deg) - ((gy2 + label_offset) * sin45deg));
                int ly = (int)(((pos + refwidth_div_2) * sin45deg) + ((gy2 + label_offset) * cos45deg));
                int fmwidth = fm.width(label);
                paint.save();
                paint.rotate(-45);
                paint.drawText(lx - fmwidth, ly - fmheight_div_2, fmwidth, fmheight, Qt::AlignRight | Qt::AlignTop, label);
                paint.restore();
            }

            QMapIterator<int, double> sit(ref.second);
            paint.save();
            if(drawBars() == TRUE) {
                TSetValue tval;
                QMap<double, TSetValue> sort_map;
                sit = ref.second;
                while(sit.hasNext())
                {
                    sit.next();
                    if(sit.value() != 0.0 && _setStyle[sit.key()].bar == TRUE) {
                        tval.first = sit.key();
                        tval.second = sit.value();
                        sort_map[(tval.second < 0.0 ? minValue() : maxValue()) - (tval.second < 0.0 ? -tval.second : tval.second)] = tval;
                    }
                }
                QMapIterator<double, TSetValue> it(sort_map);
                while(it.hasNext())
                {
                    it.next();
                    tval = it.value();
                    if(tval.second != 0.0) {
                        if(tval.second < 0) {
                            bar_height = (int)((tval.second / minValue()) * (gy_org - gy_min));
                        } else {
                            bar_height = (int)((tval.second / maxValue()) * (gy_org - gy_max));
                        } 
                        paint.fillRect(pos + buf, gy_org - bar_height, refwidth - buf2, bar_height, getSetColor(tval.first));
                    }
                }
            }
            if(drawLines() == TRUE) {
                this_map.clear();
                sit = ref.second;
                while(sit.hasNext())
                {
                    sit.next();
                    if(_setStyle[sit.key()].line == TRUE) {
                        this_map[sit.key()] = sit.value();
                        if(last_map.contains(sit.key())) {
                            paint.setPen(getSetColor(sit.key()));
                            double old_val = last_map[sit.key()];
                            double new_val = sit.value();
                            int ly1;
                            if(old_val < 0.0) ly1 = (int)((old_val / minValue()) * (gy_org - gy_min));
                            else              ly1 = (int)((old_val / maxValue()) * (gy_org - gy_max));
                            ly1 = gy_org - ly1;
                            int lx1 = pos - refwidth_div_2;
                            int ly2;
                            if(new_val < 0.0) ly2 = (int)((new_val / minValue()) * (gy_org - gy_min));
                            else              ly2 = (int)((new_val / maxValue()) * (gy_org - gy_max));
                            ly2 = gy_org - ly2;
                            int lx2 = pos + refwidth_div_2;
                            paint.drawLine(lx1, ly1, lx2, ly2);
                        }
                    }
                }
                last_map = this_map;
            }
            if(drawPoints() == TRUE) {
                sit = ref.second;
                while(sit.hasNext())
                {
                    sit.next();
                    if(_setStyle[sit.key()].point == TRUE) {
                        paint.setBrush(getSetColor(sit.key()));
                        paint.setPen(QColor(0,0,0));
                        int ly1;
                        if(sit.value() < 0.0) ly1 = (int)((sit.value() / minValue()) * (gy_org - gy_min));
                        else                  ly1 = (int)((sit.value() / maxValue()) * (gy_org - gy_max));
                        ly1 = gy_org - ly1;
                        int lx1 = pos + refwidth_div_2;
                        paint.drawEllipse(lx1 - 2, ly1 - 2, 5, 5);
                    }
                }
            }
            paint.restore();
            pos += refwidth;
        }
        paint.restore();
    }

    paint.drawLine(gx1, gy_org, gx2 - 1, gy_org);
    paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1);


    // Now that we are done return the paint device back to the state
    // it was when we started to mess with it
    paint.restore();
}