view.hxx

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef OPENGM_VIEW_FUNCTION_HXX
00003 #define OPENGM_VIEW_FUNCTION_HXX
00004 
00005 #include "opengm/functions/function_properties_base.hxx"
00006 
00007 namespace opengm {
00008 
00012 template<class GM>
00013 class ViewFunction
00014 : public FunctionBase<ViewFunction<GM>, 
00015     typename GM::ValueType,typename GM::IndexType, typename GM::LabelType>
00016 {
00017 public:
00018    typedef typename GM::ValueType ValueType;
00019    typedef ValueType value_type;
00020    typedef typename GM::FactorType FactorType;
00021    typedef typename GM::OperatorType OperatorType;
00022    typedef typename GM::IndexType IndexType;
00023    typedef typename GM::IndexType LabelType;
00024 
00025    ViewFunction();
00026    ViewFunction(const FactorType &);
00027    template<class Iterator>
00028       ValueType operator()(Iterator begin)const;
00029    LabelType shape(const IndexType)const;
00030    IndexType dimension()const;
00031    IndexType size()const;
00032 
00033 private:
00034    FactorType const* factor_;
00035 };
00036 
00037 template<class GM>
00038 inline
00039 ViewFunction<GM>::ViewFunction()
00040 :  factor_(NULL)
00041 {}
00042 
00043 template<class GM>
00044 inline
00045 ViewFunction<GM>::ViewFunction
00046 (
00047    const typename ViewFunction<GM>::FactorType & factor
00048 )
00049 :  factor_(&factor)
00050 {}
00051 
00052 template<class GM>
00053 template<class Iterator>
00054 inline typename ViewFunction<GM>::ValueType
00055 ViewFunction<GM>::operator()
00056 (
00057    Iterator begin
00058 ) const {
00059    return factor_->operator()(begin);
00060 }
00061 
00062 template<class GM>
00063 inline typename ViewFunction<GM>::LabelType
00064 ViewFunction<GM>::shape
00065 (
00066    const typename ViewFunction<GM>::IndexType index
00067 ) const{
00068    return factor_->numberOfLabels(index);
00069 }
00070 
00071 template<class GM>
00072 inline typename ViewFunction<GM>::IndexType
00073 ViewFunction<GM>::dimension() const {
00074    return factor_->numberOfVariables();
00075 }
00076 
00077 template<class GM>
00078 inline typename ViewFunction<GM>::IndexType
00079 ViewFunction<GM>::size() const {
00080    return factor_->size( );
00081 }
00082 
00083 } // namespace opengm
00084 
00085 #endif // #ifndef OPENGM_VIEW_FUNCTION_HXX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Jun 17 16:31:07 2013 for OpenGM by  doxygen 1.6.3