00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #define LIBSMBIOS_SOURCE
00020 #include "SmiImpl.h"
00021 #include "../common/FactoryImpl2.h"
00022
00023
00024 #include "smbios/message.h"
00025
00026 using namespace std;
00027
00028 namespace smi
00029 {
00030 class SmiFactoryImpl : public factory::TFactory<SmiFactory>
00031 {
00032 public:
00033 SmiFactoryImpl() { setParameter("smiFile", ""); };
00034 virtual ~SmiFactoryImpl() throw() {};
00035 virtual std::auto_ptr<ISmi> makeNew(u8 type);
00036 protected:
00037 static ISmi *_cmosPtr;
00038 };
00039
00040
00041 SmiFactory::~SmiFactory() throw()
00042 {}
00043 SmiFactory::SmiFactory()
00044 {}
00045
00046 SmiFactory *SmiFactory::getFactory()
00047 {
00048
00049
00050
00051 return SmiFactoryImpl::getFactory(reinterpret_cast<SmiFactoryImpl *>(0));
00052 }
00053
00054 std::auto_ptr<ISmi> SmiFactoryImpl::makeNew( u8 type )
00055 {
00056 ISmi *ret = 0;
00057 SmiStrategy *strategyPtr = 0;
00058
00059 if (mode == AutoDetectMode )
00060 strategyPtr = new SmiArchStrategy();
00061
00062 else if (mode == UnitTestMode)
00063 strategyPtr = new SmiMockStrategy(getParameterString("smiFile"));
00064
00065
00066 switch( type )
00067 {
00068 case DELL_CALLING_INTERFACE_SMI:
00069 ret = new DellCallingInterfaceSmiImpl(strategyPtr);
00070 break;
00071 default:
00072 throw InvalidSmiModeImpl(_("Unknown smi factory mode requested"));
00073 break;
00074 }
00075
00076 if( ! ret )
00077 throw InvalidSmiModeImpl(_("Could not allocate SMI object"));
00078
00079 std::auto_ptr<ISmi> foo(ret);
00080 return foo;
00081 }
00082
00083 }