valueattributetranslator.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_3d_valueattributetranslator_hh
#define mia_3d_valueattributetranslator_hh
#include <mia/core/attributes.hh>
#include <mia/3d/vector.hh>
#include <mia/3d/defines3d.hh>
NS_MIA_BEGIN
template <typename T>
class EXPORT_3D C3DValueAttributeTranslator: public CAttrTranslator
{
public:
static bool register_for(const std::string& key);
private:
PAttribute do_from_string(const std::string& value) const;
};
template <typename T>
class EXPORT_3D C3DValueAttribute : public CAttribute
{
public:
C3DValueAttribute(const T3DVector<T>& value);
operator T3DVector<T>()const;
const char *typedescr() const
{
return typeid(T3DVector<T>).name();
}
//
int type_id() const
{
return attribute_type<T3DVector<T>>::value;
}
private:
std::string do_as_string() const;
bool do_is_equal(const CAttribute& other) const;
bool do_is_less(const CAttribute& other) const;
T3DVector<T> m_value;
};
typedef C3DValueAttribute<float> CVoxelAttribute;
typedef C3DValueAttributeTranslator<float> CVoxelAttributeTranslator;
typedef C3DValueAttribute<int> C3DIntAttribute;
typedef C3DValueAttributeTranslator<int> C3DIntAttributeTranslator;
NS_MIA_END
#endif
vector.hh
attributes.hh
PAttribute
std::shared_ptr< CAttribute > PAttribute
define the shared pointer wrapped attribute pointer
Definition attributes.hh:102
C3DValueAttributeTranslator
a translater for 3D vectors to and from a std::string
Definition valueattributetranslator.hh:36
C3DValueAttributeTranslator::register_for
static bool register_for(const std::string &key)
C3DValueAttribute
a 3D vector value used in attributes
Definition valueattributetranslator.hh:56
C3DValueAttribute::type_id
int type_id() const
Definition valueattributetranslator.hh:78
C3DValueAttribute::typedescr
const char * typedescr() const
Definition valueattributetranslator.hh:72
C3DValueAttribute::C3DValueAttribute
C3DValueAttribute(const T3DVector< T > &value)
CAttrTranslator::CAttrTranslator
CAttrTranslator()
CAttribute
The class of all attributes of data that is considered to ve meta-data.
Definition attributes.hh:52
T3DVector
A simple 3D vector type.
Definition 3d/vector.hh:49
defines3d.hh
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
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
C3DIntAttributeTranslator
C3DValueAttributeTranslator< int > C3DIntAttributeTranslator
attribute translator for a 3D integer vector
Definition valueattributetranslator.hh:111
CVoxelAttribute
C3DValueAttribute< float > CVoxelAttribute
a 3D floating point vector used for the voxel size attribute
Definition valueattributetranslator.hh:93
C3DIntAttribute
C3DValueAttribute< int > C3DIntAttribute
a 3D integer vector
Definition valueattributetranslator.hh:105
CVoxelAttributeTranslator
C3DValueAttributeTranslator< float > CVoxelAttributeTranslator
attribute translator for a 3D floating point vector used for the voxel size
Definition valueattributetranslator.hh:99
attribute_type
Definition attributetype.hh:65