-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingletonStub.hpp
More file actions
47 lines (38 loc) · 857 Bytes
/
SingletonStub.hpp
File metadata and controls
47 lines (38 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef __SINGLETON_STUB__HPP
#define __SINGLETON_STUB__HPP
#include "Singleton.hpp"
namespace stubs
{
class SingletonStub: public SingletonClass
{
public:
static SingletonClass* getInstance()
{
std::cout << std::endl << "stub getinstance is called" << std::endl;
if ( 0 == m_instance )
{
m_instance = new SingletonStub;
}
return m_instance;
}
};
}
SingletonClass::SingletonClass()
: m_stubUsed(true)
{
std::cout << std::endl << "constructor in stub file is called" << std::endl;
}
SingletonClass::~SingletonClass()
{
if ( 0 != m_instance )
{
delete m_instance;
}
m_instance = 0;
}
SingletonClass* SingletonClass::getInstance()
{
std::cout << std::endl << " we are in good place..." << std::endl;
return stubs::SingletonStub::getInstance();
}
#endif