core/cost.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_cost_hh
#define mia_core_cost_hh
#include <mia/core/factory.hh>
#include <mia/core/refholder.hh>
#ifndef EXPORT_HANDLER
# ifdef WIN32
# define EXPORT_HANDLER __declspec(dllimport)
# else
# define EXPORT_HANDLER
# endif
#endif
NS_MIA_BEGIN
struct EXPORT_CORE cost_type {
static const char *type_descr;
};
template <typename T, typename V>
class EXPORT_HANDLER TCost : public CProductBase
{
public:
typedef T Data;
typedef V Force;
typedef TRefHolder<T> RData;
typedef typename RData::Pointer PData;
typedef T plugin_data;
typedef cost_type plugin_type;
virtual ~TCost();
double value(const T& src) const;
double evaluate_force(const T& src, V& force) const;
void set_reference(const T& ref);
private:
virtual double do_value(const T& a, const T& b) const = 0;
virtual double do_evaluate_force(const T& a, const T& b, V& force) const = 0;
virtual void post_set_reference(const T& ref);
PData m_reference;
};
NS_MIA_END
#endif
CProductBase
The base class for all plug-in created object.
Definition product_base.hh:41
TCost
The generic cost function interface.
Definition core/cost.hh:65
TCost::Force
V Force
typedef for generic programming: The gradient forca type create by the cost function
Definition core/cost.hh:71
TCost::set_reference
void set_reference(const T &ref)
TCost::plugin_type
cost_type plugin_type
plugin searchpath helper type
Definition core/cost.hh:83
TCost::value
double value(const T &src) const
TCost::RData
TRefHolder< T > RData
Const reference holder TRefHolder of the cost function data.
Definition core/cost.hh:74
TCost::~TCost
virtual ~TCost()
ensure virtual destruction, since we have virtual functions
TCost::PData
RData::Pointer PData
Pointer to const reference holder TRefHolder of the cost function data.
Definition core/cost.hh:77
TCost::evaluate_force
double evaluate_force(const T &src, V &force) const
TCost::plugin_data
T plugin_data
plugin searchpath helper type
Definition core/cost.hh:80
TCost::Data
T Data
typedef for generic programming: The data type used by the cost function
Definition core/cost.hh:68
TRefHolder
A class to make a const reference not so const.
Definition refholder.hh:40
TRefHolder::Pointer
std::shared_ptr< TRefHolder< T > > Pointer
pointer type of this reference holder.
Definition refholder.hh:43
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition core/cost.hh:32
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
factory.hh
refholder.hh
cost_type
plugin helper type
Definition core/cost.hh:39
cost_type::type_descr
static const char * type_descr
plugin path helper variable
Definition core/cost.hh:41