00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #define LIBSMBIOS_SOURCE
00021 #include "smbios/compat.h"
00022
00023 #include <vector>
00024
00025 #include "SmbiosImpl.h"
00026
00027
00028 #include "smbios/message.h"
00029
00030 using namespace std;
00031
00032 namespace smbios
00033 {
00034 SmbiosFactory::~SmbiosFactory() throw()
00035 {}
00036 SmbiosFactory::SmbiosFactory()
00037 {}
00038
00039 SmbiosFactory *SmbiosFactory::getFactory()
00040 {
00041
00042
00043
00044 return SmbiosFactoryImpl::getFactory(reinterpret_cast<SmbiosFactoryImpl *>(0));
00045 }
00046
00047 ISmbiosTable *SmbiosFactoryImpl::_tableInstance = 0;
00048
00049 SmbiosFactoryImpl::~SmbiosFactoryImpl() throw()
00050 {
00051 if( _tableInstance )
00052 {
00053 delete _tableInstance;
00054 _tableInstance = 0;
00055 }
00056 }
00057
00058 SmbiosFactoryImpl::SmbiosFactoryImpl()
00059 {
00060 mode = defaultMode;
00061 setParameter( "strictValidation", 0 );
00062 setParameter( "offset", 0 );
00063 }
00064
00065 ISmbiosTable *SmbiosFactoryImpl::getSingleton()
00066 {
00067 if (! _tableInstance)
00068 _tableInstance = makeNew();
00069
00070 return _tableInstance;
00071 }
00072
00073 ISmbiosTable *SmbiosFactoryImpl::makeNew()
00074 {
00075
00076 bool strict = getParameterNum("strictValidation") ? 1 : 0;
00077
00078 SmbiosTable *table = 0;
00079
00080 std::vector<SmbiosStrategy *> strategies;
00081
00082 if (mode == AutoDetectMode)
00083 {
00084 #ifdef LIBSMBIOS_PLATFORM_LINUX
00085 strategies.push_back( new SmbiosLinuxEFIStrategy() );
00086 #endif
00087 strategies.push_back( new SmbiosMemoryStrategy(getParameterNum("offset")) );
00088 #ifdef LIBSMBIOS_PLATFORM_WIN32
00089 strategies.push_back( new SmbiosWinGetFirmwareTableStrategy() );
00090 strategies.push_back( new SmbiosWinWMIStrategy() );
00091 #endif
00092 }
00093 else if (mode == UnitTestMode)
00094 {
00095 strategies.push_back( new SmbiosMemoryStrategy(getParameterNum("offset")) );
00096 }
00097 else
00098 {
00099 throw NotImplementedImpl(_("Unknown smbios factory mode requested"));
00100 }
00101
00102
00103 table = new SmbiosTable(
00104 strategies,
00105 strict
00106 );
00107
00108 table->initializeWorkaround();
00109 return table;
00110 }
00111 }