application_server.cpp

Go to the documentation of this file.
00001 /* MANTAINER: Bernard */
00002 
00003 #include "log.h"
00004 #include "application_server.h"
00005 #include "settings.h"
00006 
00007 ApplicationServer::ApplicationServer()
00008 {
00009         TIN
00010 }
00011 
00012 ApplicationServer::~ApplicationServer()
00013 {
00014 
00015 }
00016 
00017 ApplicationServer::ApplicationServer(ApplicationServer &copy)
00018 {
00019         TIN
00020 
00021         LOGE << "It is forbidden to make copy of AplicationServer." << endl;
00022         DIE();
00023 }
00024 
00025 void ApplicationServer::init()
00026 {
00027         TIN
00028                 
00029         loadUserConfigFile(SETTING_SERVER_CONFIG_FILE, SETTING_SERVER_CONFIG_FILE_TEMPLATE);
00030         
00031         // Log - open logfile and set log level
00032         g_log.init(g_settings.getString(SETTING_LOGFILE_SERVER).c_str(),
00033                            g_settings.isTrue(SETTING_TOSTDERR_SERVER));
00034         g_log.set_loglevel(g_settings.getInt(SETTING_LOGLEVEL));
00035         
00036         LOGI << "Server setting and loging inicialized." << endl;
00037 
00038         // prepare server global tasks
00039         mTaskManager.add(getCommander());
00040 }
00041 
00042 void ApplicationServer::run()
00043 {
00044         TIN
00045 
00046         LOGI << "Server salute you :-) - Welcome to infinite loop" << endl;
00047         
00048         // This probably will be elsewhere or the inicialization
00049         // will move to init/clean
00050         mGameServer.init();
00051 
00052 
00053         // start the server itself
00054         mGameServer.run();
00055 }
00056 
00057 void ApplicationServer::clean()
00058 {
00059         TIN
00060                 
00061         saveUserConfigFile(SETTING_SERVER_CONFIG_FILE, SETTING_SERVER_CONFIG_FILE_TEMPLATE);
00062 }
00063 
00064 
00065 GameServer& ApplicationServer::getGame()
00066 {
00067         return mGameServer;
00068 }
00069 
00070 Game* ApplicationServer::getGameCommon()
00071 {
00072         return &mGameServer;
00073 }
00074 
00075 
00076 
00077 Commander& ApplicationServer::getCommander()
00078 {
00079         return mCommanderServer;
00080 }

Generated on Wed Apr 12 13:55:27 2006 for bjs by  doxygen 1.4.5