diff --git a/ee.linux.cbp b/ee.linux.cbp
index 8dcceac53..a8f82b574 100644
--- a/ee.linux.cbp
+++ b/ee.linux.cbp
@@ -163,6 +163,7 @@
+
@@ -566,6 +567,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/ee.win.cbp b/ee.win.cbp
index 57ff900d8..0dcefd929 100644
--- a/ee.win.cbp
+++ b/ee.win.cbp
@@ -94,6 +94,8 @@
+
+
@@ -150,6 +152,8 @@
+
+
@@ -162,6 +166,7 @@
+
@@ -200,9 +205,11 @@
+
+
@@ -492,6 +499,7 @@
+
diff --git a/src/base.hpp b/src/base.hpp
index f490fb134..2793d846d 100644
--- a/src/base.hpp
+++ b/src/base.hpp
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include
#include
@@ -24,9 +25,7 @@
#include
#include
-#include
-#include
-#include
+#include "helper/PlusCallback/callback.hpp"
#include
diff --git a/src/graphics/cconsole.cpp b/src/graphics/cconsole.cpp
index 443c1fc75..a0f444ae0 100755
--- a/src/graphics/cconsole.cpp
+++ b/src/graphics/cconsole.cpp
@@ -57,9 +57,9 @@ void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUin
mHeight = (eeFloat) cEngine::instance()->GetHeight();
mHeightMin = (eeFloat) cEngine::instance()->GetHeight() * 0.4f;
- mMyCallback = cInput::instance()->PushCallback( boost::bind( &cConsole::PrivInputCallback, this, _1) );
+ mMyCallback = cInput::instance()->PushCallback( cb::Make1( this, &cConsole::PrivInputCallback ) );
- mTBuf.SetReturnCallback( boost::bind( &cConsole::ProcessLine, this ) );
+ mTBuf.SetReturnCallback( cb::Make0( this, &cConsole::ProcessLine ) );
mTBuf.Start();
mTBuf.SupportNewLine( false );
mTBuf.Active( false );
@@ -416,22 +416,22 @@ void cConsole::PrivInputCallback( EE_Event* Event ) {
}
void cConsole::CreateDefaultCommands() {
- AddCommand( L"clear", boost::bind( &cConsole::CmdClear, this, _1) );
- AddCommand( L"quit", boost::bind( &cConsole::CmdQuit, this, _1) );
- AddCommand( L"maximize", boost::bind( &cConsole::CmdMaximize, this, _1) );
- AddCommand( L"minimize", boost::bind( &cConsole::CmdMinimize, this, _1) );
- AddCommand( L"cmdlist", boost::bind( &cConsole::CmdCmdList, this, _1) );
- AddCommand( L"help", boost::bind( &cConsole::CmdCmdList, this, _1) );
- AddCommand( L"showcursor", boost::bind( &cConsole::CmdShowCursor, this, _1) );
- AddCommand( L"setframelimit", boost::bind( &cConsole::CmdFrameLimit, this, _1) );
- AddCommand( L"getlog", boost::bind( &cConsole::CmdGetLog, this, _1) );
- AddCommand( L"setgamma", boost::bind( &cConsole::CmdSetGamma, this, _1) );
- AddCommand( L"setvolume", boost::bind( &cConsole::CmdSetVolume, this, _1) );
- AddCommand( L"getgpuextensions", boost::bind( &cConsole::CmdGetGpuExtensions, this, _1) );
- AddCommand( L"dir", boost::bind( &cConsole::CmdDir, this, _1) );
- AddCommand( L"ls", boost::bind( &cConsole::CmdDir, this, _1) );
- AddCommand( L"showfps", boost::bind( &cConsole::CmdShowFps, this, _1) );
- AddCommand( L"gettexturememory", boost::bind( &cConsole::CmdGetTextureMemory, this, _1) );
+ AddCommand( L"clear", cb::Make1( this, &cConsole::CmdClear) );
+ AddCommand( L"quit", cb::Make1( this, &cConsole::CmdQuit) );
+ AddCommand( L"maximize", cb::Make1( this, &cConsole::CmdMaximize) );
+ AddCommand( L"minimize", cb::Make1( this, &cConsole::CmdMinimize) );
+ AddCommand( L"cmdlist", cb::Make1( this, &cConsole::CmdCmdList) );
+ AddCommand( L"help", cb::Make1( this, &cConsole::CmdCmdList) );
+ AddCommand( L"showcursor", cb::Make1( this, &cConsole::CmdShowCursor) );
+ AddCommand( L"setframelimit", cb::Make1( this, &cConsole::CmdFrameLimit) );
+ AddCommand( L"getlog", cb::Make1( this, &cConsole::CmdGetLog) );
+ AddCommand( L"setgamma", cb::Make1( this, &cConsole::CmdSetGamma) );
+ AddCommand( L"setvolume", cb::Make1( this, &cConsole::CmdSetVolume) );
+ AddCommand( L"getgpuextensions", cb::Make1( this, &cConsole::CmdGetGpuExtensions) );
+ AddCommand( L"dir", cb::Make1( this, &cConsole::CmdDir) );
+ AddCommand( L"ls", cb::Make1( this, &cConsole::CmdDir) );
+ AddCommand( L"showfps", cb::Make1( this, &cConsole::CmdShowFps) );
+ AddCommand( L"gettexturememory", cb::Make1( this, &cConsole::CmdGetTextureMemory) );
}
void cConsole::CmdClear () {
@@ -480,13 +480,16 @@ void cConsole::CmdCmdList ( const std::vector < std::wstring >& params ) {
void cConsole::CmdShowCursor ( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- Int32 tInt = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tInt == 0 || tInt == 1 ) {
+ Int32 tInt = 0;
+
+ bool Res = fromWString( tInt, params[1] );
+
+ if ( Res && ( tInt == 0 || tInt == 1 ) ) {
cEngine::instance()->ShowCursor( 0 != tInt );
PushText( L"showcursor " + toWStr(tInt) );
} else
PushText( L"Valid parameters are 0 or 1." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
PushText( L"Invalid Parameter. Expected int value from '" + params[1] + L"'." );
}
}
@@ -495,13 +498,16 @@ void cConsole::CmdShowCursor ( const std::vector < std::wstring >& params ) {
void cConsole::CmdFrameLimit ( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- Int32 tInt = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tInt >= 0 && tInt <= 10000 ) {
+ Int32 tInt = 0;
+
+ bool Res = fromWString( tInt, params[1] );
+
+ if ( Res && ( tInt >= 0 && tInt <= 10000 ) ) {
cEngine::instance()->SetFrameRateLimit( tInt );
PushText( L"setframelimit " + toWStr(tInt) );
} else
PushText( L"Valid parameters are between 0 and 10000 (0 = no limit)." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
PushText( L"Invalid Parameter. Expected int value from '" + params[1] + L"'." );
}
}
@@ -535,13 +541,16 @@ void cConsole::CmdGetGpuExtensions( const std::vector < std::wstring >& params )
void cConsole::CmdSetGamma( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- eeFloat tFloat = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tFloat > 0.1f && tFloat <= 10.0f ) {
+ eeFloat tFloat = 0.f;
+
+ bool Res = fromWString( tFloat, params[1] );
+
+ if ( Res && ( tFloat > 0.1f && tFloat <= 10.0f ) ) {
cEngine::instance()->SetGamma( tFloat, tFloat, tFloat );
PushText( L"setgamma " + toWStr(tFloat) );
} else
PushText( L"Valid parameters are between 0.1 and 10." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
PushText( L"Invalid Parameter. Expected float value." );
}
}
@@ -550,13 +559,16 @@ void cConsole::CmdSetGamma( const std::vector < std::wstring >& params ) {
void cConsole::CmdSetVolume( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- eeFloat tFloat = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tFloat >= 0.0f && tFloat <= 100.0f ) {
+ eeFloat tFloat = 0.f;
+
+ bool Res = fromWString( tFloat, params[1] );
+
+ if ( Res && ( tFloat >= 0.0f && tFloat <= 100.0f ) ) {
EE::Audio::cAudioListener::instance()->SetGlobalVolume( tFloat );
PushText( L"setvolume " + toWStr(tFloat) );
} else
PushText( L"Valid parameters are between 0 and 100." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
PushText( L"Invalid Parameter. Expected eeFloat value." );
}
}
@@ -567,22 +579,22 @@ void cConsole::CmdDir( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
#if EE_PLATFORM == EE_PLATFORM_WIN32
- std::string Slash( "/\\" );
+ std::wstring Slash( L"/\\" );
#else
- std::string Slash( "/" );
+ std::wstring Slash( L"/" );
#endif
- std::string myPath = wstringTostring( params[1] );
- std::string myOrder;
+ std::wstring myPath = params[1];
+ std::wstring myOrder;
if ( params.size() > 2 ) {
for ( eeUint i = 2; i < params.size(); i++ ) {
if ( i + 1 == params.size() ) {
if ( params[i] == L"ff" )
- myOrder = wstringTostring( params[i] );
+ myOrder = params[i];
else
- myPath += " " + wstringTostring( params[i] );
+ myPath += L" " + params[i];
} else {
- myPath += " " + wstringTostring( params[i] );
+ myPath += L" " + params[i];
}
}
}
@@ -590,14 +602,14 @@ void cConsole::CmdDir( const std::vector < std::wstring >& params ) {
if ( IsDirectory( myPath ) ) {
eeUint i;
- std::vector mFiles = FilesGetInPath( myPath );
+ std::vector mFiles = FilesGetInPath( myPath );
std::sort( mFiles.begin(), mFiles.end() );
- PushText( "Directory: " + myPath );
+ PushText( L"Directory: " + myPath );
- if ( myOrder == "ff" ) {
- std::vector mFolders;
- std::vector mFile;
+ if ( myOrder == L"ff" ) {
+ std::vector mFolders;
+ std::vector mFile;
for ( i = 0; i < mFiles.size(); i++ ) {
if ( IsDirectory( myPath + Slash + mFiles[i] ) ) {
@@ -611,23 +623,23 @@ void cConsole::CmdDir( const std::vector < std::wstring >& params ) {
PushText( L"Folders: " );
for ( i = 0; i < mFolders.size(); i++ )
- PushText( " " + mFolders[i] );
+ PushText( L" " + mFolders[i] );
if ( mFolders.size() )
PushText( L"Files: " );
for ( i = 0; i < mFile.size(); i++ )
- PushText( " " + mFile[i] );
+ PushText( L" " + mFile[i] );
} else {
for ( i = 0; i < mFiles.size(); i++ )
- PushText( " " + mFiles[i] );
+ PushText( L" " + mFiles[i] );
}
} else {
- if ( myPath == "help" )
- PushText( "You can use a third parameter to show folders first, the parameter is ff." );
+ if ( myPath == L"help" )
+ PushText( L"You can use a third parameter to show folders first, the parameter is ff." );
else
- PushText( "Path is not a directory." );
+ PushText( L"Path is not a directory." );
}
} catch (...) {
PushText( L"Invalid Parameter." );
@@ -638,13 +650,16 @@ void cConsole::CmdDir( const std::vector < std::wstring >& params ) {
void cConsole::CmdShowFps( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- Int32 tInt = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tInt == 0 || tInt == 1 ) {
+ Int32 tInt = 0;
+
+ bool Res = fromWString( tInt, params[1] );
+
+ if ( Res && ( tInt == 0 || tInt == 1 ) ) {
mShowFps = 0 != tInt;
PushText( L"showfps " + toWStr(tInt) );
} else
PushText( L"Valid parameters are 0 or 1." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
PushText( L"Invalid Parameter. Expected int value from '" + params[1] + L"'." );
}
}
diff --git a/src/graphics/cconsole.hpp b/src/graphics/cconsole.hpp
index b5289af20..dafb8735d 100755
--- a/src/graphics/cconsole.hpp
+++ b/src/graphics/cconsole.hpp
@@ -13,7 +13,7 @@ namespace EE { namespace Graphics {
class EE_API cConsole{
public:
//! The Console Callback return a vector of parameters ( wstring )
- typedef boost::function1 > ConsoleCallback;
+ typedef cb::Callback1& > ConsoleCallback;
cConsole();
diff --git a/src/graphics/cfont.cpp b/src/graphics/cfont.cpp
index 98e78fa24..21e3576bb 100644
--- a/src/graphics/cfont.cpp
+++ b/src/graphics/cfont.cpp
@@ -181,67 +181,77 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con
break;
}
+ Int16 tGlyphSize = mGlyphs.size();
+
for ( eeUint i = 0; i < TextCache.Text().size(); i++ ) {
Char = static_cast( TextCache.Text().at(i) );
- eeTexCoords* C = &mTexCoords[ Char ];
- switch(Char) {
- case L'\v':
- if (mVerticalDraw)
- nY += GetFontHeight();
- else
- nX += mGlyphs[ Char ].Advance;
- break;
- case L'\t':
- if (mVerticalDraw)
- nY += GetFontHeight() * 4;
- else
- nX += mGlyphs[ Char ].Advance * 4;
- break;
- case L'\n':
- if (mVerticalDraw) {
- nX += (GetFontSize() * Scale);
- nY = 0;
- } else {
- if ( i + 1 < TextCache.Text().size() ) {
- switch ( FontHAlignGet( Flags ) ) {
- case FONT_DRAW_CENTER:
- nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) );
- break;
- case FONT_DRAW_RIGHT:
- nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ];
- break;
- default:
- nX = 0;
+ if ( Char < 0 && Char > -128 )
+ Char = 256 + Char;
+
+ if ( Char >= 0 && Char < tGlyphSize ) {
+ eeTexCoords* C = &mTexCoords[ Char ];
+
+ switch(Char) {
+ case L'\v':
+ if (mVerticalDraw)
+ nY += GetFontHeight();
+ else
+ nX += mGlyphs[ Char ].Advance;
+ break;
+ case L'\t':
+ if (mVerticalDraw)
+ nY += GetFontHeight() * 4;
+ else
+ nX += mGlyphs[ Char ].Advance * 4;
+ break;
+ case L'\n':
+ if (mVerticalDraw) {
+ nX += (GetFontSize() * Scale);
+ nY = 0;
+ } else {
+ if ( i + 1 < TextCache.Text().size() ) {
+ switch ( FontHAlignGet( Flags ) ) {
+ case FONT_DRAW_CENTER:
+ nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) );
+ break;
+ case FONT_DRAW_RIGHT:
+ nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ];
+ break;
+ default:
+ nX = 0;
+ }
}
+
+ nY += (GetFontSize() * Scale);
+ Line++;
}
- nY += (GetFontSize() * Scale);
- Line++;
- }
+ break;
+ default:
+ if ( Char >= 0 && Char < tGlyphSize ) {
+ for ( Uint8 z = 0; z < 8; z+=2 ) {
+ RenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
+ RenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
+ RenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
+ RenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
+ numvert++;
+ }
- break;
- default:
- for ( Uint8 z = 0; z < 8; z+=2 ) {
- RenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
- RenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
- RenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
- RenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
- numvert++;
- }
+ #ifdef EE_GLES
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &Colors[0] ) );
+ glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) );
+ glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
- #ifdef EE_GLES
- glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &Colors[0] ) );
- glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) );
- glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
+ glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
+ #endif
- glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
- #endif
-
- if (mVerticalDraw)
- nY += GetFontHeight();
- else
- nX += mGlyphs[ Char ].Advance;
+ if (mVerticalDraw)
+ nY += GetFontHeight();
+ else
+ nX += mGlyphs[ Char ].Advance;
+ }
+ }
}
}
@@ -314,67 +324,75 @@ void cFont::SubDraw( const std::wstring& Text, const eeFloat& X, const eeFloat&
break;
}
+ Int16 tGlyphSize = mGlyphs.size();
+
for ( eeUint i = 0; i < Text.size(); i++ ) {
Char = static_cast( Text.at(i) );
- eeTexCoords* C = &mTexCoords[ Char ];
- switch(Char) {
- case L'\v':
- if (mVerticalDraw)
- nY += GetFontHeight();
- else
- nX += mGlyphs[ Char ].Advance;
- break;
- case L'\t':
- if (mVerticalDraw)
- nY += GetFontHeight() * 4;
- else
- nX += mGlyphs[ Char ].Advance * 4;
- break;
- case L'\n':
- if (mVerticalDraw) {
- nX += (GetFontSize() * Scale);
- nY = 0;
- } else {
- if ( i + 1 < Text.size() ) {
- switch ( FontHAlignGet( Flags ) ) {
- case FONT_DRAW_CENTER:
- nX = (eeFloat)( (Int32)( ( mCachedWidth - mLinesWidth[ Line ] ) * 0.5f ) );
- break;
- case FONT_DRAW_RIGHT:
- nX = mCachedWidth - mLinesWidth[ Line ];
- break;
- default:
- nX = 0;
+ if ( Char < 0 && Char > -128 )
+ Char = 256 + Char;
+
+ if ( Char >= 0 && Char < tGlyphSize ) {
+ eeTexCoords * C = &mTexCoords[ Char ];
+
+ switch( Char ) {
+ case L'\v':
+ if (mVerticalDraw)
+ nY += GetFontHeight();
+ else
+ nX += mGlyphs[ Char ].Advance;
+ break;
+ case L'\t':
+ if (mVerticalDraw)
+ nY += GetFontHeight() * 4;
+ else
+ nX += mGlyphs[ Char ].Advance * 4;
+ break;
+ case L'\n':
+ if (mVerticalDraw) {
+ nX += (GetFontSize() * Scale);
+ nY = 0;
+ } else {
+ if ( i + 1 < Text.size() ) {
+ switch ( FontHAlignGet( Flags ) ) {
+ case FONT_DRAW_CENTER:
+ nX = (eeFloat)( (Int32)( ( mCachedWidth - mLinesWidth[ Line ] ) * 0.5f ) );
+ break;
+ case FONT_DRAW_RIGHT:
+ nX = mCachedWidth - mLinesWidth[ Line ];
+ break;
+ default:
+ nX = 0;
+ }
}
+
+ nY += (GetFontSize() * Scale);
+ Line++;
}
- nY += (GetFontSize() * Scale);
- Line++;
- }
+ break;
+ default:
+ for ( Uint8 z = 0; z < 8; z+=2 ) {
+ mRenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
+ mRenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
+ mRenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
+ mRenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
+ numvert++;
+ }
- break;
- default:
- for ( Uint8 z = 0; z < 8; z+=2 ) {
- mRenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
- mRenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
- mRenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
- mRenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
- numvert++;
- }
+ #ifdef EE_GLES
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &mColors[0] ) );
+ glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[ numvert - 4 ] ) );
+ glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
- #ifdef EE_GLES
- glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &mColors[0] ) );
- glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[ numvert - 4 ] ) );
- glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
+ glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
+ #endif
- glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
- #endif
-
- if (mVerticalDraw)
- nY += GetFontHeight();
- else
- nX += mGlyphs[ Char ].Advance;
+ if ( mVerticalDraw )
+ nY += GetFontHeight();
+ else
+ nX += mGlyphs[ Char ].Advance;
+ }
}
}
@@ -394,26 +412,28 @@ void cFont::CacheWidth( const std::wstring& Text, std::vector& LinesWid
LinesWidth.clear();
eeFloat Width = 0, MaxWidth = 0;
- Uint16 CharID;
+ Int32 CharID;
Int32 Lines = 1;
for (std::size_t i = 0; i < Text.size(); ++i) {
- CharID = static_cast( Text.at(i) );
+ CharID = static_cast( Text.at(i) );
- Width += mGlyphs[CharID].Advance;
+ if ( CharID >= 0 && CharID < (Int32)mGlyphs.size() ) {
+ Width += mGlyphs[CharID].Advance;
- if ( CharID == L'\t' )
- Width += mGlyphs[CharID].Advance * 3;
+ if ( CharID == L'\t' )
+ Width += mGlyphs[CharID].Advance * 3;
- if ( CharID == L'\n' ) {
- Lines++;
- eeFloat lWidth = ( CharID == L'\t' ) ? mGlyphs[CharID].Advance * 4.f : mGlyphs[CharID].Advance;
- LinesWidth.push_back( Width - lWidth );
- Width = 0;
+ if ( CharID == L'\n' ) {
+ Lines++;
+ eeFloat lWidth = ( CharID == L'\t' ) ? mGlyphs[CharID].Advance * 4.f : mGlyphs[CharID].Advance;
+ LinesWidth.push_back( Width - lWidth );
+ Width = 0;
+ }
+
+ if ( Width > MaxWidth )
+ MaxWidth = Width;
}
-
- if ( Width > MaxWidth )
- MaxWidth = Width;
}
if ( Text.size() && Text.at( Text.size() - 1 ) != '\n' ) {
diff --git a/src/graphics/cparticlesystem.cpp b/src/graphics/cparticlesystem.cpp
index a21573fa5..60551b8dd 100755
--- a/src/graphics/cparticlesystem.cpp
+++ b/src/graphics/cparticlesystem.cpp
@@ -5,7 +5,7 @@ using namespace EE::Graphics::Private;
namespace EE { namespace Graphics {
-cParticleSystem::cParticleSystem() : mPointsSup(false), mTime(0.01f), mIsCallback(false) {
+cParticleSystem::cParticleSystem() : mPointsSup(false), mTime(0.01f) {
EE = cEngine::instance();
TF = cTextureFactory::instance();
}
@@ -76,7 +76,6 @@ void cParticleSystem::Begin() {
}
void cParticleSystem::SetCallbackReset( const ParticleCallback& pc ) {
- mIsCallback = true;
mPC = pc;
}
@@ -230,7 +229,7 @@ void cParticleSystem::Reset(cParticle* P) {
P->SetColor( eeColorAf(0.4f, 0.25f, 1.f, 1.f), 0.3f + eeRandf() * 0.2f + eeRandf() * 0.3f );
break;
case Callback:
- if (mIsCallback)
+ if ( mPC.IsSet() )
mPC(P, this);
break;
}
diff --git a/src/graphics/cparticlesystem.hpp b/src/graphics/cparticlesystem.hpp
index eebec7824..848036cc0 100755
--- a/src/graphics/cparticlesystem.hpp
+++ b/src/graphics/cparticlesystem.hpp
@@ -37,7 +37,7 @@ enum EE_PARTICLE_EFFECT {
/** @brief Basic but powerfull Particle System */
class EE_API cParticleSystem {
public:
- typedef boost::function2 ParticleCallback;
+ typedef cb::Callback2 ParticleCallback;
cParticleSystem();
~cParticleSystem();
@@ -140,7 +140,6 @@ class EE_API cParticleSystem {
void Begin();
void Reset( cParticle* P );
- bool mIsCallback;
ParticleCallback mPC;
};
diff --git a/src/helper/PlusCallback/callback.hpp b/src/helper/PlusCallback/callback.hpp
new file mode 100644
index 000000000..6553028c0
--- /dev/null
+++ b/src/helper/PlusCallback/callback.hpp
@@ -0,0 +1,2446 @@
+/*
+ * PlusCallback 1.5
+ * Copyright (c) 2009-2010 Lewis Van Winkle
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ */
+
+
+#ifndef __CALLBACK_HPP__
+#define __CALLBACK_HPP__
+
+#include
+#include
+
+
+//PlusCallback 1.5
+//This library was built on 10.03.2010 to support
+//functions with a maximum of 9 parameters.
+#define CALLBACK_VERSION 1.5
+
+
+namespace cb
+{
+
+ static const std::string unset_call_error("Attempting to invoke null callback.");
+
+
+ ///Stores a callback for a function taking 0 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback0
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback0(C* object, R (C::*function)())
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback0(R (*function)())
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback0()
+ :mCallback(0)
+ {
+ }
+
+ Callback0(const Callback0& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback0& operator=(const Callback0& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback0()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)())
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)())
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback0& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback0& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback0 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()() const
+ {
+ if (mCallback)
+ return (*mCallback)();
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call() const
+ {
+ if (mCallback)
+ return (*mCallback)();
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()() = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)())
+ :mFunc(function)
+ {}
+
+ virtual R operator()()
+ {
+ return mFunc();
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)();
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)())
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()()
+ {
+ return (mObj->*mFunc)();
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)();
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback0 Make0(C* object, R (C::*function)())
+ {
+ return Callback0(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback0 Make0(R (*function)())
+ {
+ return Callback0(function);
+ }
+
+
+ ///Stores a callback for a function taking 1 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback1
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback1(C* object, R (C::*function)(T0 t0))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback1(R (*function)(T0 t0))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback1()
+ :mCallback(0)
+ {
+ }
+
+ Callback1(const Callback1& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback1& operator=(const Callback1& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback1()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback1& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback1& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback1 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0)
+ {
+ return mFunc(t0);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0)
+ {
+ return (mObj->*mFunc)(t0);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback1 Make1(C* object, R (C::*function)(T0 t0))
+ {
+ return Callback1(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback1 Make1(R (*function)(T0 t0))
+ {
+ return Callback1(function);
+ }
+
+
+ ///Stores a callback for a function taking 2 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback2
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback2(C* object, R (C::*function)(T0 t0, T1 t1))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback2(R (*function)(T0 t0, T1 t1))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback2()
+ :mCallback(0)
+ {
+ }
+
+ Callback2(const Callback2& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback2& operator=(const Callback2& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback2()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback2& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback2& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback2 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1)
+ {
+ return mFunc(t0, t1);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1)
+ {
+ return (mObj->*mFunc)(t0, t1);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback2 Make2(C* object, R (C::*function)(T0 t0, T1 t1))
+ {
+ return Callback2(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback2 Make2(R (*function)(T0 t0, T1 t1))
+ {
+ return Callback2(function);
+ }
+
+
+ ///Stores a callback for a function taking 3 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback3
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback3(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback3(R (*function)(T0 t0, T1 t1, T2 t2))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback3()
+ :mCallback(0)
+ {
+ }
+
+ Callback3(const Callback3& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback3& operator=(const Callback3& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback3()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback3& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback3& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback3 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2)
+ {
+ return mFunc(t0, t1, t2);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2)
+ {
+ return (mObj->*mFunc)(t0, t1, t2);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback3 Make3(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2))
+ {
+ return Callback3(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback3 Make3(R (*function)(T0 t0, T1 t1, T2 t2))
+ {
+ return Callback3(function);
+ }
+
+
+ ///Stores a callback for a function taking 4 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback4
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback4(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback4(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback4()
+ :mCallback(0)
+ {
+ }
+
+ Callback4(const Callback4& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback4& operator=(const Callback4& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback4()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback4& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback4& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback4 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3)
+ {
+ return mFunc(t0, t1, t2, t3);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback4 Make4(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ {
+ return Callback4(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback4 Make4(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3))
+ {
+ return Callback4(function);
+ }
+
+
+ ///Stores a callback for a function taking 5 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback5
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback5(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback5(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback5()
+ :mCallback(0)
+ {
+ }
+
+ Callback5(const Callback5& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback5& operator=(const Callback5& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback5()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback5& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback5& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback5 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
+ {
+ return mFunc(t0, t1, t2, t3, t4);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3, t4);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback5 Make5(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ {
+ return Callback5(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback5 Make5(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4))
+ {
+ return Callback5(function);
+ }
+
+
+ ///Stores a callback for a function taking 6 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback6
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback6(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback6(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback6()
+ :mCallback(0)
+ {
+ }
+
+ Callback6(const Callback6& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback6& operator=(const Callback6& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback6()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback6& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback6& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback6 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+ {
+ return mFunc(t0, t1, t2, t3, t4, t5);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3, t4, t5);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback6 Make6(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ {
+ return Callback6(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback6 Make6(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5))
+ {
+ return Callback6(function);
+ }
+
+
+ ///Stores a callback for a function taking 7 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback7
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback7(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback7(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback7()
+ :mCallback(0)
+ {
+ }
+
+ Callback7(const Callback7& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback7& operator=(const Callback7& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback7()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback7& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback7& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback7 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+ {
+ return mFunc(t0, t1, t2, t3, t4, t5, t6);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3, t4, t5, t6);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback7 Make7(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ {
+ return Callback7(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback7 Make7(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6))
+ {
+ return Callback7(function);
+ }
+
+
+ ///Stores a callback for a function taking 8 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback8
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback8(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback8(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback8()
+ :mCallback(0)
+ {
+ }
+
+ Callback8(const Callback8& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback8& operator=(const Callback8& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback8()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback8& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback8& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback8 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6, t7);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6, t7);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+ {
+ return mFunc(t0, t1, t2, t3, t4, t5, t6, t7);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3, t4, t5, t6, t7);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback8 Make8(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ {
+ return Callback8(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback8 Make8(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7))
+ {
+ return Callback8(function);
+ }
+
+
+ ///Stores a callback for a function taking 9 parameters.
+ ///\tparam R Callback function return type.
+ template
+ class Callback9
+ {
+ public:
+ ///Constructs the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ Callback9(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ :mCallback(new(&mMem) ChildMethod(object, function))
+ {
+ }
+
+ ///Constructs the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ Callback9(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ :mCallback(new(&mMem) ChildFree(function))
+ {
+ }
+
+ ///Constructs a callback that can later be set.
+ Callback9()
+ :mCallback(0)
+ {
+ }
+
+ Callback9(const Callback9& c)
+ :mCallback(c.mCallback)
+ {
+ if (mCallback)
+ {
+ memcpy(mMem, c.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+ }
+
+ Callback9& operator=(const Callback9& rhs)
+ {
+ mCallback = rhs.mCallback;
+ if (mCallback)
+ {
+ memcpy(mMem, rhs.mMem, sizeof(mMem));
+ mCallback = reinterpret_cast(&mMem);
+ }
+
+ return *this;
+ }
+
+ ~Callback9()
+ {
+ }
+
+ ///Sets the callback to a specific object and member function.
+ ///\param object Pointer to the object to call upon. Care should be taken that this object remains valid as long as the callback may be invoked.
+ ///\param function Member function address to call.
+ template
+ void Reset(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ {
+ mCallback = new(&mMem) ChildMethod(object, function);
+ }
+
+ ///Sets the callback to a free function or static member function.
+ ///\param function Free function address to call.
+ void Reset(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ {
+ mCallback = new(&mMem) ChildFree(function);
+ }
+
+ ///Resests to callback to nothing.
+ void Reset()
+ {
+ mCallback = 0;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator==(const Callback9& rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) == (*(rhs.mCallback));
+ else
+ return mCallback == rhs.mCallback;
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator!=(const Callback9& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ ///Note that comparison operators may not work with virtual function callbacks.
+ bool operator<(const Callback9 rhs) const
+ {
+ if (mCallback && rhs.mCallback)
+ return (*mCallback) < (*(rhs.mCallback));
+ else
+ return mCallback < rhs.mCallback;
+ }
+
+ ///Returns true if the callback has been set, or false if the callback is not set and is invalid.
+ bool IsSet() const
+ {
+ return mCallback;
+ }
+
+ ///Invokes the callback.
+ R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ ///Invokes the callback. This function can sometimes be more convenient than the operator(), which does the same thing.
+ R Call(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) const
+ {
+ if (mCallback)
+ return (*mCallback)(t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ else
+ throw std::runtime_error(unset_call_error);
+ }
+
+ private:
+ class Base
+ {
+ public:
+ Base(){}
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) = 0;
+ virtual bool operator==(const Base& rhs) const = 0;
+ virtual bool operator<(const Base& rhs) const = 0;
+ virtual void* Comp() const = 0; //Returns a pointer used in comparisons.
+ };
+
+ class ChildFree : public Base
+ {
+ public:
+ ChildFree(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ :mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+ {
+ return mFunc(t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildFree* const r = dynamic_cast(&rhs);
+ if (r)
+ return mFunc < r->mFunc;
+ else
+ return true; //Free functions will always be less than methods (because comp returns 0).
+ }
+
+ virtual void* Comp() const
+ {
+ return 0;
+ }
+
+ private:
+ R (*const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8);
+ };
+
+ template
+ class ChildMethod : public Base
+ {
+ public:
+ ChildMethod(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ :mObj(object), mFunc(function)
+ {}
+
+ virtual R operator()(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+ {
+ return (mObj->*mFunc)(t0, t1, t2, t3, t4, t5, t6, t7, t8);
+ }
+
+ virtual bool operator==(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ return (mObj == r->mObj) && (mFunc == r->mFunc);
+ else
+ return false;
+ }
+
+ virtual bool operator<(const Base& rhs) const
+ {
+ const ChildMethod* const r = dynamic_cast*>(&rhs);
+ if (r)
+ {
+ if (mObj != r->mObj)
+ return mObj < r->mObj;
+ else
+ return 0 > memcmp((void*)&mFunc, (void*)&(r->mFunc), sizeof(mFunc));
+ }
+ else
+ return mObj < rhs.Comp();
+ }
+
+ virtual void* Comp() const
+ {
+ return mObj;
+ }
+
+ private:
+ C* const mObj;
+ R (C::* const mFunc)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8);
+ };
+
+ char mMem[sizeof(ChildMethod)]; //Reserve memory for creating useful objects later.
+ Base* mCallback;
+ };
+
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback9 Make9(C* object, R (C::*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ {
+ return Callback9(object, function);
+ }
+
+ ///Helper function to construct a callback without bothering to specify template parameters.
+ template
+ Callback9 Make9(R (*function)(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8))
+ {
+ return Callback9(function);
+ }
+
+}
+#endif /*__CALLBACK_HPP__*/
+
diff --git a/src/helper/libzip/config.h b/src/helper/libzip/config.h
index f464c268e..1e37c9805 100644
--- a/src/helper/libzip/config.h
+++ b/src/helper/libzip/config.h
@@ -10,7 +10,7 @@
#endif
#if (!defined (_MSCVER) && !defined (_MSC_VER))
-#define HAVE_UNISTD_H
+#define ZIP_HAVE_UNISTD_H
#endif
diff --git a/src/helper/libzip/zip_close.c b/src/helper/libzip/zip_close.c
index 2bf54b7ee..9d7768d25 100644
--- a/src/helper/libzip/zip_close.c
+++ b/src/helper/libzip/zip_close.c
@@ -45,7 +45,7 @@
#endif
#include "zipint.h"
-#ifdef HAVE_UNISTD_H
+#ifdef ZIP_HAVE_UNISTD_H
#include
#endif
diff --git a/src/helper/libzip/zip_fdopen.c b/src/helper/libzip/zip_fdopen.c
index 42fabec52..f47b0f635 100644
--- a/src/helper/libzip/zip_fdopen.c
+++ b/src/helper/libzip/zip_fdopen.c
@@ -34,7 +34,7 @@
#include "zipint.h"
-#ifdef HAVE_UNISTD_H
+#ifdef ZIP_HAVE_UNISTD_H
#include
#endif
diff --git a/src/helper/zlib/zconf.h b/src/helper/zlib/zconf.h
index 02ce56c43..36684d9f1 100644
--- a/src/helper/zlib/zconf.h
+++ b/src/helper/zlib/zconf.h
@@ -356,7 +356,7 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
+#ifdef ZIP_HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif
diff --git a/src/system/cobjectloader.cpp b/src/system/cobjectloader.cpp
index c79c145c7..92543d176 100644
--- a/src/system/cobjectloader.cpp
+++ b/src/system/cobjectloader.cpp
@@ -14,16 +14,20 @@ cObjectLoader::~cObjectLoader()
{
}
-void cObjectLoader::Load( ObjLoadCallback Cb ) {
- if ( NULL != Cb )
- mLoadCbs.push_back( Cb );
-
+void cObjectLoader::Load() {
if ( mLoaded )
SetLoaded();
Launch();
}
+void cObjectLoader::Load( ObjLoadCallback Cb ) {
+ if ( Cb.IsSet() )
+ mLoadCbs.push_back( Cb );
+
+ Load();
+}
+
void cObjectLoader::Launch() {
if ( mThreaded )
cThread::Launch();
diff --git a/src/system/cobjectloader.hpp b/src/system/cobjectloader.hpp
index 29648148c..36f19d9ef 100644
--- a/src/system/cobjectloader.hpp
+++ b/src/system/cobjectloader.hpp
@@ -8,7 +8,7 @@ namespace EE { namespace System {
class EE_API cObjectLoader : cThread {
public:
- typedef boost::function1 ObjLoadCallback;
+ typedef cb::Callback1 ObjLoadCallback;
enum ObjLoaderType {
TextureLoader = 1,
@@ -22,7 +22,9 @@ class EE_API cObjectLoader : cThread {
~cObjectLoader();
- void Load( ObjLoadCallback Cb = NULL );
+ void Load();
+
+ void Load( ObjLoadCallback Cb );
virtual void Update();
@@ -55,5 +57,3 @@ class EE_API cObjectLoader : cThread {
}}
#endif
-
-
diff --git a/src/system/cresourceloader.cpp b/src/system/cresourceloader.cpp
index 112945b80..c935fdc83 100644
--- a/src/system/cresourceloader.cpp
+++ b/src/system/cresourceloader.cpp
@@ -65,9 +65,13 @@ bool cResourceLoader::Clear( const bool& ClearObjectsLoaded ) {
}
void cResourceLoader::Load( ResLoadCallback Cb ) {
- if ( NULL != Cb )
+ if ( Cb.IsSet() )
mLoadCbs.push_back( Cb );
+ Load();
+}
+
+void cResourceLoader::Load() {
if ( mLoaded )
return;
diff --git a/src/system/cresourceloader.hpp b/src/system/cresourceloader.hpp
index 5e8fa04d4..52560c444 100644
--- a/src/system/cresourceloader.hpp
+++ b/src/system/cresourceloader.hpp
@@ -10,7 +10,7 @@ namespace EE { namespace System {
class EE_API cResourceLoader {
public:
- typedef boost::function1 ResLoadCallback;
+ typedef cb::Callback1 ResLoadCallback;
/** @param MaxThreads Set the maximun simultaneous threads to load resources, if not value is seted it will use Num Cores - 1 or 1 thread if single core. */
cResourceLoader( const Uint32& MaxThreads = THREADS_AUTO );
@@ -19,7 +19,9 @@ class EE_API cResourceLoader {
void Add( cObjectLoader * Object );
- void Load( ResLoadCallback Cb = NULL );
+ void Load( ResLoadCallback Cb );
+
+ void Load();
virtual void Update();
diff --git a/src/test/ee.cpp b/src/test/ee.cpp
index 224ea015f..eaa82fce1 100644
--- a/src/test/ee.cpp
+++ b/src/test/ee.cpp
@@ -56,7 +56,7 @@ class cUITest : public cUIControlAnim {
class cEETest : private cThread {
public:
- typedef boost::function0 SceneCb;
+ typedef cb::Callback0 SceneCb;
void Init();
void End();
@@ -250,9 +250,9 @@ void cEETest::Init() {
PS.resize(5);
- Scenes[0] = boost::bind( &cEETest::Screen1, this );
- Scenes[1] = boost::bind( &cEETest::Screen2, this );
- Scenes[2] = boost::bind( &cEETest::Screen3, this );
+ Scenes[0] = cb::Make0( this, &cEETest::Screen1 );
+ Scenes[1] = cb::Make0( this, &cEETest::Screen2 );
+ Scenes[2] = cb::Make0( this, &cEETest::Screen3 );
InBuf.Start();
@@ -266,6 +266,7 @@ void cEETest::Init() {
if ( Mus.OpenFromPack( &PAK, "music.ogg" ) ) {
Mus.Loop(true);
+ Mus.Volume( 10.f );
Mus.Play();
}
@@ -313,7 +314,7 @@ void cEETest::LoadFonts() {
mFontLoader.Add( eeNew( cTextureFontLoader, ( "conchars", eeNew( cTextureLoader, ( &PAK, "conchars.png", false, eeRGB(0,0,0) ) ), (eeUint)32 ) ) );
mFontLoader.Add( eeNew( cTextureFontLoader, ( "ProggySquareSZ", eeNew( cTextureLoader, ( &PAK, "ProggySquareSZ.png" ) ), &PAK, "ProggySquareSZ.dat" ) ) );
mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255), 1, eeColor(0,0,0), true ) ) );
- mFontLoader.Load( boost::bind( &cEETest::OnFontLoaded, this, _1 ) );
+ mFontLoader.Load( cb::Make1( this, &cEETest::OnFontLoaded ) );
}
void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) {
@@ -424,13 +425,16 @@ void cEETest::CreateUI() {
void cEETest::CmdSetPartsNum ( const std::vector < std::wstring >& params ) {
if ( params.size() >= 2 ) {
try {
- Int32 tInt = boost::lexical_cast( wstringTostring( params[1] ) );
- if ( tInt >= 0 && tInt <= 100000 ) {
+ Int32 tInt = 0;
+
+ bool Res = fromWString( tInt, params[1] );
+
+ if ( Res && ( tInt >= 0 && tInt <= 100000 ) ) {
PS[2].Create(WormHole, tInt, TN[5], EE->GetWidth() * 0.5f, EE->GetHeight() * 0.5f, 32, true);
Con.PushText( L"Wormhole Particles Number Changed to: " + toWStr(tInt) );
} else
Con.PushText( L"Valid parameters are between 0 and 100000 (0 = no limit)." );
- } catch (boost::bad_lexical_cast&) {
+ } catch (...) {
Con.PushText( L"Invalid Parameter. Expected int value from '" + params[1] + L"'." );
}
}
@@ -461,7 +465,7 @@ void cEETest::LoadTextures() {
mResLoad.Add( eeNew( cSoundLoader, ( &SndMng, "mysound", &PAK, "sound.ogg" ) ) );
- mResLoad.Load( boost::bind( &cEETest::OnTextureLoaded, this, _1 ) );
+ mResLoad.Load( cb::Make1( this, &cEETest::OnTextureLoaded ) );
TN.resize(12);
TNP.resize(12);
@@ -511,12 +515,12 @@ void cEETest::LoadTextures() {
for( Int32 mx = 0; mx < 8; mx++ )
SP.AddFrame( TN[4], 0, 0, 0, 0, eeRecti( mx * 64, my * 64, mx * 64 + 64, my * 64 + 64 ) );
- PS[0].SetCallbackReset( boost::bind( &cEETest::ParticlesCallback, this, _1, _2) );
+ PS[0].SetCallbackReset( cb::Make2( this, &cEETest::ParticlesCallback ) );
PS[0].Create(Callback, 500, TN[5], 0, 0, 16, true);
PS[1].Create(Heal, 250, TN[5], EE->GetWidth() * 0.5f, EE->GetHeight() * 0.5f, 16, true);
PS[2].Create(WormHole, PartsNum, TN[5], EE->GetWidth() * 0.5f, EE->GetHeight() * 0.5f, 32, true);
- Con.AddCommand( L"setparticlesnum", boost::bind( &cEETest::CmdSetPartsNum, this, _1) );
+ Con.AddCommand( L"setparticlesnum", cb::Make1( this, &cEETest::CmdSetPartsNum ) );
PS[3].Create(Fire, 350, TN[5], -50.f, -50.f, 32, true);
PS[4].Create(Fire, 350, TN[5], -50.f, -50.f, 32, true);
@@ -1156,7 +1160,7 @@ void cEETest::End() {
eeSAFE_DELETE( mFB );
eeSAFE_DELETE( mVBO );
eeSAFE_DELETE( mBudaTC );
-
+
cLog::instance()->Save();
cEngine::DestroySingleton();
diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp
index 2b871e2aa..b9705910c 100644
--- a/src/ui/cuicontrol.hpp
+++ b/src/ui/cuicontrol.hpp
@@ -16,7 +16,7 @@ class cUIManager;
class EE_API cUIControl {
public:
- typedef boost::function1 UIEventCallback;
+ typedef cb::Callback1 UIEventCallback;
class CreateParams {
public:
diff --git a/src/ui/cuicontrolanim.hpp b/src/ui/cuicontrolanim.hpp
index e61bb21fb..c20f29db8 100644
--- a/src/ui/cuicontrolanim.hpp
+++ b/src/ui/cuicontrolanim.hpp
@@ -29,13 +29,13 @@ class EE_API cUIControlAnim : public cUIDragable {
bool Animating();
- void StartAlphaAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = 0 );
+ void StartAlphaAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = cInterpolation::OnPathEndCallback() );
- void StartScaleAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = 0 );
+ void StartScaleAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = cInterpolation::OnPathEndCallback() );
- void StartMovement( const eeVector2i& From, const eeVector2i& To, const eeFloat& TotalTime, cWaypoints::OnPathEndCallback PathEndCallback = 0 );
+ void StartMovement( const eeVector2i& From, const eeVector2i& To, const eeFloat& TotalTime, cWaypoints::OnPathEndCallback PathEndCallback = cInterpolation::OnPathEndCallback() );
- void StartRotation( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = 0 );
+ void StartRotation( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback = cInterpolation::OnPathEndCallback() );
void CreateFadeIn( const eeFloat& Time );
diff --git a/src/ui/cuimanager.cpp b/src/ui/cuimanager.cpp
index 93a9ba70e..ecd6456b4 100644
--- a/src/ui/cuimanager.cpp
+++ b/src/ui/cuimanager.cpp
@@ -31,7 +31,7 @@ void cUIManager::Init() {
mFocusControl = mControl;
mOverControl = mControl;
- mCbId = cInput::instance()->PushCallback( boost::bind( &cUIManager::InputCallback, this, _1 ) );
+ mCbId = cInput::instance()->PushCallback( cb::Make1( this, &cUIManager::InputCallback ) );
}
void cUIManager::Shutdown() {
diff --git a/src/ui/cuitextinput.cpp b/src/ui/cuitextinput.cpp
index c4a8baed8..fa82e1ea7 100644
--- a/src/ui/cuitextinput.cpp
+++ b/src/ui/cuitextinput.cpp
@@ -12,7 +12,7 @@ cUITextInput::cUITextInput( const cUITextInput::CreateParams& Params ) :
mTextBuffer.SupportNewLine( Params.SupportNewLine );
mTextBuffer.SupportFreeEditing( Params.SupportFreeEditing );
mTextBuffer.MaxLenght( Params.MaxLenght );
- mTextBuffer.SetReturnCallback( boost::bind( &cUITextInput::OnPressEnter, this ) );
+ mTextBuffer.SetReturnCallback( cb::Make0( this, &cUITextInput::PrivOnPressEnter ) );
}
cUITextInput::~cUITextInput() {
@@ -98,6 +98,10 @@ Uint32 cUITextInput::OnPressEnter() {
return 0;
}
+void cUITextInput::PrivOnPressEnter() {
+ OnPressEnter();
+}
+
void cUITextInput::PushIgnoredChar( const Uint32& ch ) {
mTextBuffer.PushIgnoredChar( ch );
}
diff --git a/src/ui/cuitextinput.hpp b/src/ui/cuitextinput.hpp
index 40898b993..bde3ef610 100644
--- a/src/ui/cuitextinput.hpp
+++ b/src/ui/cuitextinput.hpp
@@ -15,28 +15,28 @@ class EE_API cUITextInput : public cUITextBox {
SupportFreeEditing = true;
MaxLenght = 256;
}
-
+
inline ~CreateParams() {}
-
+
bool SupportNewLine;
bool SupportFreeEditing;
Uint32 MaxLenght;
};
-
+
cUITextInput( const cUITextInput::CreateParams& Params );
-
+
~cUITextInput();
-
+
virtual void Update();
-
+
virtual void Draw();
-
+
virtual Uint32 OnFocus();
virtual Uint32 OnFocusLoss();
-
+
virtual Uint32 OnPressEnter();
-
+
void PushIgnoredChar( const Uint32& ch );
protected:
cInputTextBuffer mTextBuffer;
@@ -44,9 +44,10 @@ class EE_API cUITextInput : public cUITextBox {
eeFloat mWaitCursorTime;
eeVector2f mCurPos;
eeInt mCursorPos;
-
+
void ResetWaitCursor();
void AlignFix();
+ void PrivOnPressEnter();
};
}}
diff --git a/src/utils/cinterpolation.cpp b/src/utils/cinterpolation.cpp
index 195175b9d..83a5f8a55 100644
--- a/src/utils/cinterpolation.cpp
+++ b/src/utils/cinterpolation.cpp
@@ -16,7 +16,7 @@ cInterpolation::cInterpolation() :
mSpeed(1.3f),
mActP(NULL),
mNexP(NULL),
- mOnPathEndCallback(NULL)
+ mOnPathEndCallback()
{
}
@@ -127,13 +127,13 @@ void cInterpolation::Update( const eeFloat& Elapsed ) {
if ( mLoop ) {
mNexP = &mPoints[ 0 ];
- if ( NULL != mOnPathEndCallback )
+ if ( mOnPathEndCallback.IsSet() )
mOnPathEndCallback();
} else {
mEnable = false;
mEnded = true;
- if ( NULL != mOnPathEndCallback ) {
+ if ( mOnPathEndCallback.IsSet() ) {
mOnPathEndCallback();
mOnPathEndCallback = NULL;
}
diff --git a/src/utils/cinterpolation.hpp b/src/utils/cinterpolation.hpp
index 2aa428fbd..471e4bb60 100644
--- a/src/utils/cinterpolation.hpp
+++ b/src/utils/cinterpolation.hpp
@@ -23,7 +23,7 @@ class EE_API cInterpolation {
~cInterpolation();
- typedef boost::function0