You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1004 B
C

1 year ago
#pragma once
#include <mutex>
#include "Frame.h"
class FrameFactory
{
public:
static FrameFactory * GetInstance() {
if(!m_pInstance)
{
m_mutex.lock();
if(!m_pInstance)
{
m_pInstance = new FrameFactory();
}
m_mutex.unlock();
}
return m_pInstance;
}
// 根据设备类型建造不同的设备
static Frame *createFrame(int type, int direct);
private:
FrameFactory(){};
private:
static FrameFactory *m_pInstance;
static std::mutex m_mutex;
private:
// 垃圾回收类它的唯一工作就是在析构函数中删除DeviceFactory的实例
class Garbo
{
public:
~Garbo()
{
if (FrameFactory::m_pInstance)
{
delete FrameFactory::m_pInstance;
}
}
};
// 定义一个静态成员,在程序结束时,系统会调用它的析构函数
static Garbo m_Garbo;
};