Switch to Visual Studio 2015 compiler. Test some features with Delegate class

This commit is contained in:
phobos2077
2017-02-27 01:48:54 +07:00
parent 826c3eb021
commit be0cc2f3d5
5 changed files with 51 additions and 49 deletions
+44 -45
View File
@@ -3,63 +3,62 @@
#include <functional>
#include <vector>
typedef std::function<void()> Functor; // std::function<void(ArgT...)>
typedef std::vector<Functor> FunctorCollection;
// template <typename ...ArgT>
template <typename ...ArgT>
class Delegate {
public:
Delegate() : _functors() {} // Delegate<ArgT...>()
using Functor = std::function<void(ArgT...)>;
using FunctorCollection = std::vector<Functor>;
void add(Functor func) {
_functors.emplace_back(std::move(func));
}
Delegate<ArgT...>() {}
/*void add(const Delegate<ArgT...>& other)
{
for (auto& func : other.functors())
{
add(func);
}
}*/
void add(Functor func) {
_functors.emplace_back(std::move(func));
}
void clear() {
_functors.clear();
}
void add(const Delegate<ArgT...>& other)
{
for (auto& func : other.functors())
{
add(func);
}
}
void invoke() { // invoke(ArgT... args)
for (auto it = _functors.begin(); it != _functors.end(); ++it) {
(*it)(); // args...
}
}
void clear() {
_functors.clear();
}
const FunctorCollection& functors() const {
return _functors;
}
void invoke(ArgT... args) {
for (auto& func : _functors) {
func(args...);
}
}
Delegate operator =(Functor func) {
clear();
add(std::move(func));
return *this;
}
const FunctorCollection& functors() const {
return _functors;
}
Delegate operator=(std::nullptr_t) {
clear();
return *this;
}
Delegate operator =(Functor func) {
clear();
add(std::move(func));
return *this;
}
Delegate operator +=(Functor func) {
add(std::move(func));
return *this;
}
Delegate operator=(std::nullptr_t) {
clear();
return *this;
}
Delegate operator +=(const Delegate other) {
add(other);
return *this;
}
Delegate operator +=(Functor func) {
add(std::move(func));
return *this;
}
Delegate operator +=(const Delegate other) {
add(other);
return *this;
}
private:
FunctorCollection _functors;
FunctorCollection _functors;
};
+2 -1
View File
@@ -18,6 +18,7 @@
#include "..\main.h"
#include "..\Delegate.h"
#include "..\FalloutEngine\Fallout2.h"
#include "..\InputFuncs.h"
#include "..\Logging.h"
@@ -43,7 +44,7 @@
#include "Sound.h"
#include "ExtraSaveSlots.h"
//static Delegate OnBeforeLoadGame;
static Delegate<> OnBeforeLoadGame;
//static Delegate OnAfterLoadGame;
#define MAX_GLOBAL_SIZE (MaxGlobalVars * 12 + 4)
+2 -2
View File
@@ -24,7 +24,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win2K|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -35,7 +35,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
+2
View File
@@ -20,6 +20,8 @@
#define TARGETVERSION "Fallout 2 v1.02 US"
#define LEGAL_COPYRIGHT "Copyright (C) 2006-2017, sfall team"
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_BUILD 0
+1 -1
View File
@@ -11,7 +11,7 @@ BEGIN
VALUE "FileDescription", "sfall, built for " TARGETVERSION
VALUE "FileVersion", VERSION_STRING
VALUE "InternalName", "sfall"
VALUE "LegalCopyright", "Copyright (C) 2006-2017, Timeslip"
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "ProductName", "sfall"
VALUE "ProductVersion", VERSION_STRING
END