ToPS
ProbabilisticModelDecorator.hpp
00001 /*
00002  *       ProbabilisticModelDecorator.hpp
00003  *
00004  *       Copyright 2011 Andre Yoshiaki Kashiwabara <akashiwabara@usp.br>
00005  *                      Ígor Bonádio <ibonadio@ime.usp.br>
00006  *                      Vitor Onuchic <vitoronuchic@gmail.com>
00007  *                      Alan Mitchell Durham <aland@usp.br>
00008  *
00009  *       This program is free software; you can redistribute it and/or modify
00010  *       it under the terms of the GNU  General Public License as published by
00011  *       the Free Software Foundation; either version 3 of the License, or
00012  *       (at your option) any later version.
00013  *
00014  *       This program is distributed in the hope that it will be useful,
00015  *       but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *       GNU General Public License for more details.
00018  *
00019  *       You should have received a copy of the GNU General Public License
00020  *       along with this program; if not, write to the Free Software
00021  *       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022  *       MA 02110-1301, USA.
00023  */
00024 
00025 #include "crossplatform.hpp"
00026 
00027 #include "ProbabilisticModel.hpp"
00028 #include <string>
00029 namespace tops {
00031   class DLLEXPORT ProbabilisticModelDecorator : public ProbabilisticModel {
00032   private:
00033     ProbabilisticModelPtr _model;
00034     std::string _submodelname;
00035   public:
00036     ProbabilisticModelDecorator(ProbabilisticModelPtr m) :_model(m){};
00037     virtual ~ProbabilisticModelDecorator() {};
00039     virtual double evaluate(const Sequence & s, unsigned int begin, unsigned int end) const {
00040       double result;
00041       result = _model->evaluate(s,begin,end);
00042       return result;
00043     }
00044 
00045     virtual double  log_probability_of(int s) const{
00046       double result ;
00047       result = _model->log_probability_of(s);
00048       return result;
00049     }
00051     virtual double choose() const {
00052       double result;
00053       result = _model->choose();
00054       return result;
00055     }
00056 
00057     virtual Sequence & choose(Sequence & h, int size) const {
00058       _model->choose(h,size);
00059       return h;
00060     }
00061 
00062     virtual Sequence & choose(Sequence &h, int initial_phase, int size) const{
00063       _model->choose(h,initial_phase, size);
00064       return h;
00065     }
00066 
00067     virtual Sequence & choose(Sequence & h, Sequence & path,  int size) const
00068     {
00069       _model->choose(h,path, size);
00070       return h;
00071     }
00072 
00073 
00074     virtual Sequence & choose(Sequence & h, Sequence & path,  int i, int size) const
00075     {
00076       _model->choose(h, path, i, size);
00077       return h;
00078     }
00079 
00080     virtual Sequence & chooseWithHistory(Sequence & h, int i,  int size) const
00081     {
00082       _model-> chooseWithHistory(h,i,size);
00083       return h;
00084     }
00085 
00086     virtual Sequence & chooseWithHistory(Sequence & h, int i,  int phase, int size) const{
00087       _model->chooseWithHistory(h, i, phase,  size);
00088       return h;
00089     }
00090 
00091     virtual double prefix_sum_array_compute(int begin , int end) {
00092       return _model->prefix_sum_array_compute(begin,end);
00093     }
00094 
00095     virtual double prefix_sum_array_compute(int begin , int end, int phase) {
00096       return _model->prefix_sum_array_compute(begin,end,phase);
00097     }
00098 
00099     virtual bool initialize_prefix_sum_array(const Sequence & s, int phase) {
00100       return initialize_prefix_sum_array(s);
00101     }
00102     virtual bool initialize_prefix_sum_array(const Sequence & s) {
00103       return _model->initialize_prefix_sum_array(s);
00104     }
00105     virtual ProbabilisticModelPtr subModel() const {
00106       return _model;
00107     }
00108     virtual void setSubModel(ProbabilisticModelPtr model) {
00109       _model =model;
00110     }
00111     virtual void  subModelName(std::string name) {
00112       _submodelname = name;
00113     }
00114     virtual std::string subModelName() const{
00115       return _submodelname;
00116     }
00117 
00118   };
00119   typedef boost::shared_ptr<ProbabilisticModelDecorator> ProbabilisticModelDecoratorPtr;
00120 }