traits.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_core_traits__hh
#define mia_core_traits__hh
#include <mia/core/defines.hh>
NS_MIA_BEGIN
template <typename T>
struct dim_traits {
typedef typename T::dimsize_type dimsize_type;
};
struct vector_dimsize {
vector_dimsize(): m_n(0)
{
}
vector_dimsize(size_t n): m_n(n)
{
}
size_t size()
{
return 1;
}
size_t& operator [] (int /*i*/)
{
return m_n;
}
const size_t& operator [] (int /*i*/) const
{
return m_n;
}
private:
size_t m_n;
};
template <typename T>
struct dim_traits<std::vector<T>> {
typedef vector_dimsize dimsize_type;
};
template <typename T>
struct __cache_policy {
static bool apply()
{
return false;
}
};
NS_MIA_END
#endif
defines.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
std
Definition gsl_iterator.hh:324
dim_traits
A trait to obtaine information about of dimensions of a class.
Definition traits.hh:36
dimsize_type::dimsize_type
F::dimsize_type dimsize_type
Definition traits.hh:38
vector_dimsize::vector_dimsize
vector_dimsize(size_t n)
contruct the dimsize object
Definition traits.hh:53
vector_dimsize::size
size_t size()
Definition traits.hh:58
vector_dimsize::operator[]
size_t & operator[](int)
return a read-write reference to the first (and only)dimension
Definition traits.hh:64
vector_dimsize::vector_dimsize
vector_dimsize()
contruct the dimsize object
Definition traits.hh:48