diff --git a/test/Makefile b/test/Makefile index a40ee00..56e2c88 100755 --- a/test/Makefile +++ b/test/Makefile @@ -36,7 +36,8 @@ sub-SafeFormat: FORCE sub-Singleton: FORCE cd Singleton && \ $(MAKE) -f $(MAKEFILE)-DeletableSingleton && \ - $(MAKE) -f $(MAKEFILE)-Phoenix + $(MAKE) -f $(MAKEFILE)-Phoenix && \ + $(MAKE) -f $(MAKEFILE)-Dependencies @cd .. sub-SmallObj: FORCE @@ -78,6 +79,11 @@ clean: cd SmallObj && \ $(MAKE) -f $(MAKEFILE) clean @cd .. + + cd Singleton && \ + $(MAKE) -f $(MAKEFILE)-DeletableSingleton clean&& \ + $(MAKE) -f $(MAKEFILE)-Phoenix clean && \ + $(MAKE) -f $(MAKEFILE)-Dependencies clean diff --git a/test/Singleton/Dependencies.cpp b/test/Singleton/Dependencies.cpp new file mode 100755 index 0000000..1cf66cf --- /dev/null +++ b/test/Singleton/Dependencies.cpp @@ -0,0 +1,411 @@ + + +#include + +#include "loki/SmallObj.h" +#include "loki/Function.h" + + +using namespace Loki; + + +//////////////////////////////////////////////////////////////////////////////////// +// +// How to use FollowIntoDeath with SmallObjects? +// +//////////////////////////////////////////////////////////////////////////////////// + +typedef Loki::SmallObject +< + LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL, + LOKI_DEFAULT_CHUNK_SIZE, + LOKI_MAX_SMALL_OBJECT_SIZE, + LOKI_DEFAULT_OBJECT_ALIGNMENT, + FollowIntoDeath::With::AsMasterLifetime +> +MySmallObjectBase; + +struct MySmallObject : public MySmallObjectBase +{ +}; + +typedef SingletonHolder +< + MySmallObject, + CreateUsingNew, + FollowIntoDeath::AfterMaster::IsDestroyed +> +Singleton_of_with_a_MySmallObject; + +//////////////////////////////////////////////////////////////////////////////////// +// +// How to use FollowIntoDeath with classes containing a Functor/Function? +// +//////////////////////////////////////////////////////////////////////////////////// + +struct MyFunctionObject +{ + MyFunctionObject() + { + functor = Functor (this, &MyFunctionObject::f); + function = Function< void()>(this, &MyFunctionObject::f); + } + + void f(){} + Functor functor; + Function function; + +}; + +typedef SingletonHolder +< + MyFunctionObject, + CreateUsingNew, + FollowIntoDeath::AfterMaster::Impl::ObjAllocatorSingleton + >::IsDestroyed +> +Singleton_MyFunctionObject1; + +typedef SingletonHolder +< + MyFunctionObject, + CreateUsingNew, + FollowIntoDeath::AfterMaster::Impl::ObjAllocatorSingleton + >::IsDestroyed +> +Singleton_MyFunctionObject2; + +//////////////////////////////////////////////////////////////////////////////////// +// +// Data object for all singletons +// +//////////////////////////////////////////////////////////////////////////////////// + +template