コード例 #1
0
ファイル: tester.cpp プロジェクト: imane-jym/gp
 TestData_INIFile()
     :ini()
 {
     if(!ini.OpenFile("test/test.ini"))
     {
         throw std::string("Could not open file test/test.ini");
     }
 }
コード例 #2
0
ファイル: benchmark.cpp プロジェクト: imane-jym/gp
        ///Runs the benchmark
        bool Benchmark()
        {
            INIFile ini;
            if(!ini.OpenFile(BenchFile)) return false;
            while(ini.Next())
            {
                CurrentSection = ini.GetSection(ini.GetSection("")->GetName());
                switch(Type)
                {
                    case BT_STRING:
                    case BT_STRINGRULES:
                        if(!STL) BenchRead<const char * const, const char *>(&INISection::ReadString);
                        #ifndef MINIINI_NO_STL
                        else BenchRead<const std::string &, std::string>(&INISection::ReadString);
                        #endif
                        break;
                    case BT_INT:
                        if(!STL) BenchRead<const char * const, int>(&INISection::ReadInt);
                        #ifndef MINIINI_NO_STL
                        else BenchRead<const std::string &, int>(&INISection::ReadInt);
                        #endif
                        break;
                    case BT_FLOAT:
                        if(!STL) BenchRead<const char * const, float>(&INISection::ReadFloat);
                        #ifndef MINIINI_NO_STL
                        else BenchRead<const std::string &, float>(&INISection::ReadFloat);
                        #endif
                        break;
                    case BT_BOOL:
                        if(!STL) BenchRead<const char * const, bool>(&INISection::ReadBool);
                        #ifndef MINIINI_NO_STL
                        else BenchRead<const std::string &, bool>(&INISection::ReadBool);
                        #endif
                        break;
                    case BT_MULTISTRING:
                        BENCHREADMULTI(ReadMultiString, const char *, std::string);
                        break;
                    case BT_MULTIINT:
                        BENCHREADMULTI(ReadMultiInt, int, int);
                        break;
                    case BT_MULTIFLOAT:
                        BENCHREADMULTI(ReadMultiFloat, float, float);
                        break;
                    case BT_MULTIBOOL:
                        BENCHREADMULTI(ReadMultiBool, bool, bool);
                        break;
                    case BT_STRINGS:
                        BENCHREADARRAY(ReadStrings, const char *, std::string);
                        break;
                    case BT_INTS:
                        BENCHREADARRAY(ReadInts, int, int);
                        break;
                    case BT_FLOATS:
                        BENCHREADARRAY(ReadFloats, float, float);
                    case BT_BOOLS:
                        BENCHREADARRAY(ReadBools, bool, bool);
                        break;
                    default:
                        return false;
                        break;
                }

            }

            #ifdef MINIINI_BENCH_EXTRA
            #ifdef linux
            FileTime = miniini_private::bench_filetime;
            AllocTime = miniini_private::bench_alloctime;
            LoadTime = miniini_private::bench_loadtime;
            #endif
            #endif

            return true;
        }
コード例 #3
0
ファイル: main.cpp プロジェクト: imane-jym/gp
int main(int argc, char * argv[])
{
	ParseArg(argc,argv);

	if (gDaemonFlag)
	{
		CUtil::DaemonInit();
	}
	
	sSessCtrl;
	sLog->Initialize();

	//if (!CUtil::SetRLimit())
	//	return 0;

	if (!g_serverIni.OpenFile("server.ini"))
	{
		IME_ERROR("Cannot open server.ini");
		return 0;
	}

	if (!InitServer())
	{
		IME_ERROR("InitServer failed");
		return 0;
	}

//	//do many init db here
//	if (!StartDB())
//	{
//		IME_ERROR("StartDB failed");
//		return 0;
//	}

	IME_LOG("GameServer Start!");
	
	//todo 
	//hooksignal
	HookSignals();

	///- Launch CNetRunnable thread
	CNetRunnable * pNetRunnable = new CNetRunnable;
	ZThread::Thread netThread(pNetRunnable);
	netThread.setPriority((ZThread::Priority)1);

	ZThread::Thread *pRelayClientThread = NULL;
	if (CSet::ClientSessionRun)
	{
		///- Launch CRelayClientRunnable thread
		CRelayClientRunnable * pRelayClientRunnable = new CRelayClientRunnable;
//		ZThread::Thread relayClientThread(pRelayClientRunnable);
//		relayClientThread.setPriority((ZThread::Priority)1);
		pRelayClientThread = new ZThread::Thread(pRelayClientRunnable);
		pRelayClientThread->setPriority((ZThread::Priority)1);
	}

	///- Launch CWorldRunnable thread
	ZThread::Thread worldThread(new CWorldRunnable);
	worldThread.setPriority((ZThread::Priority)1);

	worldThread.wait();
	netThread.wait();
	//relayClientThread.wait();
	if (pRelayClientThread != NULL)
		pRelayClientThread->wait();

	//unhooksignal	
	UnHookSignals();
	EndServer();
	IME_LOG("GameServer End!");

	return 0;
}