Commit c094be96 authored by David Moxey's avatar David Moxey
Browse files

Change documentation for NekFactory and fix warning arising from CommDataType

parent 4c4048c9
......@@ -59,36 +59,34 @@ typedef boost::shared_lock<boost::shared_mutex> ReadLock;
/**
* @class NekFactory
\brief Provides a generic Factory class.
*
* Implements a generic object factory. Class-types which use a
* potentially arbitrary number of parameters may be used with
* specialised forms of the NekFactory. An upper
* limit on the number of parameters is imposed by the MAX_PARAM
* preprocessor definition in the NekFactory.hpp file. The
* specialisations are generated at compile type using Boost
* preprocessor by through repeated inclusion of the NekFactory.hpp
* file.
* @brief Provides a generic Factory class.
*
* Implements a generic object factory. Class-types which use an arbitrary
* number of parameters may be used via C++ variadic templating.
*
* To allow a class to be instantiated by the factory, the following are
* required in each class definition (in the case of a single parameter):
*
* To allow a class to be instantiated by the factory, the
* following are required in each class definition (in the case of
* a single parameter):
* \code
* static [baseclass]* create([paramtype1] &P) {
* return new [derivedclass](P);
* }
* static std::string className;
* \endcode
*
* and outside the class definition in the implementation:
*
* \code
* std::string [derivedclass]::className
* = Factory<std::string,[baseclass],[paramtype1]>::
* RegisterCreatorFunction("[derivedclass]",
* [derivedclass]::create,"Description");
* \endcode
* The assignment of the static variable className is done through the
* call to RegisterCreatorFunction, which registers the class with the
* factory prior to the start of the main() routine.
*
* The assignment of the static variable className is done through the call to
* RegisterCreatorFunction, which registers the class with the factory prior to
* the start of the main() routine.
*
* To create an instance of a derived class, for instance:
* \code
......
......@@ -82,27 +82,59 @@ int CommDataTypeGetSize(CommDataType dt)
#endif
}
/// Type trait mapping an int to MPI_INT
template <> CommDataType CommDataTypeTraits<int>::type = MPI_INT;
/// Type trait mapping an unsigned int to MPI_UNSIGNED
template <> CommDataType CommDataTypeTraits<unsigned>::type = MPI_UNSIGNED;
/// Type trait mapping a long int to MPI_LONG
template <> CommDataType CommDataTypeTraits<long>::type = MPI_LONG;
/// Type trait mapping an unsigned long int to MPI_UNSIGNED_LONG
template <>
CommDataType CommDataTypeTraits<unsigned long>::type = MPI_UNSIGNED_LONG;
/// Type trait mapping a long long int to MPI_LONG_LONG
template <> CommDataType CommDataTypeTraits<long long>::type = MPI_LONG_LONG;
/// Type trait mapping an unsigned long long int to MPI_UNSIGNED_LONG_LONG
template <>
CommDataType CommDataTypeTraits<unsigned long long>::type =
MPI_UNSIGNED_LONG_LONG;
/// Type trait mapping a float to MPI_FLOAT
template <> CommDataType CommDataTypeTraits<float>::type = MPI_FLOAT;
/// Type trait mapping a double to MPI_DOUBLE
template <> CommDataType CommDataTypeTraits<double>::type = MPI_DOUBLE;
/// Type trait mapping a long double to MPI_LONG_DOUBLE
template <>
CommDataType CommDataTypeTraits<long double>::type = MPI_LONG_DOUBLE;
template<> CommDataType &CommDataTypeTraits<int>::GetDataType()
{
static CommDataType type = MPI_INT;
return type;
}
template<> CommDataType &CommDataTypeTraits<unsigned>::GetDataType()
{
static CommDataType type = MPI_UNSIGNED;
return type;
}
template<> CommDataType &CommDataTypeTraits<long>::GetDataType()
{
static CommDataType type = MPI_LONG;
return type;
}
template<> CommDataType &CommDataTypeTraits<unsigned long>::GetDataType()
{
static CommDataType type = MPI_UNSIGNED_LONG;
return type;
}
template<> CommDataType &CommDataTypeTraits<long long>::GetDataType()
{
static CommDataType type = MPI_LONG_LONG;
return type;
}
template<> CommDataType &CommDataTypeTraits<unsigned long long>::GetDataType()
{
static CommDataType type = MPI_UNSIGNED_LONG_LONG;
return type;
}
template<> CommDataType &CommDataTypeTraits<float>::GetDataType()
{
static CommDataType type = MPI_FLOAT;
return type;
}
template<> CommDataType &CommDataTypeTraits<double>::GetDataType()
{
static CommDataType type = MPI_DOUBLE;
return type;
}
template<> CommDataType &CommDataTypeTraits<long double>::GetDataType()
{
static CommDataType type = MPI_LONG_DOUBLE;
return type;
}
}
}
......@@ -82,13 +82,9 @@ int CommDataTypeGetSize(CommDataType);
template <class T> class CommDataTypeTraits
{
LIB_UTILITIES_EXPORT static CommDataType type;
public:
static CommDataType &GetDataType()
{
return type;
}
LIB_UTILITIES_EXPORT static CommDataType &GetDataType();
static void *GetPointer(T &val)
{
return &val;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment