示例#1
0
文件: Test.cpp 项目: zhouhbsea/toprs
int main()
{
	//toprsImg img;
    int test = 5;
	
	toprsConnAble<toprsConnAbleReader> * pb = toprsConnAble<toprsConnAbleReader>::getInstance();
	toprsConnAble<toprsConnAbleFilter> * pd = toprsConnAble<toprsConnAbleFilter>::getInstance();
	////toprsConnAble * pc = toprsConnAble<toprsConnAbleReader>::getInstance();


	bool x = pb->canConnectMyInputTo(&test);

	bool y = pd->canConnectMyInputTo(&test);

	std::shared_ptr<testinter> temp(new testinter);
	std::shared_ptr<testinter> temp2 = std::make_shared<testinter>();

	toprsConnection<testinter> con(temp);
	con.connectMyInputTo(temp2);
	
	toprsConnection<testinter> con2(con);

	toprsConnection<testinter> con3(std::move(con));





	//bool z = con.testt<toprsConnAbleFilter>(&test);

	//toprsConnection<int> theConn(&test);

	//int one = 1;
	//int two =2;
	//int three = 3;

	//theConn.start();
   // theConn>>one>>two>>three;

	
	

	//bool z = pc->canConnectMyInputTo(&test);


	//return 0;
	//toprsConnAble<toprsConnAbleReader>* r = toprsConnAbleReader::getInstance();
	return 0;
}
示例#2
0
bool dbase::checkExists( const std::string &data, const std::string &table, const std::string &field, const std::string &f2, const std::string &d2 ) { // check if the received data matches anything already in the database
	logger _logger( glob.g_ll, glob.g_logfile );
	_logger.logstream << "checkExists() called.";
	_logger.log( 0 );
	_logger.logstream << "Checking if host already in Database...";
	_logger.log( 1 );
	mysqlpp::Connection con3( false );
	if ( con3.connect( dbname, dbhost, dbuser, dbpass ) ) {
		std::stringstream queryss;
		queryss<< "SELECT " << field << " FROM `" << dbname << "`.`" << table << "` WHERE " << field << " = " << mysqlpp::quote_only << data;
		if( f2 == "0" ) {
			queryss  << ";";
		}
		else {
			queryss << "AND " << f2 << "=" << mysqlpp::quote_only << d2 << ";";
		}
		std::string qstr = queryss.str();
		_logger.logstream << "Calling SQL Query '" << qstr << "'.";
		_logger.log( 1 );
		mysqlpp::Query query = con3.query( qstr );
		//std::cout << qstr << std::endl;
		mysqlpp::StoreQueryResult res = query.store();
		std::stringstream res1;
		for ( std::vector<mysqlpp::Row>::iterator it= res.begin(); it != res.end(); ++it ) {
			mysqlpp::Row row = *it;
			res1 << row[0];
		}
		std::string result = res1.str();
		_logger.logstream >> result;
		_logger.log( 1 );

		if ( result == data ) {
			_logger.logstream << "Host exists in Database.";
			_logger.log( 1 );
			return true;
		}
		else {
			_logger.logstream << "Host does not exist in Database.";
			_logger.log( 1 );
			return false;
		}
	}
示例#3
0
void
fruitapp::gui::ce::post_model::post(
	fruitapp::highscore::name const &_name,
	fruitapp::highscore::score const &_score)
{
	for(
		fruitapp::gui::ce::table::row_index::value_type i =
			static_cast<fruitapp::gui::ce::table::row_index::value_type>(connections_.size()-1);
		i != static_cast<fruitapp::gui::ce::table::row_index::value_type>(-1);
		--i)
		row_removed_(
			i);

	for(
		highscore::provider_sequence::iterator i =
			providers_.begin();
		i != providers_.end();
		++i)
	{
		fruitapp::highscore::provider::connection_base_ptr new_connection(
			(*i)->create_connection());

		fruitapp::gui::ce::table::row new_row;
		new_row.push_back(
			(*i)->identifier());
		new_row.push_back(
			FCPPT_TEXT(""));

		fruitapp::gui::ce::table::row_index::value_type const new_row_index =
			static_cast<fruitapp::gui::ce::table::row_index::value_type>(
				std::distance(
					providers_.begin(),
					i));

		row_added_(
			new_row_index,
			new_row);

		fcppt::signal::auto_connection con1(
			new_connection->message_received(
				fruitapp::highscore::callbacks::message_received{
					std::bind(
						&post_model::message_received_internal,
						this,
						std::cref(
							**i),
						std::placeholders::_1
					)
				}
			)
		);

		fcppt::signal::auto_connection con2(
			new_connection->error_received(
				fruitapp::highscore::callbacks::error_received{
					std::bind(
						&post_model::error_received_internal,
						this,
						std::cref(
							**i),
						std::placeholders::_1
					)
				}
			)
		);

		fcppt::signal::auto_connection con3(
			new_connection->rank_received(
				fruitapp::highscore::callbacks::rank_received{
					std::bind(
						&post_model::rank_received_internal,
						this,
						std::cref(
							**i),
						new_row_index,
						std::placeholders::_1
					)
				}
			)
		);

		connections_.push_back(
			fcppt::make_unique_ptr<connection_wrapper>(
				std::move(
					new_connection),
				std::move(
					con1),
				std::move(
					con2),
				std::move(
					con3)));

		connections_.back()->connection().post_rank(
			_name,
			_score);
	}
}