summaryrefslogtreecommitdiff
path: root/shared/loki/OrderedStatic.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:10:11 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:10:11 +0200
commitc0cdb2ad99a1e2a6ade5ce76c91177a79258e669 (patch)
tree4701a015385d9a6a5a4ba99a8f1f5d400fff26b1 /shared/loki/OrderedStatic.h
parent3.13 (diff)
downloadFreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.gz
FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.bz2
FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.zip
3.14
Diffstat (limited to 'shared/loki/OrderedStatic.h')
-rw-r--r--shared/loki/OrderedStatic.h376
1 files changed, 188 insertions, 188 deletions
diff --git a/shared/loki/OrderedStatic.h b/shared/loki/OrderedStatic.h
index 6eaa20b9..0f26b6e0 100644
--- a/shared/loki/OrderedStatic.h
+++ b/shared/loki/OrderedStatic.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2005 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_ORDEREDSTATIC_INC_
@@ -27,197 +27,197 @@
namespace Loki
{
- namespace Private
+namespace Private
+{
+////////////////////////////////////////////////////////////////////////////////
+// polymorph base class for OrderedStatic template,
+// necessary because of the creator
+////////////////////////////////////////////////////////////////////////////////
+class LOKI_EXPORT OrderedStaticCreatorFunc
+{
+public:
+ virtual void createObject() = 0;
+
+protected:
+ OrderedStaticCreatorFunc();
+ virtual ~OrderedStaticCreatorFunc();
+
+private:
+ OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// template base clase for OrderedStatic template,
+// common for all specializations
+////////////////////////////////////////////////////////////////////////////////
+template<class T>
+class OrderedStaticBase : public OrderedStaticCreatorFunc
+{
+public:
+ T& operator*()
{
- ////////////////////////////////////////////////////////////////////////////////
- // polymorph base class for OrderedStatic template,
- // necessary because of the creator
- ////////////////////////////////////////////////////////////////////////////////
- class LOKI_EXPORT OrderedStaticCreatorFunc
- {
- public:
- virtual void createObject() = 0;
-
- protected:
- OrderedStaticCreatorFunc();
- virtual ~OrderedStaticCreatorFunc();
-
- private:
- OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // template base clase for OrderedStatic template,
- // common for all specializations
- ////////////////////////////////////////////////////////////////////////////////
- template<class T>
- class OrderedStaticBase : public OrderedStaticCreatorFunc
- {
- public:
- T& operator*()
- {
- return *val_;
- }
-
- T* operator->()
- {
- return val_;
- }
-
- protected:
-
- OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
- {
- }
-
- virtual ~OrderedStaticBase()
- {
- }
-
- void SetLongevity(T* ptr)
- {
- val_=ptr;
- Loki::SetLongevity(val_,longevity_);
- }
-
- private:
- OrderedStaticBase();
- OrderedStaticBase(const OrderedStaticBase&);
- OrderedStaticBase& operator=(const OrderedStaticBase&);
- T* val_;
- unsigned int longevity_;
-
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStaticManagerClass implements details
- // OrderedStaticManager is then defined as a Singleton
- ////////////////////////////////////////////////////////////////////////////////
- class LOKI_EXPORT OrderedStaticManagerClass
- {
- public:
- OrderedStaticManagerClass();
- virtual ~OrderedStaticManagerClass();
-
- typedef void (OrderedStaticCreatorFunc::*Creator)();
-
- void createObjects();
- void registerObject(unsigned int longevity,OrderedStaticCreatorFunc*,Creator);
-
- private:
- OrderedStaticManagerClass(const OrderedStaticManagerClass&);
- OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
-
- struct Data
- {
- Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
- unsigned int longevity;
- OrderedStaticCreatorFunc* object;
- Creator creator;
- };
-
- std::vector<Data> staticObjects_;
- unsigned int max_longevity_;
- unsigned int min_longevity_;
- };
-
- }// namespace Private
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStaticManager is only a Singleton typedef
- ////////////////////////////////////////////////////////////////////////////////
-
- typedef Loki::SingletonHolder
- <
- Loki::Private::OrderedStaticManagerClass,
- Loki::CreateUsingNew,
- Loki::NoDestroy,
- Loki::SingleThreaded
- >
- OrderedStaticManager;
-
- ////////////////////////////////////////////////////////////////////////////////
- // template OrderedStatic template:
- // L : longevity
- // T : object type
- // TList : creator parameters
- ////////////////////////////////////////////////////////////////////////////////
-
- template<unsigned int L, class T, class TList = Loki::NullType>
- class OrderedStatic;
-
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStatic specializations
- ////////////////////////////////////////////////////////////////////////////////
-
- template<unsigned int L, class T>
- class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
+ return *val_;
+ }
+
+ T* operator->()
{
- public:
- OrderedStatic() : Private::OrderedStaticBase<T>(L)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T);
- }
-
- private:
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- };
+ return val_;
+ }
- template<unsigned int L, class T, typename P1>
- class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
+protected:
+
+ OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
{
- public:
- OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
- }
-
- private:
- OrderedStatic();
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- P1 para_;
- };
+ }
- template<unsigned int L, class T, typename P1>
- class OrderedStatic<L, T, P1(*)() > : public Private::OrderedStaticBase<T>
+ virtual ~OrderedStaticBase()
{
- public:
-
- typedef P1(*Func)();
-
- OrderedStatic(Func p) : Private::OrderedStaticBase<T>(L), para_(p)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T(para_()));
- }
-
- private:
- OrderedStatic();
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- Func para_;
+ }
+
+ void SetLongevity(T* ptr)
+ {
+ val_=ptr;
+ Loki::SetLongevity(val_,longevity_);
+ }
+
+private:
+ OrderedStaticBase();
+ OrderedStaticBase(const OrderedStaticBase&);
+ OrderedStaticBase& operator=(const OrderedStaticBase&);
+ T* val_;
+ unsigned int longevity_;
+
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStaticManagerClass implements details
+// OrderedStaticManager is then defined as a Singleton
+////////////////////////////////////////////////////////////////////////////////
+class LOKI_EXPORT OrderedStaticManagerClass
+{
+public:
+ OrderedStaticManagerClass();
+ virtual ~OrderedStaticManagerClass();
+
+ typedef void (OrderedStaticCreatorFunc::*Creator)();
+
+ void createObjects();
+ void registerObject(unsigned int longevity,OrderedStaticCreatorFunc*,Creator);
+
+private:
+ OrderedStaticManagerClass(const OrderedStaticManagerClass&);
+ OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
+
+ struct Data
+ {
+ Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
+ unsigned int longevity;
+ OrderedStaticCreatorFunc* object;
+ Creator creator;
};
+ std::vector<Data> staticObjects_;
+ unsigned int max_longevity_;
+ unsigned int min_longevity_;
+};
+
+}// namespace Private
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStaticManager is only a Singleton typedef
+////////////////////////////////////////////////////////////////////////////////
+
+typedef Loki::SingletonHolder
+<
+Loki::Private::OrderedStaticManagerClass,
+ Loki::CreateUsingNew,
+ Loki::NoDestroy,
+ Loki::SingleThreaded
+ >
+ OrderedStaticManager;
+
+////////////////////////////////////////////////////////////////////////////////
+// template OrderedStatic template:
+// L : longevity
+// T : object type
+// TList : creator parameters
+////////////////////////////////////////////////////////////////////////////////
+
+template<unsigned int L, class T, class TList = Loki::NullType>
+class OrderedStatic;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStatic specializations
+////////////////////////////////////////////////////////////////////////////////
+
+template<unsigned int L, class T>
+class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
+{
+public:
+ OrderedStatic() : Private::OrderedStaticBase<T>(L)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T);
+ }
+
+private:
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+};
+
+template<unsigned int L, class T, typename P1>
+class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
+{
+public:
+ OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
+ }
+
+private:
+ OrderedStatic();
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+ P1 para_;
+};
+
+template<unsigned int L, class T, typename P1>
+class OrderedStatic<L, T, P1(*)() > : public Private::OrderedStaticBase<T>
+{
+public:
+
+ typedef P1(*Func)();
+
+ OrderedStatic(Func p) : Private::OrderedStaticBase<T>(L), para_(p)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T(para_()));
+ }
+
+private:
+ OrderedStatic();
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+ Func para_;
+};
+
}// namespace Loki
bgstack15