viewspace.hxx

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef OPENGM_VIEW_SPACE_HXX
00003 #define OPENGM_VIEW_SPACE_HXX
00004 
00005 #include <vector>
00006 #include <limits>
00007 
00008 #include "opengm/opengm.hxx"
00009 #include "opengm/graphicalmodel/space/space_base.hxx"
00010 
00012 
00013 namespace opengm {
00014 
00018 template<class GM>
00019 class ViewSpace
00020 : public SpaceBase<ViewSpace<GM>, typename GM::IndexType, typename GM::LabelType> {
00021 public:
00022    typedef typename GM::IndexType IndexType;
00023    typedef typename GM::LabelType LabelType;
00024    typedef typename GM::SpaceType SrcSpaceType;
00025 
00026    ViewSpace();
00027    ViewSpace(const GM &);
00028    void assign(const GM &);
00029    IndexType addVariable(const LabelType);
00030    IndexType numberOfVariables() const;
00031    LabelType numberOfLabels(const IndexType) const;
00032 
00033 private:
00034    SrcSpaceType const* space_;
00035 };
00036 
00037 template<class GM>
00038 inline
00039 ViewSpace<GM>::ViewSpace()
00040 :  space_(NULL)
00041 {}
00042 
00043 template<class GM>
00044 inline
00045 ViewSpace<GM>::ViewSpace(
00046    const GM & gm
00047 )
00048 :  space_(&gm.space())
00049 {}
00050 
00051 template<class GM>
00052 inline void
00053 ViewSpace<GM>::assign(
00054    const GM & gm
00055 )
00056 {
00057    space_=& gm.space();
00058 }
00059 
00060 template<class GM>
00061 inline typename  ViewSpace<GM>::IndexType
00062 ViewSpace<GM>::addVariable(
00063    const LabelType numberOfLabels
00064 )
00065 {
00066    opengm::RuntimeError("cannot add Variable with a ViewSpace as a space object");
00067 }
00068 
00069 template<class GM>
00070 inline typename ViewSpace<GM>::IndexType
00071 ViewSpace<GM>::numberOfVariables() const
00072 {
00073    OPENGM_ASSERT(space_!=NULL);
00074    return space_->numberOfVariables();
00075 }
00076 
00077 template<class GM>
00078 inline typename ViewSpace<GM>::IndexType
00079 ViewSpace<GM>::numberOfLabels
00080 (
00081    const IndexType dimension
00082 ) const
00083 {
00084    OPENGM_ASSERT(space_!=NULL);
00085    return space_->numberOfLabels(dimension);
00086 }
00087 
00088 } // namespace opengm
00089 
00091 
00092 #endif // #ifndef OPENGM_VIEW_SPACE_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