appfactory.cpp

来自「It s a tool designed to extract as much 」· C++ 代码 · 共 131 行

CPP
131
字号
/* -*- c++ -*- ---------------------------------------------------------------   Copyright (C) 2005, SWECO, All Rights Reserved.   AppFactory implentation.   Author: Zsolt Molnar (Zsolt.Molnar@ieee.org)   ---------------------------------------------------------------------------*/#include "CmdBasedDeviceRecovery.hh"#include "DeviceManager.hh"#include "HardcodedDeviceTypeExtractor.hh"#include "OBEXSender.hh"#include "OBEXCommInitiator.hh"#include "NetHandler.hh"#include "DeviceManager.hh"#include "CmdBasedRFCommHandler.hh"#include "AppFactory.hh"#ifdef __TEST__#include "DummyDeviceManager.hh"#include "DummyNetHandler.hh"#include "DummyCommInitiator.hh"#include "DummyRFCommHandler.hh"#include "DummyOBEXSender.hh"#endif // #ifdef __TEST__namespace { 	const char rcs_id[] = "$Id$"; };bool AppFactory::_isInited = false;voidAppFactory::setup(){	if (!_isInited) {		// Trigger static initialization		getCommInitiator();		getRFCommHandler();		getNetHandler();		_isInited = true;	}}IDeviceRecovery* AppFactory::newDeviceRecoveryC(IDeviceManager& aDeviceManager){#ifndef __TEST__	return new CmdBasedDeviceRecovery(aDeviceManager);#else // #ifndef __TEST__	return new DeviceRecoveryLogic(aDeviceManager);#endif // #ifndef __TEST__}IDeviceManager* AppFactory::newDeviceManagerC(){#ifndef __TEST__	return new DeviceManager;#else // #ifndef __TEST__	return new DummyDeviceManager;#endif // #ifndef __TEST__}IDeviceTypeExtractor* AppFactory::newDeviceTypeExtractorC(){	return new HardcodedDeviceTypeExtractor;}ICommInitiator&AppFactory::getCommInitiator(){#ifndef __TEST__    static OBEXCommInitiator obc;	return obc;#else // #ifndef __TEST__	return *(new DummyCommInitiator((DeviceState)testHint_CommInitiator));#endif // #ifndef __TEST__}INetHandler&AppFactory::getNetHandler(){#ifndef __TEST__    static NetHandler nh;	return nh;#else // #ifndef __TEST__	// Yes, memory leak... but only for testing.	if (testHint_NetHandler == TEST_DNH_FALSE) {		return *(new DummyNetHandler(false));	} else {		return *(new DummyNetHandler(true));	}#endif // #ifndef __TEST__}IRFCommHandler&AppFactory::getRFCommHandler(){    static CmdBasedRFCommHandler rfcomh;	return rfcomh;}IOBEXSender* AppFactory::newOBEXSenderC(){	return new OBEXSender();}voidAppFactory::cleanup(){    /* EMPTY */}#ifdef __TEST__int AppFactory::testHint_CommInitiator;int AppFactory::testHint_NetHandler;#endif // #ifdef __TEST__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?