diff --git a/.gitignore b/.gitignore index d99bbab..15e2cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ *.obj *.exe -*.dll \ No newline at end of file +*.dll +*.cbp +*.obj +*.layout +CMakeFiles/ +example diff --git a/example.cpp b/example.cpp index 26e163f..849adc5 100644 --- a/example.cpp +++ b/example.cpp @@ -2,7 +2,7 @@ * @file example.cpp * @brief Example coding demonstrating the usage of EasyDelegate. * @date 7/11/2015 - * @author Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Please refer to LICENSE.txt for more * information. @@ -18,13 +18,13 @@ 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; } @@ -32,7 +32,7 @@ void myStaticVoidMethod(const float &flt, const char *str, const double &dbl) 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; @@ -115,8 +115,8 @@ int main(int argc, char *argv[]) typedef EasyDelegate::DeferredStaticCaller 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 delegates; @@ -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(); diff --git a/include/easydelegate/delegatesCompat.hpp b/include/easydelegate/delegatesCompat.hpp index 17a361a..9ea0fd6 100644 --- a/include/easydelegate/delegatesCompat.hpp +++ b/include/easydelegate/delegatesCompat.hpp @@ -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 Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more * information. diff --git a/include/easydelegate/delegateset.hpp b/include/easydelegate/delegateset.hpp index 4353a3a..c733389 100644 --- a/include/easydelegate/delegateset.hpp +++ b/include/easydelegate/delegateset.hpp @@ -3,7 +3,7 @@ * @date 11/17/2016 * @version 3.0 * @brief Include file containing the definition for the DelegateSet class - * @author Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more * information. diff --git a/include/easydelegate/delegatesetCompat.hpp b/include/easydelegate/delegatesetCompat.hpp index 1add87c..b2ec2db 100644 --- a/include/easydelegate/delegatesetCompat.hpp +++ b/include/easydelegate/delegatesetCompat.hpp @@ -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 Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more * information. @@ -88,7 +88,6 @@ namespace EasyDelegate } va_end(parameters); - for (size_t currentIndex = 0; currentIndex < this->size(); ++currentIndex) this->operator[](currentIndex)->invokeParameters(builtParameters); } diff --git a/include/easydelegate/easydelegate.hpp b/include/easydelegate/easydelegate.hpp index cbe39af..651bc7e 100644 --- a/include/easydelegate/easydelegate.hpp +++ b/include/easydelegate/easydelegate.hpp @@ -3,10 +3,10 @@ * @date 11/17/2016 * @version 3.0 * @brief Main include file for the EasyDelegate library. - * @author Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more - * information. + * information. */ #ifndef _INCLUDE_EASYDELEGATE_HPP_ @@ -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. diff --git a/include/easydelegate/types.hpp b/include/easydelegate/types.hpp index d336f7f..115fb1d 100644 --- a/include/easydelegate/types.hpp +++ b/include/easydelegate/types.hpp @@ -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 Robert MacGregor + * @author Robert MacGregor * * @copyright This software is licensed under the MIT license. Refer to LICENSE.txt for more * information. @@ -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 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 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 struct gens : gens {}; + /** + * @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 struct gens : gens {}; - /** - * @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 struct gens<0, S...> - { - //! Helper in the expansion logic. - typedef seq 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 struct gens<0, S...> + { + //! Helper in the expansion logic. + typedef seq 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 - using NoReferenceTuple = std::tuple::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 + using NoReferenceTuple = std::tuple::type...>; #endif // EASYDELEGATE_NO_DEFERRED_CALLING #if __cplusplus >= 201103L - //! Helper typedef to a pointer of a static method with the given signature. - template - using StaticMethodPointer = returnType(*)(parameters...); + //! Helper typedef to a pointer of a static method with the given signature. + template + using StaticMethodPointer = returnType(*)(parameters...); - //! Helper typedef to a pointer of a class member method with the given signature. - template - using MemberMethodPointer = returnType(className::*)(parameters...); + //! Helper typedef to a pointer of a class member method with the given signature. + template + using MemberMethodPointer = returnType(className::*)(parameters...); #else + // C++98 compat programming - template - struct StaticMethodPointer - { - template - struct Builder + template + struct StaticMethodPointer { - typedef returnType (*pointerType)(void); + template + struct Builder + { + typedef returnType (*pointerType)(void); + }; }; - }; - template <> - struct StaticMethodPointer<1> - { - template - struct Builder + template <> + struct StaticMethodPointer<1> { - typedef returnType (*pointerType)(paramTypeOne); + template + struct Builder + { + typedef returnType (*pointerType)(paramTypeOne); + }; }; - }; - template <> - struct StaticMethodPointer<2> - { - template - struct Builder + template <> + struct StaticMethodPointer<2> { - typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo); + template + struct Builder + { + typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo); + }; }; - }; - template <> - struct StaticMethodPointer<3> - { - template - - struct Builder + template <> + struct StaticMethodPointer<3> { - typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree); + template + + struct Builder + { + typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree); + }; }; - }; - template <> - struct StaticMethodPointer<4> - { - template - struct Builder + template <> + struct StaticMethodPointer<4> { - typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour); + template + struct Builder + { + typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour); + }; }; - }; - template <> - struct StaticMethodPointer<5> - { - template - struct Builder + template <> + struct StaticMethodPointer<5> { - typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour, paramTypeFive); + template + struct Builder + { + typedef returnType (*pointerType)(paramTypeOne, paramTypeTwo, paramTypeThree, paramTypeFour, paramTypeFive); + }; }; - }; #endif } // End NameSpace EasyDelegate #endif // _INCLUDE_EASYDELEGATE_TYPES_HPP_