more doxygen documentation, modules added

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@348 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-11-03 12:43:55 +00:00
parent 76309d2b5c
commit 7b4424b3fd
7 changed files with 311 additions and 193 deletions

View file

@ -28,13 +28,16 @@
//unreachable code if OnUnknownType throws an exception //unreachable code if OnUnknownType throws an exception
#endif #endif
/// \defgroup FactoryGroup Factory
namespace Loki namespace Loki
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template DefaultFactoryError /// \class DefaultFactoryError
// Manages the "Unknown Type" error in an object factory ///
/// \ingroup FactoryGroup
/// Manages the "Unknown Type" error in an object factory
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <typename IdentifierType, class AbstractProduct> template <typename IdentifierType, class AbstractProduct>
@ -55,48 +58,6 @@ namespace Loki
#define LOKI_ENABLE_NEW_FACTORY_CODE #define LOKI_ENABLE_NEW_FACTORY_CODE
#ifdef LOKI_ENABLE_NEW_FACTORY_CODE #ifdef LOKI_ENABLE_NEW_FACTORY_CODE
////////////////////////////////////////////////////////////////////////////////
/*
class template Factory
Implements a generic object factory
cretae functions with up to 15 parameters
template
<
class AbstractProduct,
typename IdentifierType,
typename CreatorParmTList = NullType,
template<typename, class> class FactoryErrorPolicy = ExceptionFactoryError
>
class Factory : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
{
public:
typedef Functor<AbstractProduct*, CreatorParmTList> ProductCreator;
typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
typedef typename Impl::Parm1Parm1;
// ... up to 15 Parameters
typedef typename IdToProductMap::iterator iterator;
iterator begin();
iterator end();
bool Register(const IdentifierType& id, ProductCreator creator);
bool Unregister(const IdentifierType& id);
template <class PtrObj, typename CreaFn>
bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn);
AbstractProduct* CreateObject(const IdentifierType& id);
AbstractProduct* CreateObject(const IdentifierType& id, Parm1 p1);
// ... up to 15 Parameters
};
*/
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl // class template FunctorImpl
@ -688,9 +649,47 @@ template <typename AP, typename Id, typename P1 >
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template Factory /// \class Factory
///
/// \ingroup FactoryGroup
/// Implements a generic object factory.
///
/// Create functions can have up to 15 parameters.
///
/// \code
/// template
/// <
/// class AbstractProduct,
/// typename IdentifierType,
/// typename CreatorParmTList = NullType,
/// template<typename, class> class FactoryErrorPolicy = ExceptionFactoryError
/// >
/// class Factory : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
/// {
///
/// public:
/// typedef Functor<AbstractProduct*, CreatorParmTList> ProductCreator;
/// typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
///
/// typedef typename Impl::Parm1Parm1;
/// // ... up to 15 Parameters
///
/// typedef typename IdToProductMap::iterator iterator;
/// iterator begin();
/// iterator end();
///
/// bool Register(const IdentifierType& id, ProductCreator creator);
/// bool Unregister(const IdentifierType& id);
///
/// template <class PtrObj, typename CreaFn>
/// bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn);
///
/// AbstractProduct* CreateObject(const IdentifierType& id);
/// AbstractProduct* CreateObject(const IdentifierType& id, Parm1 p1);
/// // ... up to 15 Parameters
/// };
/// \endcode
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
< <
class AbstractProduct, class AbstractProduct,
@ -972,8 +971,10 @@ template <typename AP, typename Id, typename P1 >
#endif //#define ENABLE_NEW_FACTORY_CODE #endif //#define ENABLE_NEW_FACTORY_CODE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template CloneFactory /// \class CloneFactory
// Implements a generic cloning factory ///
/// \ingroup FactoryGroup
/// Implements a generic cloning factory
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1036,6 +1037,9 @@ template <typename AP, typename Id, typename P1 >
#endif // FACTORY_INC_ #endif // FACTORY_INC_
// $Log$ // $Log$
// Revision 1.10 2005/11/03 12:43:35 syntheticpp
// more doxygen documentation, modules added
//
// Revision 1.9 2005/10/30 14:03:23 syntheticpp // Revision 1.9 2005/10/30 14:03:23 syntheticpp
// replace tabs space // replace tabs space
// //

View file

@ -18,16 +18,19 @@
namespace Loki namespace Loki
{ {
////////////////////////////////////////////////////////////////////////////////
/// \struct Function
///
/// \ingroup FunctorGroup
/// Allows a boost/TR1 like usage of Functor.
///
/// e.g. Functor<int,LOKI_TYPELIST_2(int,int)> becomes Function<int(int,int)>
////////////////////////////////////////////////////////////////////////////////
template<class R = void()> template<class R = void()>
struct Function : public Functor<R> struct Function : public Functor<R>
{ {
}; };
////////////////////////////////////////////////////////////////////////////////
// Function allows a boost/TR1 like usage of Functor.
//
// e.g. Functor<int,LOKI_TYPELIST_2(int,int)> becomes Function<int(int,int)>
////////////////////////////////////////////////////////////////////////////////
template<class R> template<class R>
struct Function<R()> : public Functor<R> struct Function<R()> : public Functor<R>
@ -42,7 +45,7 @@ namespace Loki
FBase::operator=(func); FBase::operator=(func);
} }
// emptiness // test on emptiness
template<class R2> template<class R2>
Function(Function<R2()> func) : FBase() Function(Function<R2()> func) : FBase()
{ {

View file

@ -26,6 +26,8 @@
#include <typeinfo> #include <typeinfo>
#include <memory> #include <memory>
/// \defgroup FunctorGroup Function objects
namespace Loki namespace Loki
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1127,8 +1129,10 @@ namespace Loki
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template Functor /// \class Functor
// A generalized functor implementation with value semantics ///
/// \ingroup FunctorGroup
/// A generalized functor implementation with value semantics
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <typename R = void, class TList = NullType, template <typename R = void, class TList = NullType,
template<class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL> template<class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
@ -1340,8 +1344,10 @@ namespace Loki
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template BinderFirst /// \class BinderFirst
// Binds the first parameter of a Functor object to a specific value ///
/// \ingroup FunctorGroup
/// Binds the first parameter of a Functor object to a specific value
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class OriginalFunctor> template <class OriginalFunctor>
@ -1444,8 +1450,8 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// function template BindFirst /// Binds the first parameter of a Functor object to a specific value
// Binds the first parameter of a Functor object to a specific value /// \ingroup FunctorGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class Fctor> template <class Fctor>
@ -1462,8 +1468,10 @@ namespace Loki
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template Chainer /// \class Chainer
// Chains two functor calls one after another ///
/// \ingroup FunctorGroup
/// Chains two functor calls one after another
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <typename Fun1, typename Fun2> template <typename Fun1, typename Fun2>
@ -1594,8 +1602,8 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// function template Chain /// Chains two functor calls one after another
// Chains two functor calls one after another /// \ingroup FunctorGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -300,7 +300,7 @@ namespace Loki
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Copyright (c) 2004 by Curtis Krauskopf - curtis\decompile.com /// Copyright (c) 2004 by Curtis Krauskopf - curtis@decompile.com
/// ///
/// \struct DeletableSingleton /// \struct DeletableSingleton
/// ///
@ -463,25 +463,22 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \struct FollowIntoDeath /// \class FollowIntoDeath
/// ///
/// \ingroup LifetimeGroup /// \ingroup LifetimeGroup
/// ///
/// Lifetime policyfor the SingletonHolder tempalte. /// Lifetime policyfor the SingletonHolder tempalte.
/// Followers will die after the master dies Followers will not die, if /// Followers will die after the master dies Followers will not die, if
/// - master never dies (NoDestroy policy) /// - master never dies (NoDestroy policy)
/// - master never created /// - master never created
/// - master dies not in the function registered with atexit /// - master dies not in the function registered with atexit
/// - master dies not by a call of a the atexit registerd function (DeletableSingleton::GreathFullDeath) /// - master dies not by a call of a the atexit registerd function (DeletableSingleton::GreathFullDeath)
/// ///
/// \par Usage: /// \par Usage:
/// ///
/// Lifetime of the master singleton, e.g. with a M class: /// Lifetimes of the master and the follower singletons, e.g. with a M and a F class:
/// SingletonHolder<M,FollowIntoDeath::With<DefaultLifetime>::AsMasterLifetime> MasterSingleton; /// \code SingletonHolder< M , FollowIntoDeath::With<DefaultLifetime>::AsMasterLifetime > MasterSingleton; \endcode
/// /// \code SingletonHolder< F , CreateUsingNew, FollowIntoDeath::AfterMaster< MasterSingleton >::IsDestroyed > FollowerSingleton \endcode
/// Lifetime of the follower singleton, e.g. with a F class:
///
/// SingletonHolder<F,CreateUsingNew,FollowIntoDeath::AfterMaster<MasterSingleton>::IsDestroyed>FollowerSingleton
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class FollowIntoDeath class FollowIntoDeath
{ {

View file

@ -16,13 +16,16 @@
#ifndef LOKI_SMARTPTR_INC_ #ifndef LOKI_SMARTPTR_INC_
#define LOKI_SMARTPTR_INC_ #define LOKI_SMARTPTR_INC_
//////////////////////////////////////////////////////////////////////////////// /// \defgroup SmartPointerGroup Smart pointers
// IMPORTANT NOTE /// Policy based implementation of a smart pointer
// Due to threading issues, the OwnershipPolicy has been changed as follows: /// \defgroup SmartPointerOwnershipGroup Ownership policies
// Release() returns a boolean saying if that was the last release /// \ingroup SmartPointerGroup
// so the pointer can be deleted by the StoragePolicy /// \defgroup SmartPointerStorageGroup Storage policies
// IsUnique() was removed /// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// /// \defgroup SmartPointerConversionGroup Conversion policies
/// \ingroup SmartPointerGroup
/// \defgroup SmartPointerCheckingGroup Checking policies
/// \ingroup SmartPointerGroup
#include "SmallObj.h" #include "SmallObj.h"
@ -36,8 +39,10 @@ namespace Loki
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template DefaultSPStorage /// \class DefaultSPStorage
// Implementation of the StoragePolicy used by SmartPtr ///
/// \ingroup SmartPointerStorageGroup
/// Implementation of the StoragePolicy used by SmartPtr
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class T> template <class T>
@ -95,9 +100,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RefCounted /// \class RefCounted
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Provides a classic external reference counting implementation /// \ingroup SmartPointerOwnershipGroup
/// Implementation of the OwnershipPolicy used by SmartPtr
/// Provides a classic external reference counting implementation
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -149,10 +156,12 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RefCountedMT /// \struct RefCountedMT
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Implements external reference counting for multithreaded programs /// \ingroup SmartPointerOwnershipGroup
// Policy Usage: RefCountedMTAdj<ThreadingModel>::RefCountedMT /// Implementation of the OwnershipPolicy used by SmartPtr
/// Implements external reference counting for multithreaded programs
/// Policy Usage: RefCountedMTAdj<ThreadingModel>::RefCountedMT
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <template <class> class ThreadingModel> template <template <class> class ThreadingModel>
@ -216,9 +225,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template COMRefCounted /// \class COMRefCounted
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Adapts COM intrusive reference counting to OwnershipPolicy-specific syntax /// \ingroup SmartPointerOwnershipGroup
/// Implementation of the OwnershipPolicy used by SmartPtr
/// Adapts COM intrusive reference counting to OwnershipPolicy-specific syntax
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -253,10 +264,12 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template DeepCopy /// \struct DeepCopy
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Implements deep copy semantics, assumes existence of a Clone() member /// \ingroup SmartPointerOwnershipGroup
// function of the pointee type /// Implementation of the OwnershipPolicy used by SmartPtr
/// Implements deep copy semantics, assumes existence of a Clone() member
/// function of the pointee type
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -282,9 +295,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RefLinked /// \class RefLinked
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Implements reference linking /// \ingroup SmartPointerOwnershipGroup
/// Implementation of the OwnershipPolicy used by SmartPtr
/// Implements reference linking
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace Private namespace Private
@ -384,9 +399,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template DestructiveCopy /// \class DestructiveCopy
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Implements destructive copy semantics (a la std::auto_ptr) /// \ingroup SmartPointerOwnershipGroup
/// Implementation of the OwnershipPolicy used by SmartPtr
/// Implements destructive copy semantics (a la std::auto_ptr)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -418,9 +435,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template NoCopy /// \class NoCopy
// Implementation of the OwnershipPolicy used by SmartPtr ///
// Implements a policy that doesn't allow copying objects /// \ingroup SmartPointerOwnershipGroup
/// Implementation of the OwnershipPolicy used by SmartPtr
/// Implements a policy that doesn't allow copying objects
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -452,9 +471,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template AllowConversion /// \struct AllowConversion
// Implementation of the ConversionPolicy used by SmartPtr ///
// Allows implicit conversion from SmartPtr to the pointee type /// \ingroup SmartPointerConversionGroup
/// Implementation of the ConversionPolicy used by SmartPtr
/// Allows implicit conversion from SmartPtr to the pointee type
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct AllowConversion struct AllowConversion
@ -466,10 +487,12 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template DisallowConversion /// \struct DisallowConversion
// Implementation of the ConversionPolicy used by SmartPtr ///
// Does not allow implicit conversion from SmartPtr to the pointee type /// \ingroup SmartPointerConversionGroup
// You can initialize a DisallowConversion with an AllowConversion /// Implementation of the ConversionPolicy used by SmartPtr
/// Does not allow implicit conversion from SmartPtr to the pointee type
/// You can initialize a DisallowConversion with an AllowConversion
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct DisallowConversion struct DisallowConversion
@ -487,9 +510,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template NoCheck /// \struct NoCheck
// Implementation of the CheckingPolicy used by SmartPtr ///
// Well, it's clear what it does :o) /// \ingroup SmartPointerCheckingGroup
/// Implementation of the CheckingPolicy used by SmartPtr
/// Well, it's clear what it does :o)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -517,9 +542,11 @@ namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template AssertCheck /// \struct AssertCheck
// Implementation of the CheckingPolicy used by SmartPtr ///
// Checks the pointer before dereference /// \ingroup SmartPointerCheckingGroup
/// Implementation of the CheckingPolicy used by SmartPtr
/// Checks the pointer before dereference
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -550,10 +577,12 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template AssertCheckStrict /// \struct AssertCheckStrict
// Implementation of the CheckingPolicy used by SmartPtr ///
// Checks the pointer against zero upon initialization and before dereference /// \ingroup SmartPointerCheckingGroup
// You can initialize an AssertCheckStrict with an AssertCheck /// Implementation of the CheckingPolicy used by SmartPtr
/// Checks the pointer against zero upon initialization and before dereference
/// You can initialize an AssertCheckStrict with an AssertCheck
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -588,8 +617,10 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class NullPointerException /// \struct NullPointerException
// Used by some implementations of the CheckingPolicy used by SmartPtr ///
/// \ingroup SmartPointerGroup
/// Used by some implementations of the CheckingPolicy used by SmartPtr
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct NullPointerException : public std::runtime_error struct NullPointerException : public std::runtime_error
@ -601,9 +632,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RejectNullStatic /// \struct RejectNullStatic
// Implementation of the CheckingPolicy used by SmartPtr ///
// Checks the pointer upon initialization and before dereference /// \ingroup SmartPointerCheckingGroup
/// Implementation of the CheckingPolicy used by SmartPtr
/// Checks the pointer upon initialization and before dereference
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -647,9 +680,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RejectNull /// \struct RejectNull
// Implementation of the CheckingPolicy used by SmartPtr ///
// Checks the pointer before dereference /// \ingroup SmartPointerCheckingGroup
/// Implementation of the CheckingPolicy used by SmartPtr
/// Checks the pointer before dereference
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -676,9 +711,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template RejectNullStrict /// \struct RejectNullStrict
// Implementation of the CheckingPolicy used by SmartPtr ///
// Checks the pointer upon initialization and before dereference /// \ingroup SmartPointerCheckingGroup
/// Implementation of the CheckingPolicy used by SmartPtr
/// Checks the pointer upon initialization and before dereference
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class P> template <class P>
@ -706,9 +743,11 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template ByRef /// \class ByRef
// Transports a reference as a value ///
// Serves to implement the Colvin/Gibbons trick for SmartPtr /// \ingroup SmartPointerGroup
/// Transports a reference as a value
/// Serves to implement the Colvin/Gibbons trick for SmartPtr
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <class T> template <class T>
@ -767,7 +806,21 @@ namespace Loki
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// class template SmartPtr (definition) /// \class SmartPtr
///
/// \ingroup SmartPointerGroup
///
/// \param OwnershipPolicy default = RefCounted,
/// \param ConversionPolicy default = DisallowConversion,
/// \param CheckingPolicy default = AssertCheck,
/// \param StoragePolicy default = DefaultSPStorage
///
/// \par IMPORTANT NOTE
/// Due to threading issues, the OwnershipPolicy has been changed as follows:
///
/// - Release() returns a boolean saying if that was the last release
/// so the pointer can be deleted by the StoragePolicy
/// - IsUnique() was removed
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1022,7 +1075,8 @@ namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator== for lhs = SmartPtr, rhs = raw pointer /// operator== for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1039,7 +1093,8 @@ namespace Loki
{ return GetImpl(lhs) == rhs; } { return GetImpl(lhs) == rhs; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator== for lhs = raw pointer, rhs = SmartPtr /// operator== for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1056,7 +1111,8 @@ namespace Loki
{ return rhs == lhs; } { return rhs == lhs; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator!= for lhs = SmartPtr, rhs = raw pointer /// operator!= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1073,7 +1129,8 @@ namespace Loki
{ return !(lhs == rhs); } { return !(lhs == rhs); }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator!= for lhs = raw pointer, rhs = SmartPtr /// operator!= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1090,7 +1147,8 @@ namespace Loki
{ return rhs != lhs; } { return rhs != lhs; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator< for lhs = SmartPtr, rhs = raw pointer -- NOT DEFINED /// operator< for lhs = SmartPtr, rhs = raw pointer -- NOT DEFINED
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1106,7 +1164,8 @@ namespace Loki
U* rhs); U* rhs);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator< for lhs = raw pointer, rhs = SmartPtr -- NOT DEFINED /// operator< for lhs = raw pointer, rhs = SmartPtr -- NOT DEFINED
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1122,7 +1181,8 @@ namespace Loki
const SmartPtr<T, OP, CP, KP, SP>& rhs); const SmartPtr<T, OP, CP, KP, SP>& rhs);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator> for lhs = SmartPtr, rhs = raw pointer -- NOT DEFINED // operator> for lhs = SmartPtr, rhs = raw pointer -- NOT DEFINED
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1139,7 +1199,8 @@ namespace Loki
{ return rhs < lhs; } { return rhs < lhs; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator> for lhs = raw pointer, rhs = SmartPtr /// operator> for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1156,7 +1217,8 @@ namespace Loki
{ return rhs < lhs; } { return rhs < lhs; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator<= for lhs = SmartPtr, rhs = raw pointer /// operator<= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1173,7 +1235,8 @@ namespace Loki
{ return !(rhs < lhs); } { return !(rhs < lhs); }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator<= for lhs = raw pointer, rhs = SmartPtr /// operator<= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1190,7 +1253,8 @@ namespace Loki
{ return !(rhs < lhs); } { return !(rhs < lhs); }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator>= for lhs = SmartPtr, rhs = raw pointer /// operator>= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1207,7 +1271,8 @@ namespace Loki
{ return !(lhs < rhs); } { return !(lhs < rhs); }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// operator>= for lhs = raw pointer, rhs = SmartPtr /// operator>= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
@ -1226,7 +1291,8 @@ namespace Loki
} // namespace Loki } // namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// specialization of std::less for SmartPtr /// specialization of std::less for SmartPtr
/// \ingroup SmartPointerGroup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace std namespace std
@ -1261,7 +1327,8 @@ namespace std
// In case that the macro is defined and the conversion policy allow flag is off // In case that the macro is defined and the conversion policy allow flag is off
// (e.g. DisallowConversion) then the conversion from the "pointer" to the // (e.g. DisallowConversion) then the conversion from the "pointer" to the
// SmartPtr must be explicit. // SmartPtr must be explicit.
// October 32, 2005: fix void Swap(RefLinkedBase& rhs). Peter Kümmel // October 21, 2005: fix void Swap(RefLinkedBase& rhs). Peter Kümmel
// November 3, 2005: doxygen like documentation. Peter Kümmel
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#endif // SMARTPTR_INC_ #endif // SMARTPTR_INC_

View file

@ -2,18 +2,38 @@
#define LOKI_THREADS_H_ #define LOKI_THREADS_H_
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// macro LOKI_DEFAULT_THREADING
// Selects the default threading model for certain components of Loki
// If you don't define it, it defaults to single-threaded
// All classes in Loki have configurable threading model; LOKI_DEFAULT_THREADING
// affects only default template arguments
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Header$ // $Header$
/*! /// @defgroup ThreadingGroup Threading
@defgroup ThreadingGroup Threading /// Policies to for the threading model:
*/ ///
/// - SingleThreaded
/// - ObjectLevelLockable
/// - ClassLevelLockable
///
/// All classes in Loki have configurable threading model.
///
/// The macro LOKI_DEFAULT_THREADING selects the default
/// threading model for certain components of Loki
/// (it affects only default template arguments)
///
/// \par Usage:
///
/// To use a specific threading model define
///
/// - nothing, single-theading is default
/// - LOKI_OBJECT_LEVEL_THREADING for object-level-threading
/// - LOKI_CLASS_LEVEL_THREADING for class-level-threading
///
/// \par Supported platfroms:
///
/// - Windows (windows.h)
/// - POSIX (pthread.h)
#if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING) #if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING)
@ -43,17 +63,19 @@
namespace Loki namespace Loki
{ {
/*! ////////////////////////////////////////////////////////////////////////////////
\class SingleThreaded /// \class SingleThreaded
\ingroup ThreadingGroup ///
/// \ingroup ThreadingGroup
Implementation of the ThreadingModel policy used by various classes /// Implementation of the ThreadingModel policy used by various classes
Implements a single-threaded model; no synchronization /// Implements a single-threaded model; no synchronization
*/ ////////////////////////////////////////////////////////////////////////////////
template <class Host> template <class Host>
class SingleThreaded class SingleThreaded
{ {
public: public:
/// \struct Lock
/// Dummy Lock class
struct Lock struct Lock
{ {
Lock() {} Lock() {}
@ -150,14 +172,13 @@ namespace Loki
#if defined(_WINDOWS_) || defined(_WINDOWS_H) || defined(_PTHREAD_H) #if defined(_WINDOWS_) || defined(_WINDOWS_H) || defined(_PTHREAD_H)
/*! ////////////////////////////////////////////////////////////////////////////////
\class ObjectLevelLockable /// \class ObjectLevelLockable
\ingroup ThreadingGroup ///
/// \ingroup ThreadingGroup
class template ObjectLevelLockable /// Implementation of the ThreadingModel policy used by various classes
Implementation of the ThreadingModel policy used by various classes /// Implements a object-level locking scheme
Implements a object-level locking scheme ////////////////////////////////////////////////////////////////////////////////
*/
template <class Host> template <class Host>
class ObjectLevelLockable class ObjectLevelLockable
{ {
@ -182,26 +203,32 @@ namespace Loki
class Lock; class Lock;
friend class Lock; friend class Lock;
/// \struct Lock
/// Lock class to lock on object level
class Lock class Lock
{ {
public: public:
/// Lock object
explicit Lock(const ObjectLevelLockable& host) : host_(host) explicit Lock(const ObjectLevelLockable& host) : host_(host)
{ {
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_); LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
} }
/// Lock object
explicit Lock(const ObjectLevelLockable* host) : host_(*host) explicit Lock(const ObjectLevelLockable* host) : host_(*host)
{ {
LOKI_THREADS_MUTEX_LOCK(&host_.mtx_); LOKI_THREADS_MUTEX_LOCK(&host_.mtx_);
} }
/// Unlock object
~Lock() ~Lock()
{ {
LOKI_THREADS_MUTEX_UNLOCK(&host_.mtx_); LOKI_THREADS_MUTEX_UNLOCK(&host_.mtx_);
} }
private: private:
/// private by design of the object level threading
Lock(); Lock();
Lock(const Lock&); Lock(const Lock&);
Lock& operator=(const Lock&); Lock& operator=(const Lock&);
@ -221,14 +248,13 @@ namespace Loki
pthread_mutex_t ObjectLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER); pthread_mutex_t ObjectLevelLockable<Host>::atomic_mutex_(PTHREAD_MUTEX_INITIALIZER);
#endif #endif
////////////////////////////////////////////////////////////////////////////////
/*! /// \class ClassLevelLockable
\class ClassLevelLockable ///
\ingroup ThreadingGroup /// \ingroup ThreadingGroup
/// Implementation of the ThreadingModel policy used by various classes
Implementation of the ThreadingModel policy used by various classes /// Implements a class-level locking scheme
Implements a class-level locking scheme ////////////////////////////////////////////////////////////////////////////////
*/
template <class Host> template <class Host>
class ClassLevelLockable class ClassLevelLockable
{ {
@ -256,28 +282,34 @@ namespace Loki
class Lock; class Lock;
friend class Lock; friend class Lock;
/// \struct Lock
/// Lock class to lock on class level
class Lock class Lock
{ {
public: public:
/// Lock class
Lock() Lock()
{ {
assert(initializer_.init_); assert(initializer_.init_);
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_); LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
} }
/// Lock class
explicit Lock(const ClassLevelLockable&) explicit Lock(const ClassLevelLockable&)
{ {
assert(initializer_.init_); assert(initializer_.init_);
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_); LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
} }
/// Lock class
explicit Lock(const ClassLevelLockable*) explicit Lock(const ClassLevelLockable*)
{ {
assert(initializer_.init_); assert(initializer_.init_);
LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_); LOKI_THREADS_MUTEX_LOCK(&initializer_.mtx_);
} }
/// Unlock class
~Lock() ~Lock()
{ {
assert(initializer_.init_); assert(initializer_.init_);
@ -322,6 +354,9 @@ namespace Loki
#endif #endif
// $Log$ // $Log$
// Revision 1.18 2005/11/03 12:43:35 syntheticpp
// more doxygen documentation, modules added
//
// Revision 1.17 2005/11/02 20:01:10 syntheticpp // Revision 1.17 2005/11/02 20:01:10 syntheticpp
// more doxygen documentation, modules added // more doxygen documentation, modules added
// //

View file

@ -712,6 +712,7 @@ inline std::size_t GetOffset( std::size_t numBytes, std::size_t alignment )
Calls the default allocator when SmallObjAllocator decides not to handle a Calls the default allocator when SmallObjAllocator decides not to handle a
request. SmallObjAllocator calls this if the number of bytes is bigger than request. SmallObjAllocator calls this if the number of bytes is bigger than
the size which can be handled by any FixedAllocator. the size which can be handled by any FixedAllocator.
@param numBytes number of bytes
@param doThrow True if this function should throw an exception, or false if it @param doThrow True if this function should throw an exception, or false if it
should indicate failure by returning a NULL pointer. should indicate failure by returning a NULL pointer.
*/ */
@ -886,6 +887,9 @@ void SmallObjAllocator::Deallocate( void * p )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Log$ // $Log$
// Revision 1.17 2005/11/03 12:43:55 syntheticpp
// more doxygen documentation, modules added
//
// Revision 1.16 2005/11/02 20:01:11 syntheticpp // Revision 1.16 2005/11/02 20:01:11 syntheticpp
// more doxygen documentation, modules added // more doxygen documentation, modules added
// //