Loki header files now all have consistent include statement style.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1069 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
ae4fbd418d
commit
6bc2851497
16 changed files with 773 additions and 773 deletions
|
@ -2,14 +2,14 @@
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||||
// This code accompanies the book:
|
// This code accompanies the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author or Addison-Wesley Longman make no representations about the
|
// The author or Addison-Wesley Longman make no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_ABSTRACTFACTORY_INC_
|
#ifndef LOKI_ABSTRACTFACTORY_INC_
|
||||||
|
@ -18,10 +18,10 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "Sequence.h"
|
#include <loki/Sequence.h>
|
||||||
#include "TypeManip.h"
|
#include <loki/TypeManip.h>
|
||||||
#include "HierarchyGenerators.h"
|
#include <loki/HierarchyGenerators.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
* \ingroup FactoriesGroup
|
* \ingroup FactoriesGroup
|
||||||
* \brief Implements an abstract object factory.
|
* \brief Implements an abstract object factory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class AbstractFactory
|
* \class AbstractFactory
|
||||||
* \ingroup AbstractFactoryGroup
|
* \ingroup AbstractFactoryGroup
|
||||||
|
@ -68,14 +68,14 @@ namespace Loki
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef TList ProductList;
|
typedef TList ProductList;
|
||||||
|
|
||||||
template <class T> T* Create()
|
template <class T> T* Create()
|
||||||
{
|
{
|
||||||
Unit<T>& unit = *this;
|
Unit<T>& unit = *this;
|
||||||
return unit.DoCreate(Type2Type<T>());
|
return unit.DoCreate(Type2Type<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template OpNewFactoryUnit
|
// class template OpNewFactoryUnit
|
||||||
// Creates an object by invoking the new operator
|
// Creates an object by invoking the new operator
|
||||||
|
@ -85,10 +85,10 @@ namespace Loki
|
||||||
class OpNewFactoryUnit : public Base
|
class OpNewFactoryUnit : public Base
|
||||||
{
|
{
|
||||||
typedef typename Base::ProductList BaseProductList;
|
typedef typename Base::ProductList BaseProductList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef typename BaseProductList::Tail ProductList;
|
typedef typename BaseProductList::Tail ProductList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename BaseProductList::Head AbstractProduct;
|
typedef typename BaseProductList::Head AbstractProduct;
|
||||||
ConcreteProduct* DoCreate(Type2Type<AbstractProduct>)
|
ConcreteProduct* DoCreate(Type2Type<AbstractProduct>)
|
||||||
|
@ -101,7 +101,7 @@ namespace Loki
|
||||||
// class template PrototypeFactoryUnit
|
// class template PrototypeFactoryUnit
|
||||||
// Creates an object by cloning a prototype
|
// Creates an object by cloning a prototype
|
||||||
// There is a difference between the implementation herein and the one described
|
// There is a difference between the implementation herein and the one described
|
||||||
// in the book: GetPrototype and SetPrototype use the helper friend
|
// in the book: GetPrototype and SetPrototype use the helper friend
|
||||||
// functions DoGetPrototype and DoSetPrototype. The friend functions avoid
|
// functions DoGetPrototype and DoSetPrototype. The friend functions avoid
|
||||||
// name hiding issues. Plus, GetPrototype takes a reference to pointer
|
// name hiding issues. Plus, GetPrototype takes a reference to pointer
|
||||||
// instead of returning the pointer by value.
|
// instead of returning the pointer by value.
|
||||||
|
@ -111,7 +111,7 @@ namespace Loki
|
||||||
class PrototypeFactoryUnit : public Base
|
class PrototypeFactoryUnit : public Base
|
||||||
{
|
{
|
||||||
typedef typename Base::ProductList BaseProductList;
|
typedef typename Base::ProductList BaseProductList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef typename BaseProductList::Tail ProductList;
|
typedef typename BaseProductList::Tail ProductList;
|
||||||
|
|
||||||
|
@ -133,17 +133,17 @@ namespace Loki
|
||||||
template <class U>
|
template <class U>
|
||||||
void GetPrototype(U*& p)
|
void GetPrototype(U*& p)
|
||||||
{ return DoGetPrototype(*this, p); }
|
{ return DoGetPrototype(*this, p); }
|
||||||
|
|
||||||
template <class U>
|
template <class U>
|
||||||
void SetPrototype(U* pObj)
|
void SetPrototype(U* pObj)
|
||||||
{ DoSetPrototype(*this, pObj); }
|
{ DoSetPrototype(*this, pObj); }
|
||||||
|
|
||||||
AbstractProduct* DoCreate(Type2Type<AbstractProduct>)
|
AbstractProduct* DoCreate(Type2Type<AbstractProduct>)
|
||||||
{
|
{
|
||||||
assert(pPrototype_);
|
assert(pPrototype_);
|
||||||
return pPrototype_->Clone();
|
return pPrototype_->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractProduct* pPrototype_;
|
AbstractProduct* pPrototype_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Data Generator by Shannon Barber
|
// Data Generator by Shannon Barber
|
||||||
// This code DOES NOT accompany the book:
|
// This code DOES NOT accompany the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
//
|
//
|
||||||
// Code covered by the MIT License
|
// Code covered by the MIT License
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
|
|
||||||
//Reference version
|
//Reference version
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace Loki
|
||||||
};
|
};
|
||||||
template <class TList, template <class> class GenFunc>
|
template <class TList, template <class> class GenFunc>
|
||||||
struct IterateTypes;
|
struct IterateTypes;
|
||||||
|
|
||||||
template <class T1, class T2, template <class> class GenFunc>
|
template <class T1, class T2, template <class> class GenFunc>
|
||||||
struct IterateTypes<Typelist<T1, T2>, GenFunc>
|
struct IterateTypes<Typelist<T1, T2>, GenFunc>
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ namespace Loki
|
||||||
tail.operator()(ii);
|
tail.operator()(ii);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class AtomicType, template <class> class GenFunc>
|
template <class AtomicType, template <class> class GenFunc>
|
||||||
struct IterateTypes
|
struct IterateTypes
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ namespace Loki
|
||||||
++ii; //Is this even needed?
|
++ii; //Is this even needed?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <template <class> class GenFunc>
|
template <template <class> class GenFunc>
|
||||||
struct IterateTypes<NullType, GenFunc>
|
struct IterateTypes<NullType, GenFunc>
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ namespace Loki
|
||||||
void operator()(II ii)
|
void operator()(II ii)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Types, template <class> class UnitFunc, typename II>
|
template<typename Types, template <class> class UnitFunc, typename II>
|
||||||
void iterate_types(II ii)
|
void iterate_types(II ii)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "LokiTypeInfo.h"
|
#include <loki/LokiTypeInfo.h>
|
||||||
#include "Functor.h"
|
#include <loki/Functor.h>
|
||||||
#include "AssocVector.h"
|
#include <loki/AssocVector.h>
|
||||||
#include "SmallObj.h"
|
#include <loki/SmallObj.h>
|
||||||
#include "Sequence.h"
|
#include <loki/Sequence.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
* \defgroup FactoryGroup Factory
|
* \defgroup FactoryGroup Factory
|
||||||
* \ingroup FactoriesGroup
|
* \ingroup FactoriesGroup
|
||||||
* \brief Implements a generic object factory.
|
* \brief Implements a generic object factory.
|
||||||
*
|
*
|
||||||
* <i>The Factory Method pattern is an object-oriented design pattern.
|
* <i>The Factory Method pattern is an object-oriented design pattern.
|
||||||
* Like other creational patterns, it deals with the problem of creating objects
|
* Like other creational patterns, it deals with the problem of creating objects
|
||||||
* (products) without specifying the exact class of object that will be created.
|
* (products) without specifying the exact class of object that will be created.
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
* whose main purpose is creation of objects.</i>
|
* whose main purpose is creation of objects.</i>
|
||||||
* <div ALIGN="RIGHT"><a href="http://en.wikipedia.org/wiki/Factory_method_pattern">
|
* <div ALIGN="RIGHT"><a href="http://en.wikipedia.org/wiki/Factory_method_pattern">
|
||||||
* Wikipedia</a></div>
|
* Wikipedia</a></div>
|
||||||
*
|
*
|
||||||
* Loki proposes a generic version of the Factory. Here is a typical use.<br>
|
* Loki proposes a generic version of the Factory. Here is a typical use.<br>
|
||||||
* <code><br>
|
* <code><br>
|
||||||
* 1. Factory< AbstractProduct, int > aFactory;<br>
|
* 1. Factory< AbstractProduct, int > aFactory;<br>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
* ProductCreator by registering them into the Factory.<br>
|
* ProductCreator by registering them into the Factory.<br>
|
||||||
* A ProductCreator is a just a function that will return the right object. ie <br>
|
* A ProductCreator is a just a function that will return the right object. ie <br>
|
||||||
* <code>
|
* <code>
|
||||||
* Product* createProductNull()<br>
|
* Product* createProductNull()<br>
|
||||||
* {<br>
|
* {<br>
|
||||||
* return new Product<br>
|
* return new Product<br>
|
||||||
* }<br>
|
* }<br>
|
||||||
|
@ -80,11 +80,11 @@ namespace Loki
|
||||||
* \defgroup FactoryErrorPoliciesGroup Factory Error Policies
|
* \defgroup FactoryErrorPoliciesGroup Factory Error Policies
|
||||||
* \ingroup FactoryGroup
|
* \ingroup FactoryGroup
|
||||||
* \brief Manages the "Unknown Type" error in an object factory
|
* \brief Manages the "Unknown Type" error in an object factory
|
||||||
*
|
*
|
||||||
* \class DefaultFactoryError
|
* \class DefaultFactoryError
|
||||||
* \ingroup FactoryErrorPoliciesGroup
|
* \ingroup FactoryErrorPoliciesGroup
|
||||||
* \brief Default policy that throws an exception
|
* \brief Default policy that throws an exception
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename IdentifierType, class AbstractProduct>
|
template <typename IdentifierType, class AbstractProduct>
|
||||||
|
@ -1065,9 +1065,9 @@ template <typename AP, typename Id, typename P1 >
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename IdToProductMap::iterator i =
|
typename IdToProductMap::iterator i =
|
||||||
associations_.find(typeid(*model));
|
associations_.find(typeid(*model));
|
||||||
|
|
||||||
if (i != associations_.end())
|
if (i != associations_.end())
|
||||||
{
|
{
|
||||||
return (i->second)(model);
|
return (i->second)(model);
|
||||||
|
@ -1079,7 +1079,7 @@ template <typename AP, typename Id, typename P1 >
|
||||||
typedef AssocVector<TypeInfo, ProductCreator> IdToProductMap;
|
typedef AssocVector<TypeInfo, ProductCreator> IdToProductMap;
|
||||||
IdToProductMap associations_;
|
IdToProductMap associations_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Loki
|
} // namespace Loki
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "Sequence.h"
|
#include <loki/Sequence.h>
|
||||||
#include "EmptyType.h"
|
#include <loki/EmptyType.h>
|
||||||
#include "SmallObj.h"
|
#include <loki/SmallObj.h>
|
||||||
#include "TypeTraits.h"
|
#include <loki/TypeTraits.h>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||||
// This code accompanies the book:
|
// This code accompanies the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author or Addison-Wesley Longman make no representations about the
|
// The author or Addison-Wesley Longman make no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_HIERARCHYGENERATORS_INC_
|
#ifndef LOKI_HIERARCHYGENERATORS_INC_
|
||||||
|
@ -18,14 +18,14 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "TypeTraits.h"
|
#include <loki/TypeTraits.h>
|
||||||
#include "EmptyType.h"
|
#include <loki/EmptyType.h>
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
||||||
#pragma warning( push )
|
#pragma warning( push )
|
||||||
// 'class1' : base-class 'class2' is already a base-class of 'class3'
|
// 'class1' : base-class 'class2' is already a base-class of 'class3'
|
||||||
#pragma warning( disable : 4584 )
|
#pragma warning( disable : 4584 )
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
@ -35,27 +35,27 @@ namespace Loki
|
||||||
// Generates a scattered hierarchy starting from a typelist and a template
|
// Generates a scattered hierarchy starting from a typelist and a template
|
||||||
// Invocation (TList is a typelist, Unit is a template of one arg):
|
// Invocation (TList is a typelist, Unit is a template of one arg):
|
||||||
// GenScatterHierarchy<TList, Unit>
|
// GenScatterHierarchy<TList, Unit>
|
||||||
// The generated class inherits all classes generated by instantiating the
|
// The generated class inherits all classes generated by instantiating the
|
||||||
// template 'Unit' with the types contained in TList
|
// template 'Unit' with the types contained in TList
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
// The following type helps to overcome subtle flaw in the original
|
// The following type helps to overcome subtle flaw in the original
|
||||||
// implementation of GenScatterHierarchy.
|
// implementation of GenScatterHierarchy.
|
||||||
// The flaw is revealed when the input type list of GenScatterHierarchy
|
// The flaw is revealed when the input type list of GenScatterHierarchy
|
||||||
// contains more then one element of the same type (e.g. LOKI_TYPELIST_2(int, int)).
|
// contains more then one element of the same type (e.g. LOKI_TYPELIST_2(int, int)).
|
||||||
// In this case GenScatterHierarchy will contain multiple bases of the same
|
// In this case GenScatterHierarchy will contain multiple bases of the same
|
||||||
// type and some of them will not be reachable (per 10.3).
|
// type and some of them will not be reachable (per 10.3).
|
||||||
// For example before the fix the first element of Tuple<LOKI_TYPELIST_2(int, int)>
|
// For example before the fix the first element of Tuple<LOKI_TYPELIST_2(int, int)>
|
||||||
// is not reachable in any way!
|
// is not reachable in any way!
|
||||||
template<class, class>
|
template<class, class>
|
||||||
struct ScatterHierarchyTag;
|
struct ScatterHierarchyTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TList, template <class> class Unit>
|
template <class TList, template <class> class Unit>
|
||||||
class GenScatterHierarchy;
|
class GenScatterHierarchy;
|
||||||
|
|
||||||
template <class T1, class T2, template <class> class Unit>
|
template <class T1, class T2, template <class> class Unit>
|
||||||
class GenScatterHierarchy<Typelist<T1, T2>, Unit>
|
class GenScatterHierarchy<Typelist<T1, T2>, Unit>
|
||||||
: public GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
|
: public GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
|
||||||
|
@ -71,10 +71,10 @@ namespace Loki
|
||||||
typedef Unit<T> Result;
|
typedef Unit<T> Result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// In the middle *unique* class that resolve possible ambiguity
|
// In the middle *unique* class that resolve possible ambiguity
|
||||||
template <class T1, class T2, template <class> class Unit>
|
template <class T1, class T2, template <class> class Unit>
|
||||||
class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
|
class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
|
||||||
: public GenScatterHierarchy<T1, Unit>
|
: public GenScatterHierarchy<T1, Unit>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@ -88,7 +88,7 @@ namespace Loki
|
||||||
typedef Unit<T> Result;
|
typedef Unit<T> Result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <template <class> class Unit>
|
template <template <class> class Unit>
|
||||||
class GenScatterHierarchy<NullType, Unit>
|
class GenScatterHierarchy<NullType, Unit>
|
||||||
{
|
{
|
||||||
|
@ -97,14 +97,14 @@ namespace Loki
|
||||||
typedef Unit<T> Result;
|
typedef Unit<T> Result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// function template Field
|
// function template Field
|
||||||
// Accesses a field in an object of a type generated with GenScatterHierarchy
|
// Accesses a field in an object of a type generated with GenScatterHierarchy
|
||||||
// Invocation (obj is an object of a type H generated with GenScatterHierarchy,
|
// Invocation (obj is an object of a type H generated with GenScatterHierarchy,
|
||||||
// T is a type in the typelist used to generate H):
|
// T is a type in the typelist used to generate H):
|
||||||
// Field<T>(obj)
|
// Field<T>(obj)
|
||||||
// returns a reference to Unit<T>, where Unit is the template used to generate H
|
// returns a reference to Unit<T>, where Unit is the template used to generate H
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class T, class H>
|
template <class T, class H>
|
||||||
|
@ -112,16 +112,16 @@ namespace Loki
|
||||||
{
|
{
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class H>
|
template <class T, class H>
|
||||||
const typename H::template Rebind<T>::Result& Field(const H& obj)
|
const typename H::template Rebind<T>::Result& Field(const H& obj)
|
||||||
{
|
{
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// function template TupleUnit
|
// function template TupleUnit
|
||||||
// The building block of tuples
|
// The building block of tuples
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -134,8 +134,8 @@ namespace Loki
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template Tuple
|
// class template Tuple
|
||||||
// Implements a tuple class that holds a number of values and provides field
|
// Implements a tuple class that holds a number of values and provides field
|
||||||
// access to them via the Field function (below)
|
// access to them via the Field function (below)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class TList>
|
template <class TList>
|
||||||
|
@ -149,13 +149,13 @@ namespace Loki
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class H, unsigned int i> struct FieldHelper;
|
template <class H, unsigned int i> struct FieldHelper;
|
||||||
|
|
||||||
template <class H>
|
template <class H>
|
||||||
struct FieldHelper<H, 0>
|
struct FieldHelper<H, 0>
|
||||||
{
|
{
|
||||||
typedef typename H::TList::Head ElementType;
|
typedef typename H::TList::Head ElementType;
|
||||||
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
|
isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
|
||||||
|
@ -163,16 +163,16 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef const typename H::LeftBase ConstLeftBase;
|
typedef const typename H::LeftBase ConstLeftBase;
|
||||||
|
|
||||||
typedef typename Select<isConst, ConstLeftBase,
|
typedef typename Select<isConst, ConstLeftBase,
|
||||||
typename H::LeftBase>::Result LeftBase;
|
typename H::LeftBase>::Result LeftBase;
|
||||||
|
|
||||||
typedef typename Select<isTuple, ElementType,
|
typedef typename Select<isTuple, ElementType,
|
||||||
UnitType>::Result UnqualifiedResultType;
|
UnitType>::Result UnqualifiedResultType;
|
||||||
|
|
||||||
typedef typename Select<isConst, const UnqualifiedResultType,
|
typedef typename Select<isConst, const UnqualifiedResultType,
|
||||||
UnqualifiedResultType>::Result ResultType;
|
UnqualifiedResultType>::Result ResultType;
|
||||||
|
|
||||||
static ResultType& Do(H& obj)
|
static ResultType& Do(H& obj)
|
||||||
{
|
{
|
||||||
LeftBase& leftBase = obj;
|
LeftBase& leftBase = obj;
|
||||||
|
@ -185,7 +185,7 @@ namespace Loki
|
||||||
{
|
{
|
||||||
typedef typename TL::TypeAt<typename H::TList, i>::Result ElementType;
|
typedef typename TL::TypeAt<typename H::TList, i>::Result ElementType;
|
||||||
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
typedef typename H::template Rebind<ElementType>::Result UnitType;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
|
isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
|
||||||
|
@ -193,16 +193,16 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef const typename H::RightBase ConstRightBase;
|
typedef const typename H::RightBase ConstRightBase;
|
||||||
|
|
||||||
typedef typename Select<isConst, ConstRightBase,
|
typedef typename Select<isConst, ConstRightBase,
|
||||||
typename H::RightBase>::Result RightBase;
|
typename H::RightBase>::Result RightBase;
|
||||||
|
|
||||||
typedef typename Select<isTuple, ElementType,
|
typedef typename Select<isTuple, ElementType,
|
||||||
UnitType>::Result UnqualifiedResultType;
|
UnitType>::Result UnqualifiedResultType;
|
||||||
|
|
||||||
typedef typename Select<isConst, const UnqualifiedResultType,
|
typedef typename Select<isConst, const UnqualifiedResultType,
|
||||||
UnqualifiedResultType>::Result ResultType;
|
UnqualifiedResultType>::Result ResultType;
|
||||||
|
|
||||||
static ResultType& Do(H& obj)
|
static ResultType& Do(H& obj)
|
||||||
{
|
{
|
||||||
RightBase& rightBase = obj;
|
RightBase& rightBase = obj;
|
||||||
|
@ -217,7 +217,7 @@ namespace Loki
|
||||||
// i is the index of a type in the typelist used to generate H):
|
// i is the index of a type in the typelist used to generate H):
|
||||||
// Field<i>(obj)
|
// Field<i>(obj)
|
||||||
// returns a reference to Unit<T>, where Unit is the template used to generate H
|
// returns a reference to Unit<T>, where Unit is the template used to generate H
|
||||||
// and T is the i-th type in the typelist
|
// and T is the i-th type in the typelist
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <int i, class H>
|
template <int i, class H>
|
||||||
|
@ -226,14 +226,14 @@ namespace Loki
|
||||||
{
|
{
|
||||||
return FieldHelper<H, i>::Do(obj);
|
return FieldHelper<H, i>::Do(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <int i, class H>
|
// template <int i, class H>
|
||||||
// const typename FieldHelper<H, i>::ResultType&
|
// const typename FieldHelper<H, i>::ResultType&
|
||||||
// Field(const H& obj)
|
// Field(const H& obj)
|
||||||
// {
|
// {
|
||||||
// return FieldHelper<H, i>::Do(obj);
|
// return FieldHelper<H, i>::Do(obj);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template GenLinearHierarchy
|
// class template GenLinearHierarchy
|
||||||
// Generates a linear hierarchy starting from a typelist and a template
|
// Generates a linear hierarchy starting from a typelist and a template
|
||||||
|
@ -248,7 +248,7 @@ namespace Loki
|
||||||
class Root = EmptyType
|
class Root = EmptyType
|
||||||
>
|
>
|
||||||
class GenLinearHierarchy;
|
class GenLinearHierarchy;
|
||||||
|
|
||||||
template
|
template
|
||||||
<
|
<
|
||||||
class T1,
|
class T1,
|
||||||
|
@ -283,7 +283,7 @@ namespace Loki
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
||||||
#pragma warning( pop )
|
#pragma warning( pop )
|
||||||
#endif
|
#endif
|
||||||
} // namespace Loki
|
} // namespace Loki
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||||
// This code accompanies the book:
|
// This code accompanies the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author or Addison-Wesley Longman make no representations about the
|
// The author or Addison-Wesley Longman make no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_LOKITYPEINFO_INC_
|
#ifndef LOKI_LOKITYPEINFO_INC_
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
@ -45,24 +45,24 @@ namespace Loki
|
||||||
private:
|
private:
|
||||||
const std::type_info* pInfo_;
|
const std::type_info* pInfo_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
|
|
||||||
inline TypeInfo::TypeInfo()
|
inline TypeInfo::TypeInfo()
|
||||||
{
|
{
|
||||||
class Nil {};
|
class Nil {};
|
||||||
pInfo_ = &typeid(Nil);
|
pInfo_ = &typeid(Nil);
|
||||||
assert(pInfo_);
|
assert(pInfo_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline TypeInfo::TypeInfo(const std::type_info& ti)
|
inline TypeInfo::TypeInfo(const std::type_info& ti)
|
||||||
: pInfo_(&ti)
|
: pInfo_(&ti)
|
||||||
{ assert(pInfo_); }
|
{ assert(pInfo_); }
|
||||||
|
|
||||||
inline bool TypeInfo::before(const TypeInfo& rhs) const
|
inline bool TypeInfo::before(const TypeInfo& rhs) const
|
||||||
{
|
{
|
||||||
assert(pInfo_);
|
assert(pInfo_);
|
||||||
// type_info::before return type is int in some VC libraries
|
// type_info::before return type is int in some VC libraries
|
||||||
return pInfo_->before(*rhs.pInfo_) != 0;
|
return pInfo_->before(*rhs.pInfo_) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace Loki
|
||||||
assert(pInfo_);
|
assert(pInfo_);
|
||||||
return *pInfo_;
|
return *pInfo_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* TypeInfo::name() const
|
inline const char* TypeInfo::name() const
|
||||||
{
|
{
|
||||||
assert(pInfo_);
|
assert(pInfo_);
|
||||||
|
@ -79,7 +79,7 @@ namespace Loki
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
|
|
||||||
inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
|
inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
|
||||||
// type_info::operator== return type is int in some VC libraries
|
// type_info::operator== return type is int in some VC libraries
|
||||||
{ return (lhs.Get() == rhs.Get()) != 0; }
|
{ return (lhs.Get() == rhs.Get()) != 0; }
|
||||||
|
@ -88,14 +88,14 @@ namespace Loki
|
||||||
{ return lhs.before(rhs); }
|
{ return lhs.before(rhs); }
|
||||||
|
|
||||||
inline bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
|
inline bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
|
||||||
{ return !(lhs == rhs); }
|
{ return !(lhs == rhs); }
|
||||||
|
|
||||||
inline bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
|
inline bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
|
||||||
{ return rhs < lhs; }
|
{ return rhs < lhs; }
|
||||||
|
|
||||||
inline bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
|
inline bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
|
||||||
{ return !(lhs > rhs); }
|
{ return !(lhs > rhs); }
|
||||||
|
|
||||||
inline bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
|
inline bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
|
||||||
{ return !(lhs < rhs); }
|
{ return !(lhs < rhs); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "LokiTypeInfo.h"
|
#include <loki/LokiTypeInfo.h>
|
||||||
#include "Functor.h"
|
#include <loki/Functor.h>
|
||||||
#include "AssocVector.h"
|
#include <loki/AssocVector.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// IMPORTANT NOTE:
|
// IMPORTANT NOTE:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2005 Peter Kümmel
|
// Copyright (c) 2005 Peter Kümmel
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author makes no representations about the
|
// The author makes no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_ORDEREDSTATIC_INC_
|
#ifndef LOKI_ORDEREDSTATIC_INC_
|
||||||
|
@ -18,10 +18,10 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "LokiExport.h"
|
#include <loki/LokiExport.h>
|
||||||
#include "Singleton.h"
|
#include <loki/Singleton.h>
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "Sequence.h"
|
#include <loki/Sequence.h>
|
||||||
|
|
||||||
// usage: see test/OrderedStatic
|
// usage: see test/OrderedStatic
|
||||||
|
|
||||||
|
@ -37,17 +37,17 @@ namespace Loki
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void createObject() = 0;
|
virtual void createObject() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OrderedStaticCreatorFunc();
|
OrderedStaticCreatorFunc();
|
||||||
virtual ~OrderedStaticCreatorFunc();
|
virtual ~OrderedStaticCreatorFunc();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
|
OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// template base clase for OrderedStatic template,
|
// template base clase for OrderedStatic template,
|
||||||
// common for all specializations
|
// common for all specializations
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -69,11 +69,11 @@ namespace Loki
|
||||||
OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
|
OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~OrderedStaticBase()
|
virtual ~OrderedStaticBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLongevity(T* ptr)
|
void SetLongevity(T* ptr)
|
||||||
{
|
{
|
||||||
val_=ptr;
|
val_=ptr;
|
||||||
|
@ -86,11 +86,11 @@ namespace Loki
|
||||||
OrderedStaticBase& operator=(const OrderedStaticBase&);
|
OrderedStaticBase& operator=(const OrderedStaticBase&);
|
||||||
T* val_;
|
T* val_;
|
||||||
unsigned int longevity_;
|
unsigned int longevity_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// OrderedStaticManagerClass implements details
|
// OrderedStaticManagerClass implements details
|
||||||
// OrderedStaticManager is then defined as a Singleton
|
// OrderedStaticManager is then defined as a Singleton
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
class LOKI_EXPORT OrderedStaticManagerClass
|
class LOKI_EXPORT OrderedStaticManagerClass
|
||||||
|
@ -107,7 +107,7 @@ namespace Loki
|
||||||
private:
|
private:
|
||||||
OrderedStaticManagerClass(const OrderedStaticManagerClass&);
|
OrderedStaticManagerClass(const OrderedStaticManagerClass&);
|
||||||
OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
|
OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
|
||||||
|
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
|
Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
|
||||||
|
@ -129,7 +129,7 @@ namespace Loki
|
||||||
|
|
||||||
typedef Loki::SingletonHolder
|
typedef Loki::SingletonHolder
|
||||||
<
|
<
|
||||||
Loki::Private::OrderedStaticManagerClass,
|
Loki::Private::OrderedStaticManagerClass,
|
||||||
Loki::CreateUsingNew,
|
Loki::CreateUsingNew,
|
||||||
Loki::NoDestroy,
|
Loki::NoDestroy,
|
||||||
Loki::SingleThreaded
|
Loki::SingleThreaded
|
||||||
|
@ -137,7 +137,7 @@ namespace Loki
|
||||||
OrderedStaticManager;
|
OrderedStaticManager;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// template OrderedStatic template:
|
// template OrderedStatic template:
|
||||||
// L : longevity
|
// L : longevity
|
||||||
// T : object type
|
// T : object type
|
||||||
// TList : creator parameters
|
// TList : creator parameters
|
||||||
|
@ -154,7 +154,7 @@ namespace Loki
|
||||||
template<unsigned int L, class T>
|
template<unsigned int L, class T>
|
||||||
class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
|
class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OrderedStatic() : Private::OrderedStaticBase<T>(L)
|
OrderedStatic() : Private::OrderedStaticBase<T>(L)
|
||||||
{
|
{
|
||||||
OrderedStaticManager::Instance().registerObject
|
OrderedStaticManager::Instance().registerObject
|
||||||
|
@ -180,7 +180,7 @@ namespace Loki
|
||||||
OrderedStaticManager::Instance().registerObject
|
OrderedStaticManager::Instance().registerObject
|
||||||
(L,this,&Private::OrderedStaticCreatorFunc::createObject);
|
(L,this,&Private::OrderedStaticCreatorFunc::createObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createObject()
|
void createObject()
|
||||||
{
|
{
|
||||||
Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
|
Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2006 Peter Kümmel
|
// Copyright (c) 2006 Peter Kümmel
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author makes no representations about the
|
// The author makes no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_REGISTER_INC_
|
#ifndef LOKI_REGISTER_INC_
|
||||||
|
@ -15,12 +15,12 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "TypeManip.h"
|
#include <loki/TypeManip.h>
|
||||||
#include "HierarchyGenerators.h"
|
#include <loki/HierarchyGenerators.h>
|
||||||
#include "ForEachType.h"
|
#include <loki/ForEachType.h>
|
||||||
|
|
||||||
|
|
||||||
/// \defgroup RegisterGroup Register
|
/// \defgroup RegisterGroup Register
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
@ -35,14 +35,14 @@ namespace Loki
|
||||||
/// \ingroup RegisterGroup
|
/// \ingroup RegisterGroup
|
||||||
/// Must be specialized be the user
|
/// Must be specialized be the user
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
bool RegisterFunction();
|
bool RegisterFunction();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \ingroup RegisterGroup
|
/// \ingroup RegisterGroup
|
||||||
/// Must be specialized be the user
|
/// Must be specialized be the user
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
bool UnRegisterFunction();
|
bool UnRegisterFunction();
|
||||||
|
|
||||||
namespace Private
|
namespace Private
|
||||||
|
@ -52,7 +52,7 @@ namespace Loki
|
||||||
template< int Index, typename T >
|
template< int Index, typename T >
|
||||||
void operator()()
|
void operator()()
|
||||||
{
|
{
|
||||||
RegisterFunction<T>();
|
RegisterFunction<T>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,8 +118,8 @@ namespace Loki
|
||||||
/// see test/Register
|
/// see test/Register
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
|
#define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
|
||||||
#define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
|
#define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
|
||||||
|
|
||||||
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
|
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "LokiExport.h"
|
#include <loki/LokiExport.h>
|
||||||
#include "Threads.h"
|
#include <loki/Threads.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "LokiExport.h"
|
#include <loki/LokiExport.h>
|
||||||
#include "Threads.h"
|
#include <loki/Threads.h>
|
||||||
#include "Singleton.h"
|
#include <loki/Singleton.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <new> // needed for std::nothrow_t parameter.
|
#include <new> // needed for std::nothrow_t parameter.
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,12 @@
|
||||||
/// \defgroup SmartPointerCheckingGroup Checking policies
|
/// \defgroup SmartPointerCheckingGroup Checking policies
|
||||||
/// \ingroup SmartPointerGroup
|
/// \ingroup SmartPointerGroup
|
||||||
|
|
||||||
#include "LokiExport.h"
|
#include <loki/LokiExport.h>
|
||||||
#include "SmallObj.h"
|
#include <loki/SmallObj.h>
|
||||||
#include "TypeManip.h"
|
#include <loki/TypeManip.h>
|
||||||
#include "static_check.h"
|
#include <loki/static_check.h>
|
||||||
#include "RefToValue.h"
|
#include <loki/RefToValue.h>
|
||||||
#include "ConstPolicy.h"
|
#include <loki/ConstPolicy.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,9 +18,9 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include "NullType.h"
|
#include <loki/NullType.h>
|
||||||
#include "TypeManip.h"
|
#include <loki/TypeManip.h>
|
||||||
#include "TypelistMacros.h"
|
#include <loki/TypelistMacros.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||||
// This code accompanies the book:
|
// This code accompanies the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
// Permission to use, copy, modify, distribute and sell this software for any
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
// purpose is hereby granted without fee, provided that the above copyright
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
// notice appear in all copies and that both that copyright notice and this
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
// permission notice appear in supporting documentation.
|
// permission notice appear in supporting documentation.
|
||||||
// The author or Addison-Wesley Longman make no representations about the
|
// The author or Addison-Wesley Longman make no representations about the
|
||||||
// suitability of this software for any purpose. It is provided "as is"
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef LOKI_VISITOR_INC_
|
#ifndef LOKI_VISITOR_INC_
|
||||||
|
@ -20,15 +20,15 @@
|
||||||
|
|
||||||
/// \defgroup VisitorGroup Visitor
|
/// \defgroup VisitorGroup Visitor
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include <loki/Typelist.h>
|
||||||
#include "HierarchyGenerators.h"
|
#include <loki/HierarchyGenerators.h>
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \class BaseVisitor
|
/// \class BaseVisitor
|
||||||
///
|
///
|
||||||
/// \ingroup VisitorGroup
|
/// \ingroup VisitorGroup
|
||||||
/// The base class of any Acyclic Visitor
|
/// The base class of any Acyclic Visitor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -38,7 +38,7 @@ namespace Loki
|
||||||
public:
|
public:
|
||||||
virtual ~BaseVisitor() {}
|
virtual ~BaseVisitor() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \class Visitor
|
/// \class Visitor
|
||||||
///
|
///
|
||||||
|
@ -48,7 +48,7 @@ namespace Loki
|
||||||
/// \par Usage
|
/// \par Usage
|
||||||
///
|
///
|
||||||
/// Defining the visitable class:
|
/// Defining the visitable class:
|
||||||
///
|
///
|
||||||
/// \code
|
/// \code
|
||||||
/// class RasterBitmap : public BaseVisitable<>
|
/// class RasterBitmap : public BaseVisitable<>
|
||||||
/// {
|
/// {
|
||||||
|
@ -59,7 +59,7 @@ namespace Loki
|
||||||
///
|
///
|
||||||
/// Way 1 to define a visitor:
|
/// Way 1 to define a visitor:
|
||||||
/// \code
|
/// \code
|
||||||
/// class SomeVisitor :
|
/// class SomeVisitor :
|
||||||
/// public BaseVisitor // required
|
/// public BaseVisitor // required
|
||||||
/// public Visitor<RasterBitmap>,
|
/// public Visitor<RasterBitmap>,
|
||||||
/// public Visitor<Paragraph>
|
/// public Visitor<Paragraph>
|
||||||
|
@ -72,7 +72,7 @@ namespace Loki
|
||||||
///
|
///
|
||||||
/// Way 2 to define the visitor:
|
/// Way 2 to define the visitor:
|
||||||
/// \code
|
/// \code
|
||||||
/// class SomeVisitor :
|
/// class SomeVisitor :
|
||||||
/// public BaseVisitor // required
|
/// public BaseVisitor // required
|
||||||
/// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
|
/// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
|
||||||
/// {
|
/// {
|
||||||
|
@ -84,7 +84,7 @@ namespace Loki
|
||||||
///
|
///
|
||||||
/// Way 3 to define the visitor:
|
/// Way 3 to define the visitor:
|
||||||
/// \code
|
/// \code
|
||||||
/// class SomeVisitor :
|
/// class SomeVisitor :
|
||||||
/// public BaseVisitor // required
|
/// public BaseVisitor // required
|
||||||
/// public Visitor<Seq<RasterBitmap, Paragraph>::Type>
|
/// public Visitor<Seq<RasterBitmap, Paragraph>::Type>
|
||||||
/// {
|
/// {
|
||||||
|
@ -97,7 +97,7 @@ namespace Loki
|
||||||
/// \par Using const visit functions:
|
/// \par Using const visit functions:
|
||||||
///
|
///
|
||||||
/// Defining the visitable class (true for const):
|
/// Defining the visitable class (true for const):
|
||||||
///
|
///
|
||||||
/// \code
|
/// \code
|
||||||
/// class RasterBitmap : public BaseVisitable<void, DefaultCatchAll, true>
|
/// class RasterBitmap : public BaseVisitable<void, DefaultCatchAll, true>
|
||||||
/// {
|
/// {
|
||||||
|
@ -108,7 +108,7 @@ namespace Loki
|
||||||
///
|
///
|
||||||
/// Defining the visitor which only calls const member functions:
|
/// Defining the visitor which only calls const member functions:
|
||||||
/// \code
|
/// \code
|
||||||
/// class SomeVisitor :
|
/// class SomeVisitor :
|
||||||
/// public BaseVisitor // required
|
/// public BaseVisitor // required
|
||||||
/// public Visitor<RasterBitmap, void, true>,
|
/// public Visitor<RasterBitmap, void, true>,
|
||||||
/// {
|
/// {
|
||||||
|
@ -119,7 +119,7 @@ namespace Loki
|
||||||
///
|
///
|
||||||
/// \par Example:
|
/// \par Example:
|
||||||
///
|
///
|
||||||
/// test/Visitor/main.cpp
|
/// test/Visitor/main.cpp
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class T, typename R = void, bool ConstVisit = false>
|
template <class T, typename R = void, bool ConstVisit = false>
|
||||||
|
@ -150,7 +150,7 @@ namespace Loki
|
||||||
// This specialization is not present in the book. It makes it easier to define
|
// This specialization is not present in the book. It makes it easier to define
|
||||||
// Visitors for multiple types in a shot by using a typelist. Example:
|
// Visitors for multiple types in a shot by using a typelist. Example:
|
||||||
//
|
//
|
||||||
// class SomeVisitor :
|
// class SomeVisitor :
|
||||||
// public BaseVisitor // required
|
// public BaseVisitor // required
|
||||||
// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
|
// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
|
||||||
// {
|
// {
|
||||||
|
@ -169,7 +169,7 @@ namespace Loki
|
||||||
// using Visitor<Head, R>::Visit;
|
// using Visitor<Head, R>::Visit;
|
||||||
// using Visitor<Tail, R>::Visit;
|
// using Visitor<Tail, R>::Visit;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Head, typename R>
|
template <class Head, typename R>
|
||||||
class Visitor<Typelist<Head, NullType>, R, false> : public Visitor<Head, R, false>
|
class Visitor<Typelist<Head, NullType>, R, false> : public Visitor<Head, R, false>
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ namespace Loki
|
||||||
// using Visitor<Head, R>::Visit;
|
// using Visitor<Head, R>::Visit;
|
||||||
// using Visitor<Tail, R>::Visit;
|
// using Visitor<Tail, R>::Visit;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Head, typename R>
|
template <class Head, typename R>
|
||||||
class Visitor<Typelist<Head, NullType>, R, true> : public Visitor<Head, R, true>
|
class Visitor<Typelist<Head, NullType>, R, true> : public Visitor<Head, R, true>
|
||||||
{
|
{
|
||||||
|
@ -216,7 +216,7 @@ namespace Loki
|
||||||
virtual R Visit(Head&)
|
virtual R Visit(Head&)
|
||||||
{ return R(); }
|
{ return R(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Head, typename R>
|
template <class Head, typename R>
|
||||||
class BaseVisitorImpl<Typelist<Head, NullType>, R>
|
class BaseVisitorImpl<Typelist<Head, NullType>, R>
|
||||||
: public Visitor<Head, R>
|
: public Visitor<Head, R>
|
||||||
|
@ -225,7 +225,7 @@ namespace Loki
|
||||||
virtual R Visit(Head&)
|
virtual R Visit(Head&)
|
||||||
{ return R(); }
|
{ return R(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template BaseVisitable
|
// class template BaseVisitable
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -241,9 +241,9 @@ struct DefaultCatchAll
|
||||||
// class template BaseVisitable
|
// class template BaseVisitable
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template
|
template
|
||||||
<
|
<
|
||||||
typename R = void,
|
typename R = void,
|
||||||
template <typename, class> class CatchAll = DefaultCatchAll,
|
template <typename, class> class CatchAll = DefaultCatchAll,
|
||||||
bool ConstVisitable = false
|
bool ConstVisitable = false
|
||||||
>
|
>
|
||||||
|
@ -256,7 +256,7 @@ struct DefaultCatchAll
|
||||||
typedef R ReturnType;
|
typedef R ReturnType;
|
||||||
virtual ~BaseVisitable() {}
|
virtual ~BaseVisitable() {}
|
||||||
virtual ReturnType Accept(BaseVisitor&) = 0;
|
virtual ReturnType Accept(BaseVisitor&) = 0;
|
||||||
|
|
||||||
protected: // give access only to the hierarchy
|
protected: // give access only to the hierarchy
|
||||||
template <class T>
|
template <class T>
|
||||||
static ReturnType AcceptImpl(T& visited, BaseVisitor& guest)
|
static ReturnType AcceptImpl(T& visited, BaseVisitor& guest)
|
||||||
|
@ -277,7 +277,7 @@ struct DefaultCatchAll
|
||||||
typedef R ReturnType;
|
typedef R ReturnType;
|
||||||
virtual ~BaseVisitable() {}
|
virtual ~BaseVisitable() {}
|
||||||
virtual ReturnType Accept(BaseVisitor&) const = 0;
|
virtual ReturnType Accept(BaseVisitor&) const = 0;
|
||||||
|
|
||||||
protected: // give access only to the hierarchy
|
protected: // give access only to the hierarchy
|
||||||
template <class T>
|
template <class T>
|
||||||
static ReturnType AcceptImpl(const T& visited, BaseVisitor& guest)
|
static ReturnType AcceptImpl(const T& visited, BaseVisitor& guest)
|
||||||
|
@ -295,7 +295,7 @@ struct DefaultCatchAll
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \def LOKI_DEFINE_VISITABLE()
|
/// \def LOKI_DEFINE_VISITABLE()
|
||||||
/// \ingroup VisitorGroup
|
/// \ingroup VisitorGroup
|
||||||
/// Put it in every class that you want to make visitable
|
/// Put it in every class that you want to make visitable
|
||||||
/// (in addition to deriving it from BaseVisitable<R>)
|
/// (in addition to deriving it from BaseVisitable<R>)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ struct DefaultCatchAll
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \def LOKI_DEFINE_CONST_VISITABLE()
|
/// \def LOKI_DEFINE_CONST_VISITABLE()
|
||||||
/// \ingroup VisitorGroup
|
/// \ingroup VisitorGroup
|
||||||
/// Put it in every class that you want to make visitable by const member
|
/// Put it in every class that you want to make visitable by const member
|
||||||
/// functions (in addition to deriving it from BaseVisitable<R>)
|
/// functions (in addition to deriving it from BaseVisitable<R>)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ struct DefaultCatchAll
|
||||||
/// \class CyclicVisitor
|
/// \class CyclicVisitor
|
||||||
///
|
///
|
||||||
/// \ingroup VisitorGroup
|
/// \ingroup VisitorGroup
|
||||||
/// Put it in every class that you want to make visitable (in addition to
|
/// Put it in every class that you want to make visitable (in addition to
|
||||||
/// deriving it from BaseVisitable<R>
|
/// deriving it from BaseVisitable<R>
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ struct DefaultCatchAll
|
||||||
public:
|
public:
|
||||||
typedef R ReturnType;
|
typedef R ReturnType;
|
||||||
// using Visitor<TList, R>::Visit;
|
// using Visitor<TList, R>::Visit;
|
||||||
|
|
||||||
template <class Visited>
|
template <class Visited>
|
||||||
ReturnType GenericVisit(Visited& host)
|
ReturnType GenericVisit(Visited& host)
|
||||||
{
|
{
|
||||||
|
@ -336,7 +336,7 @@ struct DefaultCatchAll
|
||||||
return subObj.Visit(host);
|
return subObj.Visit(host);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \def LOKI_DEFINE_CYCLIC_VISITABLE(SomeVisitor)
|
/// \def LOKI_DEFINE_CYCLIC_VISITABLE(SomeVisitor)
|
||||||
/// \ingroup VisitorGroup
|
/// \ingroup VisitorGroup
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue