Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/sketch/sketch_add.hpp
Go to the documentation of this file.
00001 #ifndef SKYLARK_SKETCH_ADD_HPP
00002 #define SKYLARK_SKETCH_ADD_HPP
00003 
00004 #ifndef SKYLARK_SKETCH_HPP
00005 #error "Include top-level sketch.hpp instead of including individuals headers"
00006 #endif
00007 
00013 namespace skylark { namespace sketch {
00014 
00015 sketch_transform_data_t*
00016 sketch_transform_data_t::from_ptree(const boost::property_tree::ptree& pt) {
00017     std::string type = pt.get<std::string>("sketch_type");
00018 
00019 # define AUTO_LOAD_DISPATCH(T, C)                    \
00020     if (type == #T)                                  \
00021         return new C(pt);
00022 
00023     AUTO_LOAD_DISPATCH(JLT, JLT_data_t);
00024     AUTO_LOAD_DISPATCH(CT,  CT_data_t);
00025     AUTO_LOAD_DISPATCH(CWT, CWT_data_t);
00026     AUTO_LOAD_DISPATCH(MMT, MMT_data_t);
00027     AUTO_LOAD_DISPATCH(WZT, WZT_data_t);
00028     AUTO_LOAD_DISPATCH(PPT, PPT_data_t);
00029 
00030     AUTO_LOAD_DISPATCH(GaussianRFT,  GaussianRFT_data_t);
00031     AUTO_LOAD_DISPATCH(LaplacianRFT, LaplacianRFT_data_t);
00032 
00033     AUTO_LOAD_DISPATCH(ExpSemigroupRLT, ExpSemigroupRLT_data_t);
00034     AUTO_LOAD_DISPATCH(FastGaussianRFT, FastGaussianRFT_data_t);
00035 
00036 #if SKYLARK_HAVE_FFTW
00037     AUTO_LOAD_DISPATCH(FJLT, FJLT_data_t);
00038 #endif
00039 
00040 #undef AUTO_LOAD_DISPATCH
00041 
00042     SKYLARK_THROW_EXCEPTION(base::sketch_exception());
00043 
00044     return nullptr;
00045 }
00046 
00047 template<typename IT, typename OT>
00048 sketch_transform_t<IT, OT>*
00049 sketch_transform_t<IT, OT>::from_ptree(const boost::property_tree::ptree& pt) {
00050     std::string type = pt.get<std::string>("sketch_type");
00051 
00052 # define AUTO_LOAD_DISPATCH(T, C)                    \
00053     if (type == #T)                                  \
00054         return new C<IT,OT>(pt);
00055 
00056     AUTO_LOAD_DISPATCH(JLT, JLT_t);
00057     AUTO_LOAD_DISPATCH(CT,  CT_t);
00058     AUTO_LOAD_DISPATCH(CWT, CWT_t);
00059     AUTO_LOAD_DISPATCH(MMT, MMT_t);
00060     AUTO_LOAD_DISPATCH(WZT, WZT_t);
00061     AUTO_LOAD_DISPATCH(PPT, PPT_t);
00062 
00063     AUTO_LOAD_DISPATCH(GaussianRFT,  GaussianRFT_t);
00064     AUTO_LOAD_DISPATCH(LaplacianRFT, LaplacianRFT_t);
00065 
00066     AUTO_LOAD_DISPATCH(ExpSemigroupRLT, ExpSemigroupRLT_t);
00067     AUTO_LOAD_DISPATCH(FastGaussianRFT, FastGaussianRFT_t);
00068 
00069 #if SKYLARK_HAVE_FFTW
00070     AUTO_LOAD_DISPATCH(FJLT, FJLT_t);
00071 #endif
00072 
00073 #undef AUTO_LOAD_DISPATCH
00074 
00075     SKYLARK_THROW_EXCEPTION(base::sketch_exception());
00076 
00077     return nullptr;
00078 }
00079 
00080 } }    // namespace skylark::sketch
00081 
00082 #endif // SKYLARK_SKETCH_ADD_HPP