asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
Download asio - 1.2.0 (Stable) Last Update: Aug 14 2008
Sometimes we have to code with 'singleton'. If you don't know what Singleton is, you can read about it in many Design Pattern books. Singleton principle is really simple.
As you know, if you use reference pointer for singleton object, then you must delete it when program terminates. But it will be good because it does 'late instance'.
I want to terminate singleton object automatically, and instance lately. So, I coded this.
Good things:
Late instance.
Safe terminate automatically.
Separated code for Object and Singleton.
Here is my tiny singleton helper class - CSingletonT<>, and I hope it helps you.
// // Using singletonT class // #include "SingletonT.h"
// test class class CObj { protected: CObj(){ x = 0 ; TRACE("Created CObj\r\n"); } public: virtual ~CObj(){ x = 0 ; TRACE("Deleted CObj\r\n");}
int x; };
// Testing void CTestSingleTDlg::OnButton1() { // TODO: Add your control notification handler code here // if first call, then singleton object will instance ( instance lately ) CObj* o = CSingletonT<CObj>::GetObject();
Sometimes we have to code with 'singleton'. If you don't know what Singleton is, you can read about it in many Design Pattern books. Singleton principle is really simple.
As you know, if you use reference pointer for singleton object, then you must delete it when program terminates. But it will be good because it does 'late instance'.
I want to terminate singleton object automatically, and instance lately. So, I coded this.
Good things:
Late instance.
Safe terminate automatically.
Separated code for Object and Singleton.
Here is my tiny singleton helper class - CSingletonT<>, and I hope it helps you.
// // Using singletonT class // #include "SingletonT.h"
// test class class CObj { protected: CObj(){ x = 0 ; TRACE("Created CObj\r\n"); } public: virtual ~CObj(){ x = 0 ; TRACE("Deleted CObj\r\n");}
int x; };
// Testing void CTestSingleTDlg::OnButton1() { // TODO: Add your control notification handler code here // if first call, then singleton object will instance ( instance lately ) CObj* o = CSingletonT<CObj>::GetObject();