Exemplo n.º 1
0
// This constructor is used to reload analysis blocks directly out of the database
AM1DExpressionAB::AM1DExpressionAB(AMDatabase* db, int id)
	: AMAnalysisBlock("tempName"),
	  axisInfo_("tempName_x", 0)
{
	currentlySettingInputSources_ = false;
	// We're not using direct evaluation at the start
	direct_ = xDirect_ = false;

	// initialize the parser:
	parser_.DefineNameChars("0123456789_:.[]"
							"abcdefghijklmnopqrstuvwxyz"
							"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	xParser_.DefineNameChars("0123456789_:.[]"
							 "abcdefghijklmnopqrstuvwxyz"
							 "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	//parser_.DefineOprtChars("abcdefghijklmnopqrstuvwxyz"
	//					   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	//				   "+-*^/?<>=#!$%&|~'_");
	//parser_.DefineInfixOprtChars("/+-*^?<>=#!$%&|~'_");

	// initial state is invalid: no inputs.
	setState(AMDataSource::InvalidFlag);

	loadFromDb(db, id);	// this will trigger setExpression() and setXExpression(), which will re-evaluate our state.

	AMDataSource::name_ = AMDbObject::name();	// normally it's not okay to change a dataSource's name. Here we get away with it because we're within the constructor, and nothing's watching us yet.
	axisInfo_ = AMAxisInfo(name() + "_x", 0);
}
Exemplo n.º 2
0
AMOldDetectorInfoSet::AMOldDetectorInfoSet(AMDatabase* db, int id)
	: AMDbObject(), AMOrderedSet<QString, QPair<AMOldDetectorInfo*, bool> >() {

	connect(signalSource(), SIGNAL(itemAdded(int)), this, SLOT(onDetectorAdded(int)));
	connect(signalSource(), SIGNAL(itemRemoved(int)), this, SLOT(onDetectorRemoved(int)));
	connect(signalSource(), SIGNAL(itemChanged(int)), this, SLOT(onDetectorValuesChanged(int)));

	loadFromDb(db, id);
}
AMExternalScanDataSourceAB::AMExternalScanDataSourceAB(AMDatabase* db, int id) : AMStandardAnalysisBlock("tempName")
{
	insideConstructor_ = true;

	setState(AMDataSource::InvalidFlag);
	scan_ = 0;
	sourceScanId_ = -1;

	loadFromDb(db, id);

	insideConstructor_ = false;
}
bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( QString theCrs )
{
  if ( loadFromDb( QgsApplication::srsDbFilePath(), "lower(auth_name||':'||auth_id)", theCrs.toLower() ) )
    return true;

  if ( theCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
  {
    createFromSrsId( GEOCRS_ID );
    return true;
  }

  return false;
}
Exemplo n.º 5
0
void CVarManager::loadNormal()
{
	m_bNormalLoaded = true;

	try
	{
		sqlite3x::sqlite3_connection db(m_szCVarDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "SELECT name, value FROM cvar;");

		sqlite3x::sqlite3_reader cmdResults = cmd.executereader();
		loadFromDb(cmdResults);
	}
	catch (std::exception &e)
	{
		Warning(gcString("Failed to load cvar normal: {0}\n", e.what()));
	}
}
Exemplo n.º 6
0
void CVarManager::loadUser(uint32 userid)
{
	m_uiUserId = userid;
	m_bUserLoaded = true;

	try
	{
		sqlite3x::sqlite3_connection db(m_szCVarDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "SELECT name, value FROM cvaruser WHERE user=?;");
		cmd.bind(1, (int)m_uiUserId);

		sqlite3x::sqlite3_reader cmdResults = cmd.executereader();
		loadFromDb(cmdResults);
	}
	catch (std::exception &)
	{
	}
}
Exemplo n.º 7
0
void CVarManager::loadWinUser()
{
	m_bWinUserLoaded = true;

	try
	{
		sqlite3x::sqlite3_connection db(m_szCVarDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "SELECT name, value FROM cvarwin WHERE user=?;");

		cmd.bind(1, getWinUser());

		sqlite3x::sqlite3_reader cmdResults = cmd.executereader();
		loadFromDb(cmdResults);
	}
	catch (std::exception &e)
	{
		Warning(gcString("Failed to load cvar win user: {0}\n", e.what()));
	}
}
Exemplo n.º 8
0
AM4DBinningAB::AM4DBinningAB(AMDatabase *db, int id)
	: AMStandardAnalysisBlock("tempName")
{
	sumAxis_ = 3;
	sumRangeMin_ = 0;
	sumRangeMax_ = 0;

	inputSource_ = 0;
	cacheCompletelyInvalid_ = true;
	// leave sources_ empty for now.

	axes_ << AMAxisInfo("invalid", 0, "No input data") << AMAxisInfo("invalid", 0, "No input data") << AMAxisInfo("invalid", 0, "No input data");
	setState(AMDataSource::InvalidFlag);

	loadFromDb(db, id);
		// will restore sumAxis, sumRangeMin, and sumRangeMax. We'll remain invalid until we get connected.

	AMDataSource::name_ = AMDbObject::name();	// normally it's not okay to change a dataSource's name. Here we get away with it because we're within the constructor, and nothing's watching us yet.
}
Exemplo n.º 9
0
// This constructor immediately loads a stored sample from the database.
AMSamplePre2013::AMSamplePre2013(int databaseId, AMDatabase* database, QObject* parent)
    : AMDbObject(parent)
{

    loadFromDb(database, databaseId);
}
Exemplo n.º 10
0
    void Server::runGame()
    {
        std::cout<<"Start Game service"<<std::endl;

        loadFromDb();
        while(!stop)
        {
            sf::Lock guard(_clientMutex);
            //for all clients
            for(auto it = _clients.begin(); it != _clients.end();++it)
            {
                Client* client = *it;
                packet::NetworkEvent* msg;
                while(client and client->pollEvent(msg))
                {
                    std::cout<<"Client "<<client->id()<<" recive data of type : "<<msg->type()<<std::endl;
                    switch(msg->type())
                    {
                        case FuncIds::IdGetListGame :
                        {
                            sf::Packet response;
                            packet::SetListGame list;
                            sf::Lock guard(_gameMutex);
                            for(auto game : _games)
                            {
                                list.add(game->id(),game->getPlayersCount(),game->getTeamCount());
                            }

                            response<<list;
                            client->send(response);
                        }break;
                        case FuncIds::IdCreateGame :
                        {
                            sf::Packet response;
                            packet::SetListGame list;
                            sf::Lock guard(_gameMutex);
                            _games.emplace_back(new Game("./media/map.json"));
                            _games.back()->load(true);

                            for(auto game : _games)
                            {
                                list.add(game->id(),game->getPlayersCount(),game->getTeamCount());
                            }
                            _games.back()->onLogOut = onLogOut;
                            _games.back()->run();

                            response<<list;
                            //send new game to all clients
                            for(auto it2 = _clients.begin(); it2 != _clients.end();++it2)
                                (*it2)->send(response);
                        }break;
                        case FuncIds::IdJoinGame :
                        {
                            int gameId = static_cast<packet::JoinGame*>(msg)->gameId();
                            sf::Lock guard(_gameMutex);
                            for(auto game : _games)
                            {
                                if(game->id() == gameId)
                                {
                                    if(game->addClient(client))
                                    {
                                        client = nullptr;
                                        it = _clients.erase(it);
                                        --it;
                                    }
                                    break;
                                }
                            }

                        }break;

                        case FuncIds::IdDisconnected :
                        {
                            it = _clients.erase(it);
                            --it;
                            client = nullptr;
                        }break;
                        default : break;
                    }
                    delete msg;
                }
            }
        }

        std::cout<<"Stop Game service"<<std::endl;
        {
            sf::Lock guard(_gameMutex);
            for(auto& game : _games)
            {
                std::cout<<"Stop Game "<<game->id()<<std::endl;
                game->stop();
                game->wait();
            }
            saveToDb();
        }
    }
bool QgsCoordinateReferenceSystem::createFromSrsId( long id )
{
  return loadFromDb( id < USER_CRS_START_ID ? QgsApplication::srsDbFilePath() :
                     QgsApplication::qgisUserDbFilePath(), "srs_id", QString::number( id ) );
}
bool QgsCoordinateReferenceSystem::createFromSrid( long id )
{
  return loadFromDb( QgsApplication::srsDbFilePath(), "srid", QString::number( id ) );
}
Exemplo n.º 13
0
/// This constructor immediately loads a stored run from the database.
AMRun::AMRun(int databaseId, AMDatabase* database, QObject* parent)
	: AMDbObject(parent)
{

	loadFromDb(database, databaseId);
}