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 "HierarchyGenerators.h"
|
||||
#include "ForEachType.h"
|
||||
|
||||
|
||||
/// \defgroup RegisterGroup Register
|
||||
|
||||
|
@ -33,40 +35,38 @@ namespace Loki
|
|||
/// \ingroup RegisterGroup
|
||||
/// Must be specialized be the user
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<class t> bool RegisterFunction();
|
||||
template<class T>
|
||||
bool RegisterFunction();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \ingroup RegisterGroup
|
||||
/// Must be specialized be the user
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<class t> bool UnRegisterFunction();
|
||||
template<class T>
|
||||
bool UnRegisterFunction();
|
||||
|
||||
namespace Private
|
||||
{
|
||||
template<class T>
|
||||
struct RegisterOnCreate
|
||||
{
|
||||
RegisterOnCreate() { RegisterFunction<T>(); }
|
||||
template< int Index, typename T >
|
||||
void operator()()
|
||||
{
|
||||
RegisterFunction<T>();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct UnRegisterOnDelete
|
||||
{
|
||||
~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct RegisterOnCreateElement
|
||||
template< int Index, typename T >
|
||||
void operator()()
|
||||
{
|
||||
RegisterOnCreate<T> registerObj;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct UnRegisterOnDeleteElement
|
||||
{
|
||||
UnRegisterOnDelete<T> unregisterObj;
|
||||
};
|
||||
UnRegisterFunction<T>();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class RegisterOnCreateSet
|
||||
|
@ -80,8 +80,13 @@ namespace Loki
|
|||
|
||||
template<typename ElementList>
|
||||
struct RegisterOnCreateSet
|
||||
: GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
|
||||
{};
|
||||
{
|
||||
RegisterOnCreateSet()
|
||||
{
|
||||
Private::RegisterOnCreate d;
|
||||
ForEachType< ElementList, Private::RegisterOnCreate > dummy(d);
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class UnRegisterOnDeleteSet
|
||||
|
@ -94,8 +99,13 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<typename ElementList>
|
||||
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
|
||||
|
||||
/// specialization of std::less for StroeTracker@Private@Loki@@@std@@@std@@QBEXABV123@@Z |