diff --git a/client/client_application.hpp b/client/client_application.hpp index e0e67c7..eea274f 100644 --- a/client/client_application.hpp +++ b/client/client_application.hpp @@ -28,18 +28,23 @@ #include "udp_network_utility.hpp" #include "character.hpp" +#include "singleton.hpp" + #include -class ClientApplication { +class ClientApplication: public Singleton { public: - ClientApplication() = default; - ~ClientApplication() = default; - + //public methods void Init(int argc, char** argv); void Proc(); void Quit(); private: + friend Singleton; + + ClientApplication() = default; + ~ClientApplication() = default; + //Private access members void LoadScene(SceneList sceneIndex); void UnloadScene(); diff --git a/client/main.cpp b/client/main.cpp index cc3fc08..57154b6 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -32,16 +32,18 @@ using namespace std; int main(int argc, char** argv) { try { //create the singletons + ClientApplication::Create(); ConfigUtility::Create(); //call the server's routines - ClientApplication app; + ClientApplication& app = ClientApplication::GetSingleton(); app.Init(argc, argv); app.Proc(); app.Quit(); //delete the singletons ConfigUtility::Delete(); + ClientApplication::Delete(); } catch(exception& e) { cerr << "Fatal exception thrown: " << e.what() << endl; diff --git a/server/main.cpp b/server/main.cpp index bfa7f7c..4fbc24a 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -33,15 +33,17 @@ int main(int argc, char** argv) { try { //create the singletons ConfigUtility::Create(); + ServerApplication::Create(); //call the server's routines - ServerApplication app; + ServerApplication& app = ServerApplication::GetSingleton(); app.Init(argc, argv); app.Proc(); app.Quit(); //delete the singletons ConfigUtility::Delete(); + ServerApplication::Delete(); } catch(exception& e) { cerr << "Fatal exception thrown: " << e.what() << endl; diff --git a/server/server_application.hpp b/server/server_application.hpp index 74b8777..6c99d2d 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -31,6 +31,7 @@ //common utilities #include "udp_network_utility.hpp" #include "config_utility.hpp" +#include "singleton.hpp" //APIs #include "lua/lua.hpp" @@ -42,17 +43,19 @@ #include //The main application class -class ServerApplication { +class ServerApplication: public Singleton { public: //public methods - ServerApplication() = default; - ~ServerApplication() = default; - void Init(int argc, char** argv); void Proc(); void Quit(); private: + friend Singleton; + + ServerApplication() = default; + ~ServerApplication() = default; + //handle incoming traffic void HandlePacket(SerialPacket* const);