※设计模式※→☆创建型模式☆============Abstract Factory模式(四)
模式概述
一般情况 下,我们为了高内聚和松耦合,经常会使用多态来处理一些问题。抽象出一些类的公共接口作为抽象基类或者接口。这样的话,我们将会面临一个挑战。在每次使用子类的时候,我们不得不经常使用base* = New XXX (这也无可厚非,但当系统复杂后,我们可能将无法维护子类的创建),最终我们在程序的扩展和维护成本上的开销将变得越来越大,越来越难。
我们知道经常“某个对象”由于需求的变化,对象的具体实现面临着剧烈的变化。为了应对这种变化我们抽象出它比较稳定的接口,隔离出“这个易变对象”的变化,从而保持系统中“其它依赖该对象的对象”不随着需求的改变而改变,这就是我们经常谈的Factory模式了。
简单Simple Factory模式可以实现 ”定义创建对象的接口,并封装对象的创建“。
Simple Factory模式见:
http://blog.csdn.net/xiaoting451292510/article/details/8289608
然而,Simple Factory模式只解决了一个问题 "对象的创建封装",这个并不是Factory模式的真正意义所在。Factory模式的真正意义或者说他的威力是 ”将具体化类的工作延迟到了类中“,因此实际上我们一般经常使用的是ComplexFactory模式。
Complex Factory模式见:
http://blog.csdn.net/xiaoting451292510/article/details/8290809
实际还有另外一种情况,当我们需要创建一组相关对象或者说是一组相互依赖的对象的,上述的Simple Factory模式和Complex Factory模式就无法满足我们的需求了。这时我们可以使用Abstract Factory模式来解决这个问题。
Abstract Factory模式结构如下:
这里我把Factory类使用Singleton模式处理了,因为确确实实我只需要一个这样的工厂,而不是需要多个。
Singleton模式见:
http://blog.csdn.net/xiaoting451292510/article/details/8285710
惯例,我个人习惯是喜欢把拷贝构造函数和赋值函数私有化,并不对其进行实现。以避免一些不必要的麻烦,如果确实是需要使用拷贝构造函数和赋值函数时,再进行一些相关具体情况的处理。
AbstractFactory模式可以创建一组相关对象或者说是一组相互依赖的对象,例如:我们在游戏开发中,经常性某一个章节是有很多怪物的。然而对于不同的人来说,可玩性就是相当重要的了。因此怪物需要分成简单,中等,因难甚至BT级别,以供玩家自己选择符合自己的模式。为了避免创建过程错误及减少维护成本,这时候就可以使用Abstract Factory模式。
上述是我在开始一款游戏中使用的,可能理解有些不顺畅。这里我将使用一些很明显的例子。我们一直在使用电脑。电脑大致上是分鼠标、键盘、显示器和主机几个部分构成。每个部件以有很多厂商生产,如DELL、ASUS、HP等等。利用Abstract Factory模式我们可以通过不同的工大生产出一整套的产品。如DELLFactory里,生产出来的鼠标、键盘、显示器和主机产品都是DELL牌的(这样视乎就是DELL牌电脑了呢,哈哈!)。我不相信DELL的键盘,那就用HP的话,可以在HPFactory里生产出HP的键盘和鼠标,然后自行组装。
最后对于工厂模式作个小总结
Simple Factory模式:
定义创建对象的接口,并封装对象的创建
http://blog.csdn.net/xiaoting451292510/article/details/8289608
Complex Factory模式
1 定义创建对象的接口,并封装对象的创建
2 将具体化类的工作延迟到了类中
http://blog.csdn.net/xiaoting451292510/article/details/8290809
Abstract Factory模式
1 定义创建对象的接口,并封装对象的创建
2 将具体化类的工作延迟到了类中
3 创建创建一组相关对象或者说是一组相互依赖的对象最后,无论模式多么优越,我们也需要根据实际的具体情况而慎重考虑。
--------------------------------------------------------------------
// DesignPattern.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#ifndef CXX_DESIGNPATTERN_SINGLETON_H
#include "DESIGNPATTERN_Singleton.h"
#endif
#ifndef CXX_PROFESSION_H
#include "Profession.h"
#endif
#ifndef CXX_DESIGNPATTERN_SIMPLEFACTORY_H
#include "DESIGNPATTERN_SimpleFactory.h"
#endif
#ifndef CXX_DESIGNPATTERN_COMPLEXFACTORY_H
#include "DESIGNPATTERN_ComplexFactory.h"
#endif
#ifndef CXX_MOUSE_H
#include "Mouse.h"
#endif
#ifndef CXX_KEYBOARD_H
#include "Keyboard.h"
#endif
#ifndef CXX_MONITOR_H
#include "Monitor.h"
#endif
#ifndef CXX_COMPUTER_H
#include "Computer.h"
#endif
#ifndef CXX_DESIGNPATTERN_ABSTRACTFACTORY_H
#include "DESIGNPATTERN_AbstractFactory.h"
#endif
int _tmain(int argc, _TCHAR* argv[])
{
#if DEBG_TEST_SINGLETON
cout<<"***************************Singleton***************************"<<endl;
Singleton* pSingletonA = NULL;
Singleton* pSingletonA = NULL;
Singleton* pSingletonB = NULL;
pSingletonA = Singleton::Instance();
pSingletonB = Singleton::Instance();
Singleton::Destroy();
Singleton::Destroy();
#endif
#if DEBG_TEST_SIMPLEFACTORY
cout<<"***************************SimpleFactory***************************"<<endl;
Singleton* pSingletonA = NULL;
Profession* pProfession[3] = {0};
for (int i=0; i<3; i++) {
pProfession[i] = SimpleFactory::Instance()->CreateProfession(i);
}
for (int i=0; i<3; i++) {
if (NULL != pProfession[i]) {
delete pProfession[i];
pProfession[i] = NULL;
}
}
#endif
#if DEBG_TEST_COMPLEXFACTORY
cout<<"***************************ComplexFactory***************************"<<endl;
ComplexFactory* pWarriorFactory = WarriorFactory::Instance();
ComplexFactory* pMasterFactory = MasterFactory::Instance();
Profession* pWarrior = pWarriorFactory->CreateProfession();
Profession* pMaster = pMasterFactory->CreateProfession();
if (NULL != pWarrior) {
delete pWarrior;
pWarrior = NULL;
}
if (NULL != pMaster) {
delete pMaster;
pMaster = NULL;
}
#endif
#if DEBG_TEST_ABSTRACTFACTORY
cout<<"***************************AbstractFactory***************************"<<endl;
AbstractFactory* pDELLFactory = DELLFactory::Instance();
AbstractFactory* pASUSFactory = ASUSFactory::Instance();
AbstractFactory* pHPFactory = HPFactory::Instance();
//DELL product
Mouse* pDellMouse = pDELLFactory->CreateMouse();
Keyboard* pDellKeyboard = pDELLFactory->CreateKeyboard();
Monitor* pDellMonitor = pDELLFactory->CreateMonitor();
Computer* pDellComputer = pDELLFactory->CreateComputer();
//ASUS product
Mouse* pASUSMouse = pASUSFactory->CreateMouse();
Keyboard* pASUSKeyboard = pASUSFactory->CreateKeyboard();
Monitor* pASUSMonitor = pASUSFactory->CreateMonitor();
Computer* pASUSComputer = pASUSFactory->CreateComputer();
//HP product
Mouse* pHPMouse = pHPFactory->CreateMouse();
Keyboard* pHPKeyboard = pHPFactory->CreateKeyboard();
Monitor* pHPMonitor = pHPFactory->CreateMonitor();
Computer* pHPComputer = pHPFactory->CreateComputer();
if (NULL != pDellMouse) {
delete pDellMouse;
pDellMouse = NULL;
}
if (NULL != pDellKeyboard) {
delete pDellKeyboard;
pDellKeyboard = NULL;
}
if (NULL != pDellMonitor) {
delete pDellMonitor;
pDellMonitor = NULL;
}
if (NULL != pDellComputer) {
delete pDellComputer;
pDellComputer = NULL;
}
if (NULL != pHPMouse) {
delete pHPMouse;
pHPMouse = NULL;
}
if (NULL != pHPKeyboard) {
delete pHPKeyboard;
pHPKeyboard = NULL;
}
if (NULL != pHPMonitor) {
delete pHPMonitor;
pHPMonitor = NULL;
}
if (NULL != pHPComputer) {
delete pHPComputer;
pHPComputer = NULL;
}
if (NULL != pASUSMouse) {
delete pASUSMouse;
pASUSMouse = NULL;
}
if (NULL != pASUSKeyboard) {
delete pASUSKeyboard;
pASUSKeyboard = NULL;
}
if (NULL != pASUSMonitor) {
delete pASUSMonitor;
pASUSMonitor = NULL;
}
if (NULL != pASUSComputer) {
delete pASUSComputer;
pASUSComputer = NULL;
}
#endif
return 0;
}
DESIGNPATTERN_AbstractFactory.h
--------------------------------------------------------------------
/**
@file DESIGNPATTERN_AbstractFactory.h
@brief 1. Define an interface for creating an object, and the package object is created
2. The work of the specific class of delay to sub-class
3. Interface provides an object created for different class??Creating a group of related or dependent objects??.
@author arvin
@version 1.0 2012/12/14
*/
#ifndef CXX_DESIGNPATTERN_ABSTRACTFACTORY_H
#define CXX_DESIGNPATTERN_ABSTRACTFACTORY_H
class Mouse;
class Keyboard;
class Monitor;
class Computer;
class AbstractFactory
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~AbstractFactory() = 0;
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
virtual Mouse* CreateMouse() = 0;
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
virtual Keyboard* CreateKeyboard() = 0;
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
virtual Monitor* CreateMonitor() = 0;
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
virtual Computer* CreateComputer() = 0;
protected:
/**
* Construction
*
* @param VOID
* @return
*/
AbstractFactory();
private:
/**
* Copy Construction
*
* @param const AbstractFactory& cAbstractFactory
* @return
*/
AbstractFactory(const AbstractFactory& cAbstractFactory);
/**
* Assignment
*
* @param const AbstractFactory& cAbstractFactory
* @return AbstractFactory&
*/
AbstractFactory& operator=(const AbstractFactory& cAbstractFactory);
public:
protected:
private:
};
class DELLFactory : public AbstractFactory
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~DELLFactory();
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
static AbstractFactory* Instance();
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
static VOID Destroy();
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
virtual Mouse* CreateMouse();
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
virtual Keyboard* CreateKeyboard();
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
virtual Monitor* CreateMonitor();
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
virtual Computer* CreateComputer();
protected:
private:
/**
* Construction
*
* @param VOID
* @return
*/
DELLFactory();
/**
* Copy Construction
*
* @param const DELLFactory& cDELLFactory
* @return
*/
DELLFactory(const DELLFactory& cDELLFactory);
/**
* Assignment
*
* @param const DELLFactory& cDELLFactory
* @return DELLFactory&
*/
DELLFactory& operator=(const DELLFactory& cDELLFactory);
public:
protected:
private:
static DELLFactory* m_pInstance;
};
class ASUSFactory : public AbstractFactory
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~ASUSFactory();
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
static AbstractFactory* Instance();
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
static VOID Destroy();
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
virtual Mouse* CreateMouse();
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
virtual Keyboard* CreateKeyboard();
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
virtual Monitor* CreateMonitor();
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
virtual Computer* CreateComputer();
protected:
private:
/**
* Construction
*
* @param VOID
* @return
*/
ASUSFactory();
/**
* Copy Construction
*
* @param const ASUSFactory& cASUSFactory
* @return
*/
ASUSFactory(const ASUSFactory& cASUSFactory);
/**
* Assignment
*
* @param const ASUSFactory& cASUSFactory
* @return ASUSFactory&
*/
ASUSFactory& operator=(const ASUSFactory& cASUSFactory);
public:
protected:
private:
static ASUSFactory* m_pInstance;
};
class HPFactory : public AbstractFactory
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~HPFactory();
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
static AbstractFactory* Instance();
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
static VOID Destroy();
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
virtual Mouse* CreateMouse();
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
virtual Keyboard* CreateKeyboard();
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
virtual Monitor* CreateMonitor();
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
virtual Computer* CreateComputer();
protected:
private:
/**
* Construction
*
* @param VOID
* @return
*/
HPFactory();
/**
* Copy Construction
*
* @param const HPFactory& cHPFactory
* @return
*/
HPFactory(const HPFactory& cHPFactory);
/**
* Assignment
*
* @param const HPFactory& cHPFactory
* @return HPFactory&
*/
HPFactory& operator=(const HPFactory& cHPFactory);
public:
protected:
private:
static HPFactory* m_pInstance;
};
#endif /* >>CXX_DESIGNPATTERN_ABSTRACTFACTORY_H<< */
/* EOF */
DESIGNPATTERN_AbstractFactory.cpp
--------------------------------------------------------------------
/**
@file DESIGNPATTERN_AbstractFactory.h
@brief 1. Define an interface for creating an object, and the package object is created
2. The work of the specific class of delay to sub-class
3. Interface provides an object created for different class??Creating a group of related or dependent objects??.
@author arvin
@version 1.0 2012/12/14
*/
#include "stdafx.h"
#ifndef CXX_DESIGNPATTERN_ABSTRACTFACTORY_H
#include "DESIGNPATTERN_AbstractFactory.h"
#endif
#ifndef CXX_MOUSE_H
#include "Mouse.h"
#endif
#ifndef CXX_KEYBOARD_H
#include "Keyboard.h"
#endif
#ifndef CXX_MONITOR_H
#include "Monitor.h"
#endif
#ifndef CXX_COMPUTER_H
#include "Computer.h"
#endif
/**
* Construction
*
* @param VOID
* @return
*/
AbstractFactory::AbstractFactory()
{
}
/**
* Destruction
*
* @param VOID
* @return
*/
AbstractFactory::~AbstractFactory()
{
}
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
Mouse*
AbstractFactory::CreateMouse()
{
//system error log
cerr<<"[AbstractFactory::CreateMouse] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
return NULL;
}
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
Keyboard*
AbstractFactory::CreateKeyboard()
{
//system error log
cerr<<"[AbstractFactory::CreateKeyboard] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
return NULL;
}
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
Monitor*
AbstractFactory::CreateMonitor()
{
//system error log
cerr<<"[AbstractFactory::CreateMonitor] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
return NULL;
}
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
Computer*
AbstractFactory::CreateComputer()
{
//system error log
cerr<<"[AbstractFactory::CreateComputer] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
return NULL;
}
DELLFactory* DELLFactory::m_pInstance = NULL;
/**
* Construction
*
* @param VOID
* @return
*/
DELLFactory::DELLFactory()
{
}
/**
* Destruction
*
* @param VOID
* @return
*/
DELLFactory::~DELLFactory()
{
}
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
AbstractFactory*
DELLFactory::Instance()
{
if (NULL == m_pInstance) {
m_pInstance = new DELLFactory;
}
return m_pInstance;
}
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID
DELLFactory::Destroy()
{
if (NULL != m_pInstance) {
delete m_pInstance;
m_pInstance = NULL;
}
}
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
Mouse*
DELLFactory::CreateMouse()
{
return new DELLMouse;
}
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
Keyboard*
DELLFactory::CreateKeyboard()
{
return new DELLKeyboard;
}
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
Monitor*
DELLFactory::CreateMonitor()
{
return new DELLMonitor;
}
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
Computer*
DELLFactory::CreateComputer()
{
return new DELLComputer;
}
ASUSFactory* ASUSFactory::m_pInstance = NULL;
/**
* Construction
*
* @param VOID
* @return
*/
ASUSFactory::ASUSFactory()
{
}
/**
* Destruction
*
* @param VOID
* @return
*/
ASUSFactory::~ASUSFactory()
{
}
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
AbstractFactory*
ASUSFactory::Instance()
{
if (NULL == m_pInstance) {
m_pInstance = new ASUSFactory;
}
return m_pInstance;
}
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID
ASUSFactory::Destroy()
{
if (NULL != m_pInstance) {
delete m_pInstance;
m_pInstance = NULL;
}
}
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
Mouse*
ASUSFactory::CreateMouse()
{
return new ASUSMouse;
}
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
Keyboard*
ASUSFactory::CreateKeyboard()
{
return new ASUSKeyboard;
}
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
Monitor*
ASUSFactory::CreateMonitor()
{
return new ASUSMonitor;
}
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
Computer*
ASUSFactory::CreateComputer()
{
return new ASUSComputer;
}
HPFactory* HPFactory::m_pInstance = NULL;
/**
* Construction
*
* @param VOID
* @return
*/
HPFactory::HPFactory()
{
}
/**
* Destruction
*
* @param VOID
* @return
*/
HPFactory::~HPFactory()
{
}
/**
* Instance
*
* @param VOID
* @return AbstractFactory*
* @note singleton
*/
AbstractFactory*
HPFactory::Instance()
{
if (NULL == m_pInstance) {
m_pInstance = new HPFactory;
}
return m_pInstance;
}
/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID
HPFactory::Destroy()
{
if (NULL != m_pInstance) {
delete m_pInstance;
m_pInstance = NULL;
}
}
/**
* Create Mouse
*
* @param VOID
* @return Mouse*
* @note
*/
Mouse*
HPFactory::CreateMouse()
{
return new HPMouse;
}
/**
* Create Keyboard
*
* @param VOID
* @return Keyboard*
* @note
*/
Keyboard*
HPFactory::CreateKeyboard()
{
return new HPKeyboard;
}
/**
* Create Monitor
*
* @param VOID
* @return Monitor*
* @note
*/
Monitor*
HPFactory::CreateMonitor()
{
return new HPMonitor;
}
/**
* Create Computer
*
* @param VOID
* @return Computer*
* @note
*/
Computer*
HPFactory::CreateComputer()
{
return new HPComputer;
}
/* EOF */
Mouse.h
--------------------------------------------------------------------
/**
@file Mouse.h
@brief all kinds of Mouse
@author arvin
@version 1.0 2012/12/14
*/
#ifndef CXX_MOUSE_H
#define CXX_MOUSE_H
class Mouse
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~Mouse() = 0;
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation() = 0;
protected:
/**
* Construction
*
* @param VOID
* @return
*/
Mouse();
private:
/**
* Copy Construction
*
* @param const Mouse& cMouse
* @return
*/
Mouse(const Mouse& cMouse);
/**
* Assignment
*
* @param const Mouse& cMouse
* @return Mouse&
*/
Mouse& operator=(const Mouse& cMouse);
public:
protected:
private:
};
class DELLMouse : public Mouse
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
DELLMouse();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~DELLMouse();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const DELLMouse& cASUSMouse
* @return
*/
DELLMouse(const DELLMouse& cDELLMouse);
/**
* Assignment
*
* @param const DELLMouse& cASUSMouse
* @return DELLMouse&
*/
DELLMouse& operator=(const DELLMouse& cDELLMouse);
public:
protected:
private:
};
class ASUSMouse : public Mouse
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
ASUSMouse();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~ASUSMouse();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const ASUSMouse& cASUSMouse
* @return
*/
ASUSMouse(const ASUSMouse& cASUSMouse);
/**
* Assignment
*
* @param const ASUSMouse& cASUSMouse
* @return ASUSMouse&
*/
ASUSMouse& operator=(const ASUSMouse& cASUSMouse);
public:
protected:
private:
};
class HPMouse : public Mouse
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
HPMouse();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~HPMouse();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const HPMouse& cHPMouse
* @return
*/
HPMouse(const HPMouse& cHPMouse);
/**
* Assignment
*
* @param const HPMouse& cHPMouse
* @return HPMouse&
*/
HPMouse& operator=(const HPMouse& cHPMouse);
public:
protected:
private:
};
#endif /* >>CXX_MOUSE_H<< */
/* EOF */
Mouse.cpp
--------------------------------------------------------------------
/**
@file Mouse.h
@brief all kinds of Mouse
@author arvin
@version 1.0 2012/12/14
*/
#include "stdafx.h"
#ifndef CXX_MOUSE_H
#include "Mouse.h"
#endif
/**
* Construction
*
* @param VOID
* @return
*/
Mouse::Mouse()
{
cout<<"Construction Mouse"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
Mouse::~Mouse()
{
cout<<"Destruction Mouse"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
Mouse::Operation()
{
//system error log
cerr<<"[Mouse::Operation] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
}
/**
* Construction
*
* @param VOID
* @return
*/
DELLMouse::DELLMouse()
{
cout<<"Construction DELLMouse"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
DELLMouse::~DELLMouse()
{
cout<<"Destruction DELLMouse"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
DELLMouse::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
ASUSMouse::ASUSMouse()
{
cout<<"Construction ASUSMouse"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
ASUSMouse::~ASUSMouse()
{
cout<<"Destruction ASUSMouse"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
ASUSMouse::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
HPMouse::HPMouse()
{
cout<<"Construction HPMouse"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
HPMouse::~HPMouse()
{
cout<<"Destruction HPMouse"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
HPMouse::Operation()
{
}
/* EOF */
Keyboard.h
--------------------------------------------------------------------
/**
@file Keyboard.h
@brief all kinds of Keyboard
@author arvin
@version 1.0 2012/12/17
*/
#ifndef CXX_KEYBOARD_H
#define CXX_KEYBOARD_H
class Keyboard
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~Keyboard() = 0;
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation() = 0;
protected:
/**
* Construction
*
* @param VOID
* @return
*/
Keyboard();
private:
/**
* Copy Construction
*
* @param const Keyboard& cKeyboard
* @return
*/
Keyboard(const Keyboard& cKeyboard);
/**
* Assignment
*
* @param const Keyboard& cKeyboard
* @return Keyboard&
*/
Keyboard& operator=(const Keyboard& cKeyboard);
public:
protected:
private:
};
class DELLKeyboard : public Keyboard
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
DELLKeyboard();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~DELLKeyboard();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const DELLKeyboard& cASUSKeyboard
* @return
*/
DELLKeyboard(const DELLKeyboard& cDELLKeyboard);
/**
* Assignment
*
* @param const DELLKeyboard& cASUSKeyboard
* @return DELLKeyboard&
*/
DELLKeyboard& operator=(const DELLKeyboard& cDELLKeyboard);
public:
protected:
private:
};
class ASUSKeyboard : public Keyboard
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
ASUSKeyboard();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~ASUSKeyboard();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const ASUSKeyboard& cASUSKeyboard
* @return
*/
ASUSKeyboard(const ASUSKeyboard& cASUSKeyboard);
/**
* Assignment
*
* @param const ASUSKeyboard& cASUSKeyboard
* @return ASUSKeyboard&
*/
ASUSKeyboard& operator=(const ASUSKeyboard& cASUSKeyboard);
public:
protected:
private:
};
class HPKeyboard : public Keyboard
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
HPKeyboard();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~HPKeyboard();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const HPKeyboard& cHPKeyboard
* @return
*/
HPKeyboard(const HPKeyboard& cHPKeyboard);
/**
* Assignment
*
* @param const HPKeyboard& cHPKeyboard
* @return HPKeyboard&
*/
HPKeyboard& operator=(const HPKeyboard& cHPKeyboard);
public:
protected:
private:
};
#endif /* >>CXX_KEYBOARD_H<< */
/* EOF */
Keyboard.cpp
--------------------------------------------------------------------
/**
@file Keyboard.h
@brief all kinds of Keyboard
@author arvin
@version 1.0 2012/12/17
*/
#include "stdafx.h"
#ifndef CXX_KEYBOARD_H
#include "Keyboard.h"
#endif
/**
* Construction
*
* @param VOID
* @return
*/
Keyboard::Keyboard()
{
cout<<"Construction Keyboard"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
Keyboard::~Keyboard()
{
cout<<"Destruction Keyboard"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
Keyboard::Operation()
{
//system error log
cerr<<"[Keyboard::Operation] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
}
/**
* Construction
*
* @param VOID
* @return
*/
DELLKeyboard::DELLKeyboard()
{
cout<<"Construction DELLKeyboard"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
DELLKeyboard::~DELLKeyboard()
{
cout<<"Destruction DELLKeyboard"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
DELLKeyboard::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
ASUSKeyboard::ASUSKeyboard()
{
cout<<"Construction ASUSKeyboard"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
ASUSKeyboard::~ASUSKeyboard()
{
cout<<"Destruction ASUSKeyboard"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
ASUSKeyboard::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
HPKeyboard::HPKeyboard()
{
cout<<"Construction HPKeyboard"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
HPKeyboard::~HPKeyboard()
{
cout<<"Destruction HPKeyboard"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
HPKeyboard::Operation()
{
}
/* EOF */
Monitor.h
--------------------------------------------------------------------
/**
@file Monitor.h
@brief all kinds of Monitor
@author arvin
@version 1.0 2012/12/17
*/
#ifndef CXX_MONITOR_H
#define CXX_MONITOR_H
class Monitor
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~Monitor() = 0;
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation() = 0;
protected:
/**
* Construction
*
* @param VOID
* @return
*/
Monitor();
private:
/**
* Copy Construction
*
* @param const Monitor& cMonitor
* @return
*/
Monitor(const Monitor& cMonitor);
/**
* Assignment
*
* @param const Monitor& cMonitor
* @return Monitor&
*/
Monitor& operator=(const Monitor& cMonitor);
public:
protected:
private:
};
class DELLMonitor : public Monitor
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
DELLMonitor();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~DELLMonitor();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const DELLMonitor& cASUSMonitor
* @return
*/
DELLMonitor(const DELLMonitor& cDELLMonitor);
/**
* Assignment
*
* @param const DELLMonitor& cASUSMonitor
* @return DELLMonitor&
*/
DELLMonitor& operator=(const DELLMonitor& cDELLMonitor);
public:
protected:
private:
};
class ASUSMonitor : public Monitor
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
ASUSMonitor();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~ASUSMonitor();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const ASUSMonitor& cASUSMonitor
* @return
*/
ASUSMonitor(const ASUSMonitor& cASUSMonitor);
/**
* Assignment
*
* @param const ASUSMonitor& cASUSMonitor
* @return ASUSMonitor&
*/
ASUSMonitor& operator=(const ASUSMonitor& cASUSMonitor);
public:
protected:
private:
};
class HPMonitor : public Monitor
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
HPMonitor();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~HPMonitor();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const HPMonitor& cHPMonitor
* @return
*/
HPMonitor(const HPMonitor& cHPMonitor);
/**
* Assignment
*
* @param const HPMonitor& cHPMonitor
* @return HPMonitor&
*/
HPMonitor& operator=(const HPMonitor& cHPMonitor);
public:
protected:
private:
};
#endif /* >>CXX_MONITOR_H<< */
/* EOF */
Monitor.cpp
--------------------------------------------------------------------
/**
@file Monitor.h
@brief all kinds of Monitor
@author arvin
@version 1.0 2012/12/17
*/
#include "stdafx.h"
#ifndef CXX_MONITOR_H
#include "Monitor.h"
#endif
/**
* Construction
*
* @param VOID
* @return
*/
Monitor::Monitor()
{
cout<<"Construction Monitor"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
Monitor::~Monitor()
{
cout<<"Destruction Monitor"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
Monitor::Operation()
{
//system error log
cerr<<"[Monitor::Operation] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
}
/**
* Construction
*
* @param VOID
* @return
*/
DELLMonitor::DELLMonitor()
{
cout<<"Construction DELLMonitor"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
DELLMonitor::~DELLMonitor()
{
cout<<"Destruction DELLMonitor"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
DELLMonitor::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
ASUSMonitor::ASUSMonitor()
{
cout<<"Construction ASUSMonitor"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
ASUSMonitor::~ASUSMonitor()
{
cout<<"Destruction ASUSMonitor"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
ASUSMonitor::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
HPMonitor::HPMonitor()
{
cout<<"Construction HPMonitor"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
HPMonitor::~HPMonitor()
{
cout<<"Destruction HPMonitor"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
HPMonitor::Operation()
{
}
/* EOF */
Computer.h
--------------------------------------------------------------------
/**
@file Computer.h
@brief all kinds of Computer
@author arvin
@version 1.0 2012/12/17
*/
#ifndef CXX_COMPUTER_H
#define CXX_COMPUTER_H
class Computer
{
public:
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~Computer() = 0;
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation() = 0;
protected:
/**
* Construction
*
* @param VOID
* @return
*/
Computer();
private:
/**
* Copy Construction
*
* @param const Computer& cComputer
* @return
*/
Computer(const Computer& cComputer);
/**
* Assignment
*
* @param const Computer& cComputer
* @return Computer&
*/
Computer& operator=(const Computer& cComputer);
public:
protected:
private:
};
class DELLComputer : public Computer
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
DELLComputer();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~DELLComputer();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const DELLComputer& cASUSComputer
* @return
*/
DELLComputer(const DELLComputer& cDELLComputer);
/**
* Assignment
*
* @param const DELLComputer& cASUSComputer
* @return DELLComputer&
*/
DELLComputer& operator=(const DELLComputer& cDELLComputer);
public:
protected:
private:
};
class ASUSComputer : public Computer
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
ASUSComputer();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~ASUSComputer();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const ASUSComputer& cASUSComputer
* @return
*/
ASUSComputer(const ASUSComputer& cASUSComputer);
/**
* Assignment
*
* @param const ASUSComputer& cASUSComputer
* @return ASUSComputer&
*/
ASUSComputer& operator=(const ASUSComputer& cASUSComputer);
public:
protected:
private:
};
class HPComputer : public Computer
{
public:
/**
* Construction
*
* @param VOID
* @return
*/
HPComputer();
/**
* Destruction
*
* @param VOID
* @return
*/
virtual ~HPComputer();
/**
* Operation
*
* @param VOID
* @return
*/
virtual VOID Operation();
protected:
private:
/**
* Copy Construction
*
* @param const HPComputer& cHPComputer
* @return
*/
HPComputer(const HPComputer& cHPComputer);
/**
* Assignment
*
* @param const HPComputer& cHPComputer
* @return HPComputer&
*/
HPComputer& operator=(const HPComputer& cHPComputer);
public:
protected:
private:
};
#endif /* >>CXX_COMPUTER_H<< */
/* EOF */
Computer.cpp
--------------------------------------------------------------------
/**
@file Computer.h
@brief all kinds of Computer
@author arvin
@version 1.0 2012/12/17
*/
#include "stdafx.h"
#ifndef CXX_COMPUTER_H
#include "Computer.h"
#endif
/**
* Construction
*
* @param VOID
* @return
*/
Computer::Computer()
{
cout<<"Construction Computer"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
Computer::~Computer()
{
cout<<"Destruction Computer"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
Computer::Operation()
{
//system error log
cerr<<"[Computer::Operation] got called from thread "<</*ThreadID*/"at: "/**gettimeofday()*/<<endl;
}
/**
* Construction
*
* @param VOID
* @return
*/
DELLComputer::DELLComputer()
{
cout<<"Construction DELLComputer"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
DELLComputer::~DELLComputer()
{
cout<<"Destruction DELLComputer"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
DELLComputer::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
ASUSComputer::ASUSComputer()
{
cout<<"Construction ASUSComputer"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
ASUSComputer::~ASUSComputer()
{
cout<<"Destruction ASUSComputer"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
ASUSComputer::Operation()
{
}
/**
* Construction
*
* @param VOID
* @return
*/
HPComputer::HPComputer()
{
cout<<"Construction HPComputer"<<endl;
}
/**
* Destruction
*
* @param VOID
* @return
*/
HPComputer::~HPComputer()
{
cout<<"Destruction HPComputer"<<endl;
}
/**
* Operation
*
* @param VOID
* @return
*/
VOID
HPComputer::Operation()
{
}
/* EOF */