00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #define LIBSMBIOS_SOURCE
00020 #include "CmosRWImpl.h"
00021 #include "FactoryImpl2.h"
00022
00023 using namespace std;
00024
00025 namespace cmos
00026 {
00027 class CmosRWFactoryImpl : public factory::TFactory<CmosRWFactory>
00028 {
00029 public:
00030 CmosRWFactoryImpl() { setParameter("cmosMapFile", ""); };
00031 virtual ~CmosRWFactoryImpl() throw ();
00032 virtual ICmosRW *getSingleton( );
00033 virtual ICmosRW *makeNew( );
00034 protected:
00035 static ICmosRW *_cmosPtr;
00036 };
00037
00038
00039 CmosRWFactory::~CmosRWFactory() throw()
00040 {}
00041 CmosRWFactory::CmosRWFactory()
00042 {}
00043
00044 ICmosRW *CmosRWFactoryImpl::_cmosPtr = 0;
00045
00046 CmosRWFactoryImpl::~CmosRWFactoryImpl() throw()
00047 {
00048 if( _cmosPtr )
00049 {
00050 delete _cmosPtr;
00051 }
00052 _cmosPtr = 0;
00053 }
00054
00055 CmosRWFactory *CmosRWFactory::getFactory()
00056 {
00057
00058
00059
00060 return CmosRWFactoryImpl::getFactory(reinterpret_cast<CmosRWFactoryImpl *>(0));
00061 }
00062
00063 ICmosRW *CmosRWFactoryImpl::getSingleton()
00064 {
00065 if (_cmosPtr == 0)
00066 _cmosPtr = makeNew();
00067
00068 return _cmosPtr;
00069 }
00070
00071 ICmosRW *CmosRWFactoryImpl::makeNew()
00072 {
00073 ICmosRW *ret=0;
00074 if (mode == UnitTestMode)
00075 {
00076 ret = new CmosRWFile( getParameterString("cmosMapFile") );
00077 }
00078 else if ( mode == AutoDetectMode )
00079 {
00080 ret = new CmosRWIo( );
00081 }
00082 else
00083 {
00084 throw InvalidCmosRWModeImpl("CmosRW Factory has been set to an invalid mode.");
00085 }
00086 return ret;
00087 }
00088
00089 }