1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

- Moved FunctionList from /client to /lib -> used in client and server

- Updated project files
This commit is contained in:
beegee1 2013-11-30 10:08:38 +00:00
parent c786a3076a
commit 41e274b4aa
13 changed files with 102 additions and 98 deletions

View File

@ -48,7 +48,6 @@ set(client_SRCS
set(client_HEADERS
CSoundBase.h
FunctionList.h
gui/SDL_Pixels.h
)

View File

@ -2,7 +2,7 @@
#include "../lib/CondSh.h"
#include "FunctionList.h"
#include "../lib/FunctionList.h"
#include "../lib/CGameInterface.h"
#include "gui/CIntObject.h"
#include "../lib/CGameState.h"

View File

@ -4,7 +4,7 @@
#include <SDL.h>
#include "../lib/StartInfo.h"
#include "GUIClasses.h"
#include "FunctionList.h"
#include "../lib/FunctionList.h"
#include "../lib/mapping/CMapInfo.h"
#include "../lib/rmg/CMapGenerator.h"

View File

@ -1,7 +1,7 @@
#pragma once
#include "CAnimation.h"
#include "FunctionList.h"
#include "../lib/FunctionList.h"
#include "../lib/ResourceSet.h"
#include "../lib/CConfigHandler.h"
#include "../lib/GameConstants.h"

View File

@ -231,7 +231,6 @@
<ClInclude Include="CSpellWindow.h" />
<ClInclude Include="CVideoHandler.h" />
<ClInclude Include="FontBase.h" />
<ClInclude Include="FunctionList.h" />
<ClInclude Include="Graphics.h" />
<ClInclude Include="GUIClasses.h" />
<ClInclude Include="mapHandler.h" />
@ -261,4 +260,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -60,7 +60,6 @@
<ClInclude Include="CSpellWindow.h" />
<ClInclude Include="CVideoHandler.h" />
<ClInclude Include="FontBase.h" />
<ClInclude Include="FunctionList.h" />
<ClInclude Include="Graphics.h" />
<ClInclude Include="GUIClasses.h" />
<ClInclude Include="resource.h" />
@ -93,4 +92,4 @@
<None Include="..\ChangeLog" />
<None Include="vcmi.ico" />
</ItemGroup>
</Project>
</Project>

View File

@ -1,6 +1,6 @@
#pragma once
#include "../FunctionList.h"
#include "../../lib/FunctionList.h"
//#include "../CDefHandler.h"
#include "../CAnimation.h"

View File

@ -2,7 +2,7 @@
#include "CIntObject.h"
#include "SDL_Extensions.h"
#include "../FunctionList.h"
#include "../../lib/FunctionList.h"
struct SDL_Surface;
struct Rect;

View File

@ -73,8 +73,10 @@ set(lib_SRCS
set(lib_HEADERS
../Global.h
filesystem/CInputStream.h
filesystem/ISimpleResourceLoader.h
AI_Base.h
CondSh.h
ConstTransitivePtr.h
@ -82,6 +84,7 @@ set(lib_HEADERS
CRandomGenerator.h
CScriptingModule.h
CStopWatch.h
FunctionList.h
GameConstants.h
StringConstants.h
IGameEventsReceiver.h

View File

@ -1,85 +1,85 @@
#pragma once
/*
* FunctionList.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
/// List of functions that share the same signature - can be used to call all of them easily
template<typename Signature>
class CFunctionList
{
public:
std::vector<boost::function<Signature> > funcs;
CFunctionList(int){};
CFunctionList(){};
template <typename Functor>
CFunctionList(const Functor &f)
{
funcs.push_back(boost::function<Signature>(f));
}
CFunctionList(const boost::function<Signature> &first)
{
if (first)
funcs.push_back(first);
}
CFunctionList(std::nullptr_t)
{}
CFunctionList & operator+=(const boost::function<Signature> &first)
{
funcs.push_back(first);
return *this;
}
void add(const CFunctionList<Signature> &first)
{
for (size_t i = 0; i < first.funcs.size(); i++)
{
funcs.push_back(first.funcs[i]);
}
}
void clear()
{
funcs.clear();
}
operator bool() const
{
return funcs.size();
}
void operator()() const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(size_t i=0;i<funcs2.size(); ++i)
{
if (funcs2[i])
funcs2[i]();
}
}
template <typename Arg>
void operator()(const Arg & a) const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++)
{
if (funcs2[i])
funcs2[i](a);
}
}
// Me wants variadic templates :(
template <typename Arg1, typename Arg2>
void operator()(Arg1 & a, Arg2 & b) const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++)
{
if (funcs2[i])
funcs2[i](a, b);
}
}
};
#pragma once
/*
* FunctionList.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
/// List of functions that share the same signature - can be used to call all of them easily
template<typename Signature>
class CFunctionList
{
public:
std::vector<boost::function<Signature> > funcs;
CFunctionList(int){};
CFunctionList(){};
template <typename Functor>
CFunctionList(const Functor &f)
{
funcs.push_back(boost::function<Signature>(f));
}
CFunctionList(const boost::function<Signature> &first)
{
if (first)
funcs.push_back(first);
}
CFunctionList(std::nullptr_t)
{}
CFunctionList & operator+=(const boost::function<Signature> &first)
{
funcs.push_back(first);
return *this;
}
void add(const CFunctionList<Signature> &first)
{
for (size_t i = 0; i < first.funcs.size(); i++)
{
funcs.push_back(first.funcs[i]);
}
}
void clear()
{
funcs.clear();
}
operator bool() const
{
return funcs.size();
}
void operator()() const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(size_t i=0;i<funcs2.size(); ++i)
{
if (funcs2[i])
funcs2[i]();
}
}
template <typename Arg>
void operator()(const Arg & a) const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++)
{
if (funcs2[i])
funcs2[i](a);
}
}
// Me wants variadic templates :(
template <typename Arg1, typename Arg2>
void operator()(Arg1 & a, Arg2 & b) const
{
std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++)
{
if (funcs2[i])
funcs2[i](a, b);
}
}
};

View File

@ -272,6 +272,7 @@
<ClInclude Include="filesystem\CZipLoader.h" />
<ClInclude Include="filesystem\Filesystem.h" />
<ClInclude Include="filesystem\ISimpleResourceLoader.h" />
<ClInclude Include="FunctionList.h" />
<ClInclude Include="IBonusTypeHandler.h" />
<ClInclude Include="mapping\CCampaignHandler.h" />
<ClInclude Include="mapping\CMap.h" />
@ -308,4 +309,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -231,6 +231,9 @@
<ClInclude Include="Filesystem\CCompressedStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FunctionList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CModHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -316,4 +319,4 @@
<Filter>RMG</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

View File

@ -1,7 +1,7 @@
#pragma once
#include "../client/FunctionList.h"
#include "../lib/FunctionList.h"
#include "../lib/CGameState.h"
#include "../lib/Connection.h"
#include "../lib/IGameCallback.h"