From 4d6c92e6c8b933e5c6324fb49ff9a2f1114e2096 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 4 Jan 2016 15:56:17 +0100 Subject: [PATCH] Move DirectPlay templates into directplayutils.h refs #564 --- .../fs9/blacksimpluginfreefunctions.h | 28 ------------ src/plugins/simulator/fs9/directplaypeer.cpp | 1 + src/plugins/simulator/fs9/directplayutils.h | 45 +++++++++++++++++++ src/plugins/simulator/fs9/fs9client.cpp | 1 + src/plugins/simulator/fs9/fs9host.cpp | 1 + src/plugins/simulator/fs9/lobbyclient.cpp | 1 + 6 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 src/plugins/simulator/fs9/directplayutils.h diff --git a/src/plugins/simulator/fs9/blacksimpluginfreefunctions.h b/src/plugins/simulator/fs9/blacksimpluginfreefunctions.h index d0d7ca265..4914dc7b8 100644 --- a/src/plugins/simulator/fs9/blacksimpluginfreefunctions.h +++ b/src/plugins/simulator/fs9/blacksimpluginfreefunctions.h @@ -17,34 +17,6 @@ namespace BlackSimPlugin { namespace Fs9 { - //! Safely release a COM allocated object - template - void SafeRelease(T*& pT) - { - if (pT) - pT->Release(); - pT = nullptr; - } - - //! Safely delete an allocated pointer - template - void SafeDelete(T*& pT) - { - if( pT != nullptr ) - delete pT; - pT = nullptr; - } - - //! Safely delete an allocated array - template - void SafeDeleteArray(T*& pT) - { - if(pT) - delete[] pT; - pT = nullptr; - } - - //! Print the direct play error HRESULT logDirectPlayError(HRESULT error); diff --git a/src/plugins/simulator/fs9/directplaypeer.cpp b/src/plugins/simulator/fs9/directplaypeer.cpp index 6a735a5aa..fd8ed2509 100644 --- a/src/plugins/simulator/fs9/directplaypeer.cpp +++ b/src/plugins/simulator/fs9/directplaypeer.cpp @@ -8,6 +8,7 @@ */ #include "directplaypeer.h" +#include "directplayutils.h" #include "multiplayerpacketparser.h" #include "blacksimpluginfreefunctions.h" #include "blackmisc/logmessage.h" diff --git a/src/plugins/simulator/fs9/directplayutils.h b/src/plugins/simulator/fs9/directplayutils.h new file mode 100644 index 000000000..5dd09b71e --- /dev/null +++ b/src/plugins/simulator/fs9/directplayutils.h @@ -0,0 +1,45 @@ +/* Copyright (C) 2016 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_FS9_DIRECTPLAYUTILS_H +#define BLACKSIMPLUGIN_FS9_DIRECTPLAYUTILS_H + +namespace BlackSimPlugin +{ + namespace Fs9 + { + //! Safely release a COM allocated object + template + void SafeRelease(T*& pT) + { + if (pT) { pT->Release(); } + pT = nullptr; + } + + //! Safely delete an allocated pointer + template + void SafeDelete(T*& pT) + { + delete pT; + pT = nullptr; + } + + //! Safely delete an allocated array + template + void SafeDeleteArray(T*& pT) + { + delete[] pT; + pT = nullptr; + } + } +} + +#endif diff --git a/src/plugins/simulator/fs9/fs9client.cpp b/src/plugins/simulator/fs9/fs9client.cpp index c63ff00b7..044082176 100644 --- a/src/plugins/simulator/fs9/fs9client.cpp +++ b/src/plugins/simulator/fs9/fs9client.cpp @@ -13,6 +13,7 @@ #include "multiplayerpackets.h" #include "multiplayerpacketparser.h" #include "blacksimpluginfreefunctions.h" +#include "directplayutils.h" #include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/logmessage.h" diff --git a/src/plugins/simulator/fs9/fs9host.cpp b/src/plugins/simulator/fs9/fs9host.cpp index c6ec77cad..f7693795a 100644 --- a/src/plugins/simulator/fs9/fs9host.cpp +++ b/src/plugins/simulator/fs9/fs9host.cpp @@ -10,6 +10,7 @@ #define _CRT_SECURE_NO_WARNINGS #include "blacksimpluginfreefunctions.h" +#include "directplayutils.h" #include "fs9host.h" #include "multiplayerpacketparser.h" #include "multiplayerpackets.h" diff --git a/src/plugins/simulator/fs9/lobbyclient.cpp b/src/plugins/simulator/fs9/lobbyclient.cpp index 33fb10fe7..991aac0c7 100644 --- a/src/plugins/simulator/fs9/lobbyclient.cpp +++ b/src/plugins/simulator/fs9/lobbyclient.cpp @@ -9,6 +9,7 @@ #define _CRT_SECURE_NO_WARNINGS #include "blacksimpluginfreefunctions.h" +#include "directplayutils.h" #include "blackmisc/project.h" #include "fs9.h" #include "lobbyclient.h"