A
download basesystem.cpp
Language: C++
License: LGPL
Copyright: Copyright 2006-2007 John Poole.
LOC: 77
Project Info
geekinfo - Cross-platform system information tool(geekinfo)
Server: Google
Type: svn
Google\g\geekinfo\trunk\
   basesystem.cpp
   basesystem.h
   cpucount.cpp
   cpucount.h
   cpucount_asm.asm
   cpucount_asm.h
   geekinfo.cpp
   geekinfo.h
   geekinfo_c.cpp
   geekinfo_c.h
   geekinfo_c_test.c
   linuxsystem.cpp
   linuxsystem.h
   macosxsystem.cpp
   macosxsystem.h
   Makefile.win32
   Makefile_c.win32
   model.cpp
   model.h
   model.py
   platform.h
   solarissystem.cpp
   solarissystem.h
   system.cpp
   system.h
   types.h
   win32system.cpp
   win32system.h
   wmi.cpp
   wmi.h

/*
	basesystem.cpp

    Copyright 2006-2007 John Poole.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
#include "basesystem.h"
#include "platform.h"

#if defined( PLATFORM_LINUX )
	#include "linuxsystem.h"
#elif defined( PLATFORM_MACOSX )
	#include "macosxsystem.h"
#elif defined( PLATFORM_WINDOWS )
	#include "win32system.h"
#elif defined( PLATFORM_SOLARIS )
        #include "solarissystem.h"
#else
	#error Unsupported platform
#endif

#include <sstream>

std::string BaseSystem::platform()
{
	std::ostringstream	s;

	#if defined( PLATFORM_MACOSX )
		s << "Mac OS X";
	#elif defined( PLATFORM_LINUX )
		s << "Linux";
	#elif defined( PLATFORM_WINDOWS )
		s << "Windows";
	#elif defined( PLATFORM_SOLARIS )
		s << "Solaris";
	#else
		#error Unknown platform
	#endif
	
	#if defined( ARCH_X86 )
		s << " x86";
	#elif defined( ARCH_PPC )
		s << " PPC";
	#else
		#error Unsupported architecture
	#endif

	#if defined( ARCH_64BIT )
		s << " (64-bit)";
	#elif defined( ARCH_32BIT ) 
		s << " (32-bit)";
	#else
		#error Unsupported architecture
	#endif
	
	return s.str();
}

std::string BaseSystem::compiler()
{
	#if defined( PLATFORM_SOLARIS )
  		return "Sun Studio 11";
	#elif defined( PLATFORM_UNIX )
		return "GCC " __VERSION__;
	#elif defined( PLATFORM_WINDOWS )
		#if _MSC_VER == 1300
			return "Visual C++ 2003";
		#elif _MSC_VER == 1400
			return "Visual C++ 2005";
		#else
			#error Unknown Visual C++ version
		#endif
	#else
		#error Unknown compiler
	#endif
}

BaseSystem * systemFactory()
{
    #if defined( PLATFORM_MACOSX )
        return new MacOSXSystem();
    #elif defined( PLATFORM_LINUX )
        return new LinuxSystem();
    #elif defined( PLATFORM_WINDOWS )
        return new Win32System();
    #elif defined( PLATFORM_SOLARIS )
	return new SolarisSystem();
    #else
        #error systemFactory() return undefined.
        return NULL;
    #endif
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us