use foreach in register code, add foreach tests
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1060 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
665abd0b92
commit
059018191f
5 changed files with 128 additions and 35 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "TypeManip.h"
|
#include "TypeManip.h"
|
||||||
#include "HierarchyGenerators.h"
|
#include "HierarchyGenerators.h"
|
||||||
|
#include "ForEachType.h"
|
||||||
|
|
||||||
|
|
||||||
/// \defgroup RegisterGroup Register
|
/// \defgroup RegisterGroup Register
|
||||||
|
|
||||||
|
@ -33,41 +35,39 @@ namespace Loki
|
||||||
/// \ingroup RegisterGroup
|
/// \ingroup RegisterGroup
|
||||||
/// Must be specialized be the user
|
/// Must be specialized be the user
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class t> bool RegisterFunction();
|
template<class T>
|
||||||
|
bool RegisterFunction();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \ingroup RegisterGroup
|
/// \ingroup RegisterGroup
|
||||||
/// Must be specialized be the user
|
/// Must be specialized be the user
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class t> bool UnRegisterFunction();
|
template<class T>
|
||||||
|
bool UnRegisterFunction();
|
||||||
|
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
template<class T>
|
|
||||||
struct RegisterOnCreate
|
struct RegisterOnCreate
|
||||||
{
|
{
|
||||||
RegisterOnCreate() { RegisterFunction<T>(); }
|
template< int Index, typename T >
|
||||||
|
void operator()()
|
||||||
|
{
|
||||||
|
RegisterFunction<T>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct UnRegisterOnDelete
|
struct UnRegisterOnDelete
|
||||||
{
|
{
|
||||||
~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
|
template< int Index, typename T >
|
||||||
};
|
void operator()()
|
||||||
|
{
|
||||||
template<class T>
|
UnRegisterFunction<T>();
|
||||||
struct RegisterOnCreateElement
|
}
|
||||||
{
|
|
||||||
RegisterOnCreate<T> registerObj;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct UnRegisterOnDeleteElement
|
|
||||||
{
|
|
||||||
UnRegisterOnDelete<T> unregisterObj;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \class RegisterOnCreateSet
|
/// \class RegisterOnCreateSet
|
||||||
///
|
///
|
||||||
|
@ -79,9 +79,14 @@ namespace Loki
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename ElementList>
|
template<typename ElementList>
|
||||||
struct RegisterOnCreateSet
|
struct RegisterOnCreateSet
|
||||||
: GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
|
{
|
||||||
{};
|
RegisterOnCreateSet()
|
||||||
|
{
|
||||||
|
Private::RegisterOnCreate d;
|
||||||
|
ForEachType< ElementList, Private::RegisterOnCreate > dummy(d);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \class UnRegisterOnDeleteSet
|
/// \class UnRegisterOnDeleteSet
|
||||||
|
@ -93,9 +98,14 @@ namespace Loki
|
||||||
/// see test/Register
|
/// see test/Register
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<typename ElementList>
|
template<typename ElementList>
|
||||||
struct UnRegisterOnDeleteSet
|
struct UnRegisterOnDeleteSet
|
||||||
: GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
|
{
|
||||||
{};
|
~UnRegisterOnDeleteSet()
|
||||||
|
{
|
||||||
|
Private::UnRegisterOnDelete d;
|
||||||
|
ForEachType< ElementList, Private::UnRegisterOnDelete > dummy(d);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1810,4 +1810,3 @@ namespace std
|
||||||
|
|
||||||
#endif // end file guardian
|
#endif // end file guardian
|
||||||
|
|
||||||
/// specialization of std::less for StroeTracker@Private@Loki@@@std@@@std@@QBEXABV123@@Z |