Skip to content

Commit

Permalink
Minor formatting updates; update the dx.no-ip.org URL's; update copyr…
Browse files Browse the repository at this point in the history
…ight dates
  • Loading branch information
Ragora committed Feb 17, 2017
1 parent 68a8ccc commit bcc0168
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 103 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.obj
*.exe
*.dll
*.dll
*.cbp
*.obj
*.layout
CMakeFiles/
example
14 changes: 7 additions & 7 deletions example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file example.cpp
* @brief Example coding demonstrating the usage of EasyDelegate.
* @date 7/11/2015
* @author Robert MacGregor
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Please refer to LICENSE.txt for more
* information.
Expand All @@ -18,21 +18,21 @@

using namespace std;

unsigned int myStaticIntMethod(const char *str, const float &flt, const double &dbl)
unsigned int myStaticIntMethod(const char* str, const float& flt, const double& dbl)
{
cout << "myStaticIntMethod: " << str << "," << flt << "," << dbl << endl;
return 5;
}

void myStaticVoidMethod(const float &flt, const char *str, const double &dbl)
void myStaticVoidMethod(const float& flt, const char* str, const double& dbl)
{
cout << "myStaticVoidMethod: " << flt << "," << str << "," << dbl << endl;
}

class MyCustomClass
{
public:
unsigned int myMemberMethod(const char *str, const float &flt, const double &dbl)
unsigned int myMemberMethod(const char* str, const float& flt, const double &dbl)
{
cout << "MyCustomClass::myMemberMethod: " << str << "," << flt << "," << dbl << endl;
return 2;
Expand Down Expand Up @@ -115,8 +115,8 @@ int main(int argc, char *argv[])
typedef EasyDelegate::DeferredStaticCaller<void, const float&, const char*, const double&> MyCachedVoidStaticDelegateType;

// Allocate our delegate types
MyCachedIntMemberDelegateType *cachedMemberDelegate = new MyCachedIntMemberDelegateType(&MyCustomClass::myMemberMethod, myCustomClassInstance, "Cached", 3.14, 3.14159);
MyCachedVoidStaticDelegateType *cachedStaticDelegate = new MyCachedVoidStaticDelegateType(myStaticVoidMethod, 8.15f, "Cached", 3.14f);
MyCachedIntMemberDelegateType* cachedMemberDelegate = new MyCachedIntMemberDelegateType(&MyCustomClass::myMemberMethod, myCustomClassInstance, "Cached", 3.14, 3.14159);
MyCachedVoidStaticDelegateType* cachedStaticDelegate = new MyCachedVoidStaticDelegateType(myStaticVoidMethod, 8.15f, "Cached", 3.14f);

// Now store these in a set
vector<EasyDelegate::IDeferredCaller *> delegates;
Expand All @@ -125,7 +125,7 @@ int main(int argc, char *argv[])
delegates.push_back(cachedStaticDelegate);

// Iterate
for (auto it = delegates.begin(); it != delegates.end(); it++)
for (auto it = delegates.begin(); it != delegates.end(); ++it)
{
cout << "Invoking Delegate " << endl;
(*it)->genericDispatch();
Expand Down
4 changes: 2 additions & 2 deletions include/easydelegate/delegatesCompat.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @file delegates.hpp
* @file delegatesCompat.hpp
* @date 11/17/2016
* @version 3.0
* @brief Include file declaring various delegate types.
* @author <a href="http://dx.no-ip.org">Robert MacGregor</a>
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more
* information.
Expand Down
2 changes: 1 addition & 1 deletion include/easydelegate/delegateset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @date 11/17/2016
* @version 3.0
* @brief Include file containing the definition for the DelegateSet class
* @author <a href="http://dx.no-ip.org">Robert MacGregor</a>
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more
* information.
Expand Down
5 changes: 2 additions & 3 deletions include/easydelegate/delegatesetCompat.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @file delegateset.hpp
* @file delegatesetCompat.hpp
* @date 11/17/2016
* @version 3.0
* @brief Include file containing the definition for the DelegateSet class
* @author <a href="http://dx.no-ip.org">Robert MacGregor</a>
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more
* information.
Expand Down Expand Up @@ -88,7 +88,6 @@ namespace EasyDelegate
}

va_end(parameters);

for (size_t currentIndex = 0; currentIndex < this->size(); ++currentIndex)
this->operator[](currentIndex)->invokeParameters(builtParameters);
}
Expand Down
14 changes: 7 additions & 7 deletions include/easydelegate/easydelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* @date 11/17/2016
* @version 3.0
* @brief Main include file for the EasyDelegate library.
* @author <a href="http://dx.no-ip.org">Robert MacGregor</a>
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more
* information.
* information.
*/

#ifndef _INCLUDE_EASYDELEGATE_HPP_
Expand Down Expand Up @@ -47,12 +47,12 @@
#include "types.hpp"

#if __cplusplus >= 201103L
#include "delegates.hpp"
#include "delegateset.hpp"
#include "deferredcallers.hpp"
#include "delegates.hpp"
#include "delegateset.hpp"
#include "deferredcallers.hpp"
#else
#include "delegatesCompat.hpp"
#include "delegatesetCompat.hpp"
#include "delegatesCompat.hpp"
#include "delegatesetCompat.hpp"
#endif

//! Namespace containing all EasyDelegate functionality.
Expand Down
165 changes: 83 additions & 82 deletions include/easydelegate/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @version 3.0
* @brief Include file declaring various helper types used by the EasyDelegate library. They
* may also aid programmers using the library as well.
* @author <a href="http://dx.no-ip.org">Robert MacGregor</a>
* @author <a href="https://dx.no-ip.org">Robert MacGregor</a>
*
* @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more
* information.
Expand All @@ -21,115 +21,116 @@
namespace EasyDelegate
{
#ifndef EASYDELEGATE_NO_DEFERRED_CALLING
/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int ...> struct seq {};
/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int ...> struct seq {};

/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int N, int ...S> struct gens : gens<N-1, N-1, S...> {};
/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int N, int ...S> struct gens : gens<N-1, N-1, S...> {};

/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int ...S> struct gens<0, S...>
{
//! Helper in the expansion logic.
typedef seq<S...> type;
};
/**
* @brief Part of a helper template that is used to statically unpack tuples for
* the deferring calling system.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
*/
template<int ...S> struct gens<0, S...>
{
//! Helper in the expansion logic.
typedef seq<S...> type;
};
#endif

#ifndef EASYDELEGATE_NO_DEFERRED_CALLING
/**
* @brief A helper typedef for an std::tuple that removes the reference from referenced types.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/12742877/remove-reference-from-stdtuple-members
*/
template <typename... typenames>
using NoReferenceTuple = std::tuple<typename std::remove_reference<typenames>::type...>;
/**
* @brief A helper typedef for an std::tuple that removes the reference from referenced types.
*
* @details Taken from the chosen answer of http://stackoverflow.com/questions/12742877/remove-reference-from-stdtuple-members
*/
template <typename... typenames>
using NoReferenceTuple = std::tuple<typename std::remove_reference<typenames>::type...>;
#endif // EASYDELEGATE_NO_DEFERRED_CALLING

#if __cplusplus >= 201103L
//! Helper typedef to a pointer of a static method with the given signature.
template <typename returnType, typename... parameters>
using StaticMethodPointer = returnType(*)(parameters...);
//! Helper typedef to a pointer of a static method with the given signature.
template <typename returnType, typename... parameters>
using StaticMethodPointer = returnType(*)(parameters...);

//! Helper typedef to a pointer of a class member method with the given signature.
template <typename className, typename returnType, typename... parameters>
using MemberMethodPointer = returnType(className::*)(parameters...);
//! Helper typedef to a pointer of a class member method with the given signature.
template <typename className, typename returnType, typename... parameters>
using MemberMethodPointer = returnType(className::*)(parameters...);
#else
// C++98 compat programming

template <unsigned int paramCount>
struct StaticMethodPointer
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
template <unsigned int paramCount>
struct StaticMethodPointer
{
typedef returnType (*pointerType)(void);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
{
typedef returnType (*pointerType)(void);
};
};
};

template <>
struct StaticMethodPointer<1>
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
template <>
struct StaticMethodPointer<1>
{
typedef returnType (*pointerType)(paramTypeOne);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
{
typedef returnType (*pointerType)(paramTypeOne);
};
};
};

template <>
struct StaticMethodPointer<2>
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
template <>
struct StaticMethodPointer<2>
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo);
};
};
};

template <>
struct StaticMethodPointer<3>
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>

struct Builder
template <>
struct StaticMethodPointer<3>
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>

struct Builder
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree);
};
};
};

template <>
struct StaticMethodPointer<4>
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
template <>
struct StaticMethodPointer<4>
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour);
};
};
};

template <>
struct StaticMethodPointer<5>
{
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
template <>
struct StaticMethodPointer<5>
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour, paramTypeFive);
template <typename returnType, typename paramTypeOne = int, typename paramTypeTwo = int, typename paramTypeThree = int, typename paramTypeFour = int, typename paramTypeFive = int>
struct Builder
{
typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour, paramTypeFive);
};
};
};
#endif
} // End NameSpace EasyDelegate
#endif // _INCLUDE_EASYDELEGATE_TYPES_HPP_

0 comments on commit bcc0168

Please sign in to comment.